component.uvue 7.6 KB
Newer Older
DCloud-WZF's avatar
DCloud-WZF 已提交
1
<template>
2 3 4 5 6 7 8 9 10 11
  <!-- #ifdef APP -->
  <scroll-view style="flex: 1">
    <!-- #endif -->
    <view class="uni-container">
      <view class="uni-header-logo">
        <image
          class="uni-header-image"
          src="/static/componentIndex.png"
        ></image>
      </view>
Y
yurj26 已提交
12
      <view class="uni-text-box">
13 14 15 16
        <text class="hello-text"
          >uni-app内置组件,展示样式仅供参考,文档详见:</text
        >
        <u-link
W
wanganxp 已提交
17 18
          :href="'https://uniapp.dcloud.io/uni-app-x/component/'"
          :text="'https://uniapp.dcloud.io/uni-app-x/component/'"
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
          :inWhiteList="true"
        ></u-link>
      </view>
      <uni-collapse>
        <template v-for="item in list" :key="item.id">
          <uni-collapse-item :title="item.name" class="item">
            <view
              class="uni-navigate-item"
              :hover-class="page.enable == false ? '' : 'is--active'"
              v-for="(page, key) in item.pages"
              :key="key"
              @click="goDetailPage(page)"
            >
              <text
                class="uni-navigate-text"
                :class="page.enable == false ? 'text-disabled' : ''"
                >{{ page.name }}</text
              >
              <image :src="arrowRightIcon" class="uni-icon"></image>
            </view>
          </uni-collapse-item>
        </template>
D
DCloud_LXH 已提交
41 42
      </uni-collapse>

43
      <!-- #ifdef UNI-APP-X && APP -->
D
DCloud_LXH 已提交
44
      <uni-upgrade-center-app ref="upgradePopup" @close="upgradePopupClose" />
45
      <!-- #endif -->
46 47 48 49
    </view>
    <!-- #ifdef APP -->
  </scroll-view>
  <!-- #endif -->
DCloud-WZF's avatar
DCloud-WZF 已提交
50 51
</template>

D
DCloud_LXH 已提交
52
<script lang="uts">
53
// #ifdef UNI-APP-X && APP
D
DCloud_LXH 已提交
54 55
import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update'
// #endif
D
DCloud_LXH 已提交
56

