CSS.uvue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <template>
  2. <!-- #ifdef APP -->
  3. <scroll-view style="flex: 1;" enable-back-to-top="true">
  4. <!-- #endif -->
  5. <view class="uni-container" :class="isDarkMode ? 'theme-dark' : 'theme-light'">
  6. <view v-if="!hasLeftWin" class="uni-header-logo">
  7. <image class="uni-header-image" src="/static/cssIndex.png"></image>
  8. </view>
  9. <view v-if="!hasLeftWin" class="uni-text-box">
  10. <text class="hello-text">uni-app x目前已支持的CSS属性,展示样式仅供参考,文档详见:</text>
  11. <u-link :href="'https://uniapp.dcloud.io/uni-app-x/css/'" :text="'https://uniapp.dcloud.io/uni-app-x/css/'"
  12. :inWhiteList="true"></u-link>
  13. </view>
  14. <uni-collapse>
  15. <uni-collapse-item ref="category" v-for="menuItem in menu" :key="menuItem.id" :title="menuItem.name"
  16. class="uni-panel">
  17. <template v-for="childMenuItem in menuItem.items" :key="childMenuItem.id">
  18. <view v-if="childMenuItem.items.length==0" class="uni-navigate-item pl"
  19. hover-class="is--active" @click="goPage(`/${childMenuItem.path}`)">
  20. <text class="uni-navigate-text" :class="{
  21. 'left-win-active': leftWinActive === childMenuItem.path && hasLeftWin,
  22. }">{{ childMenuItem.style["navigationBarTitleText"] }}</text>
  23. <image :src="arrowRightIcon" class="uni-icon-size"></image>
  24. </view>
  25. <uni-collapse v-else style="width: 100%;border-top: 1px solid #f0f0f0;">
  26. <uni-collapse-item :title="childMenuItem.name" class="uni-panel"
  27. style="margin-bottom: 0;">
  28. <view class="uni-navigate-item pl" hover-class="is--active"
  29. v-for="grandChildMenuItem in childMenuItem.items" :key="grandChildMenuItem.path"
  30. @click="goPage(`/${grandChildMenuItem.path}`)">
  31. <text class="uni-navigate-text" :class="{
  32. 'left-win-active':
  33. leftWinActive === grandChildMenuItem.path && hasLeftWin,
  34. }">{{ grandChildMenuItem.style["navigationBarTitleText"] }}</text>
  35. <image :src="arrowRightIcon" class="uni-icon-size"></image>
  36. </view>
  37. </uni-collapse-item>
  38. </uni-collapse>
  39. </template>
  40. </uni-collapse-item>
  41. </uni-collapse>
  42. </view>
  43. <!-- #ifdef APP -->
  44. </scroll-view>
  45. <!-- #endif -->
  46. </template>
  47. <script lang="uts">
  48. import { generateMenu, MenuItem } from './generateMenu.uts'
  49. const menu = generateMenu('pages/CSS')
  50. import { state } from '@/store/index.uts'
  51. export default {
  52. data() {
  53. return {
  54. menu: menu as MenuItem[],
  55. arrowRightIcon: '/static/icons/arrow-right.png'
  56. }
  57. },
  58. computed: {
  59. hasLeftWin() : boolean {
  60. return !state.noMatchLeftWindow
  61. },
  62. leftWinActive() : string {
  63. return state.leftWinActive.slice(1)
  64. },
  65. isDarkMode() : boolean {
  66. return state.isDarkMode
  67. }
  68. },
  69. methods: {
  70. goPage(url : string) {
  71. if (this.hasLeftWin) {
  72. uni.reLaunch({ url })
  73. } else {
  74. uni.navigateTo({ url })
  75. }
  76. }
  77. },
  78. // #ifdef WEB
  79. watch: {
  80. $route: {
  81. immediate: true,
  82. handler(newRoute) {
  83. if (newRoute.matched.length) {
  84. const activeCategoryIndex = this.menu.findIndex(menuItem => menuItem?.items.some(item => this.leftWinActive && this.leftWinActive === item?.path))
  85. if (activeCategoryIndex > -1) {
  86. this.$nextTick(() => {
  87. ((this.$refs.category as ComponentPublicInstance[])[activeCategoryIndex]).$callMethod('openCollapse', true)
  88. })
  89. }
  90. }
  91. }
  92. }
  93. },
  94. // #endif
  95. }
  96. </script>
  97. <style>
  98. .pl{
  99. padding-left: 18px
  100. }
  101. </style>