component.uvue 8.4 KB
Newer Older
1 2
<template>
  <!-- #ifdef APP -->
W
wanganxp 已提交
3
  <scroll-view style="flex: 1" enable-back-to-top="true">
W
wanganxp 已提交
4
  <!-- #endif -->
5 6
    <view class="uni-container">
      <view class="uni-header-logo">
W
wanganxp 已提交
7
        <image class="uni-header-image" src="/static/componentIndex.png"></image>
8 9
      </view>
      <view class="uni-text-box">
W
wanganxp 已提交
10 11 12
        <text class="hello-text">uni-app内置组件,展示样式仅供参考,文档详见:</text>
        <u-link :href="'https://uniapp.dcloud.io/uni-app-x/component/'"
          :text="'https://uniapp.dcloud.io/uni-app-x/component/'" :inWhiteList="true"></u-link>
13 14 15 16
      </view>
      <uni-collapse>
        <template v-for="item in list" :key="item.id">
          <uni-collapse-item :title="item.name" class="item">
W
wanganxp 已提交
17 18 19 20
            <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>
21
              <image :src="arrowRightIcon" class="uni-icon-size"></image>
22 23 24 25 26
            </view>
          </uni-collapse-item>
        </template>
      </uni-collapse>

DCloud_iOS_XHY's avatar
DCloud_iOS_XHY 已提交
27
      <!-- #ifdef UNI-APP-X && APP-ANDROID -->
28
      <uni-upgrade-center-app ref="upgradePopup" @show="upgradePopupShow" @close="upgradePopupClose" />
29 30
      <!-- #endif -->
    </view>
W
wanganxp 已提交
31
  <!-- #ifdef APP -->
32 33 34 35 36
  </scroll-view>
  <!-- #endif -->
</template>

<script lang="uts">
DCloud_iOS_XHY's avatar
DCloud_iOS_XHY 已提交
37
  // #ifdef UNI-APP-X && APP-ANDROID
W
wanganxp 已提交
38 39
  import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update'
  // #endif
40