57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
type Page = {
  name : string
  enable ?: boolean
  url ?: string
}
type ListItem = {
  id : string
  name : string
  pages : Page[]
  url ?: string
  enable ?: boolean
}
export default {
  data() {
    return {
      list: [
        {
          id: 'view',
          name: '视图容器',
          pages: [
            {
              name: 'view',
            },
            {
              name: 'scroll-view',
            },
            {
              name: 'swiper',
            },
            /*
              {
                name: 'movable-view',
                enable: false
              },
              {
                name: 'cover-view',
                enable: false
              },
              */
            {
W
wanganxp 已提交
97
              name: 'list-view',
D
DCloud_LXH 已提交
98 99 100 101 102 103
            },
            {
              name: 'sticky-header',
            },
            {
              name: 'sticky-section',
shutao-dc's avatar
shutao-dc 已提交
104
            }
105 106 107 108 109 110 111 112 113 114 115
          ] as Page[],
        },
        {
          id: 'content',
          name: '基础内容',
          pages: [
            {
              name: 'text',
            },
            {
              name: 'rich-text',
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
116
              enable: true,
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
            },
            {
              name: 'progress',
            },
          ] as Page[],
        },
        {
          id: 'form',
          name: '表单组件',
          pages: [
            {
              name: 'button',
            },
            {
              name: 'checkbox',
            },
133 134 135
            {
              name: 'form',
            },
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232
            {
              name: 'input',
              /* }, {
                  name: 'label',
                  enable: false
                }, {
                  name: 'picker',
                  enable: false */
            },
            {
              name: 'picker-view',
            },
            {
              name: 'radio',
            },
            {
              name: 'slider',
            },
            {
              name: 'slider-100',
            },
            {
              name: 'switch',
            },
            {
              name: 'textarea',
            },
            /*
              {
                name: 'editor',
                enable: false
              },
              */
          ] as Page[],
        },
        {
          id: 'nav',
          name: '导航',
          pages: [{
            name: 'navigator',
            enable: true
          }] as Page[],
        },
        {
          id: 'media',
          name: '媒体组件',
          pages: [
            {
              name: 'image',
              enable: true,
            },
            {
              name: 'video',
              enable: true,
            },
            {
              name: 'animation-view',
              enable: false,
            },
          ] as Page[],
        },
        /*
          {
            id: 'map',
            name: '地图',
            pages: [
              {
                name: 'map',
                enable: false
              }
            ] as Page[]
          },
          {
            id: 'canvas',
            name: '画布',
            pages: [
              {
                name: 'canvas'
              }
            ] as Page[]
          },
          */
        {
          id: 'web-view',
          name: '网页',
          pages: [
            {
              name: '网络网页',
              enable: true,
              url: '/pages/component/web-view/web-view',
            },
            {
              name: '本地网页',
              enable: true,
              url: '/pages/component/web-view-local/web-view-local',
            },
          ] as Page[],
D
DCloud_LXH 已提交
233 234 235 236 237 238 239 240 241 242 243
        },
        {
          id: 'unicloud-db',
          name: 'unicloud-db',
          pages: [
            {
              name: '联系人',
              enable: true,
              url: '/pages/component/unicloud-db-contacts/list'
            }
          ] as Page[],
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266
        },
        /*
          {
            id: 'ad',
            url: 'ad',
            name: 'AD组件',
            enable: false,
            pages: [] as Page[]
          }
          */
           {
         id: 'general-attr-event',
         name: '通用属性和事件',
         pages: [
           {
             name: '通用属性',
             url: '/pages/component/general-attribute/general-attribute',
             enable: true,
           },
           {
             name: '通用事件',
             url: '/pages/component/general-event/general-event',
             enable: true,
张磊 已提交
267 268
           },{
             name: 'Transition事件',
269
             url: '/pages/component/general-event/transition-event',
张磊 已提交
270
             enable: true,
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293
           },
         ] as Page[],
       }
      ] as ListItem[],
      arrowUpIcon: '/static/icons/arrow-up.png',
      arrowDownIcon: '/static/icons/arrow-down.png',
      arrowRightIcon: '/static/icons/arrow-right.png',
    }
  },
  methods: {
    goDetailPage(e : Page) {
      if (e.enable == false) {
        uni.showToast({
          title: '暂不支持',
          icon: 'none',
        })
        return
      }
      const url =
        e.url != null ? e.url! : `/pages/component/${e.name}/${e.name}`
      uni.navigateTo({
        url,
      })
D
DCloud_LXH 已提交
294
    }
295
    // #ifdef UNI-APP-X && APP
D
DCloud_LXH 已提交
296 297 298 299 300 301
    ,upgradePopupClose() {
      console.log('upgradePopup close');
    }
    // #endif
  },
  onReady() {
302
    // #ifdef UNI-APP-X && APP
D
DCloud_LXH 已提交
303
  	checkUpdate(this.$refs['upgradePopup'] as UniUpgradeCenterAppComponentPublicInstance)
304
    // #endif
D
DCloud_LXH 已提交
305 306 307
  },
  beforeUnmount() {
    uni.showTabBar()?.catch(_ => {})
D
DCloud_LXH 已提交
308
  }
309
}
DCloud-WZF's avatar
DCloud-WZF 已提交
310 311 312
</script>

<style>
313
@import "../../common/uni-uvue.css";
M
mehaotian 已提交
314

315 316 317 318
.item {
  margin-bottom: 12px;
}
</style>