W
wanganxp 已提交
41 42 43
  type Page = {
    name : string
    enable ?: boolean
W
wanganxp 已提交
44
    url ?: string.PageURIString
W
wanganxp 已提交
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
  }
  type ListItem = {
    id : string
    name : string
    pages : Page[]
    url ?: string
    enable ?: boolean
  }
  export default {
    data() {
      return {
        list: [
          {
            id: 'view',
            name: '视图容器',
            pages: [
61
              {
W
wanganxp 已提交
62
                name: 'view',
63 64
              },
              {
W
wanganxp 已提交
65
                name: 'scroll-view',
66
              },
W
wanganxp 已提交
67 68 69 70 71 72
              {
                name: 'swiper',
              },
              /*
                {
                  name: 'movable-view',
73
                  enable: false
W
wanganxp 已提交
74 75 76 77 78 79 80 81 82
                },
                {
                  name: 'cover-view',
                  enable: false
                },
                */
              {
                name: 'list-view',
              },
83
              {
W
wanganxp 已提交
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
                name: 'sticky-header',
              },
              {
                name: 'sticky-section',
              },
            ] as Page[],
          },
          {
            id: 'content',
            name: '基础内容',
            pages: [
              {
                name: 'text',
              },
              {
                name: 'rich-text',
                enable: true,
              },
              {
                name: 'progress',
              },
            ] as Page[],
          },
          {
            id: 'form',
            name: '表单组件',
            pages: [
              {
                name: 'button',
              },
              {
                name: 'checkbox',
              },
              {
                name: 'form',
              },
              {
                name: 'input',
              },
              /*
              {
                name: 'label',
              }, {
                name: 'picker',
128 129
              },
              */
W
wanganxp 已提交
130 131 132 133 134 135 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
              {
                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[],
          },
164
          {
W
wanganxp 已提交
165 166
            id: 'media',
            name: '媒体组件',
167 168
            pages: [
              {
W
wanganxp 已提交
169 170 171 172 173 174 175 176 177 178 179 180
                name: 'image',
                enable: true,
              },
              {
                name: 'video',
                enable: true,
              },
              /* {
                name: 'animation-view',
                enable: false,
              }, */
            ] as Page[],
181
          },
H
hdx 已提交
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200
          // {
          //   id: 'map',
          //   name: '地图',
          //   pages: [
          //     {
          //       name: 'map',
          //       enable: false
          //     }
          //   ] as Page[]
          // },
          // {
          //   id: 'canvas',
          //   name: '画布',
          //   pages: [
          //     {
          //       name: 'canvas'
          //     }
          //   ] as Page[]
          // },
W
wanganxp 已提交
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 233
          {
            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[],
          },
          {
            id: 'unicloud-db',
            name: 'unicloud-db',
            pages: [
              {
                name: '联系人',
                enable: true,
                url: '/pages/component/unicloud-db-contacts/list'
              },
              {
                name: 'mixinDatacom',
                enable: true,
                url: '/pages/component/mixin-datacom/mixin-datacom'
              }
            ] as Page[],
          },
          /*
H
hdx 已提交
234
            {
W
wanganxp 已提交
235 236 237 238 239
              id: 'ad',
              url: 'ad',
              name: 'AD组件',
              enable: false,
              pages: [] as Page[]
240
            }
W
wanganxp 已提交
241
            */
242
          {
W
wanganxp 已提交
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266
            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,
              },
              {
                name: 'touch事件',
                url: '/pages/component/general-event/touch-event',
                enable: true,
              },
              {
                name: 'Transition事件',
                url: '/pages/component/general-event/transition-event',
                enable: true,
              },
            ] as Page[],
267
          }
W
wanganxp 已提交
268
        ] as ListItem[],
W
wanganxp 已提交
269 270 271
        arrowUpIcon: '/static/icons/arrow-up.png' as string.ImageURIString,
        arrowDownIcon: '/static/icons/arrow-down.png' as string.ImageURIString,
        arrowRightIcon: '/static/icons/arrow-right.png' as string.ImageURIString,
W
wanganxp 已提交
272 273 274 275 276 277 278 279
        pageHiden: false
      }
    },
    methods: {
      goDetailPage(e : Page) {
        if (e.enable == false) {
          uni.showToast({
            title: '暂不支持',
W
wanganxp 已提交
280
            icon: 'none'
W
wanganxp 已提交
281 282 283 284 285 286 287
          })
          return
        }
        const url =
          e.url != null ? e.url! : `/pages/component/${e.name}/${e.name}`
        uni.navigateTo({
          url,
288 289
        })
      }
DCloud_iOS_XHY's avatar
DCloud_iOS_XHY 已提交
290
      // #ifdef UNI-APP-X && APP-ANDROID
W
wanganxp 已提交
291 292 293 294 295
      , upgradePopupShow() {
        console.log('upgradePopup show');
        if (!this.pageHiden) {
          uni.hideTabBar()?.catch(_ => { })
        }
296
      }
W
wanganxp 已提交
297 298 299 300 301 302 303
      , upgradePopupClose() {
        console.log('upgradePopup close');
        uni.showTabBar()?.catch(_ => { })
      }
      // #endif
    },
    onReady() {
DCloud_iOS_XHY's avatar
DCloud_iOS_XHY 已提交
304
      // #ifdef UNI-APP-X && APP-ANDROID
W
wanganxp 已提交
305 306 307 308 309 310 311 312 313 314 315
      checkUpdate(this.$refs['upgradePopup'] as UniUpgradeCenterAppComponentPublicInstance)
      // #endif
    },
    onShow() {
      this.pageHiden = false
    },
    onHide() {
      this.pageHiden = true
    },
    beforeUnmount() {
      uni.showTabBar()?.catch(_ => { })
316
    }
317 318 319 320
  }
</script>

<style>
W
wanganxp 已提交
321 322 323
  .item {
    margin-bottom: 12px;
  }
324
</style>