template.uvue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <template>
  2. <cl-page>
  3. <view class="p-3">
  4. <cl-list
  5. v-for="(item, index) in list"
  6. :key="index"
  7. :title="item.label"
  8. :pt="{
  9. className: 'mb-5'
  10. }"
  11. >
  12. <cl-list-item
  13. v-for="child in item.children"
  14. :key="child.label"
  15. :label="child.label"
  16. :arrow="child.path != null"
  17. :pt="{
  18. label: {
  19. className: '!w-auto'
  20. }
  21. }"
  22. @tap="toPath(child)"
  23. >
  24. </cl-list-item>
  25. </cl-list>
  26. </view>
  27. <!-- 自定义底部导航栏 -->
  28. <tabbar></tabbar>
  29. </cl-page>
  30. </template>
  31. <script setup lang="ts">
  32. import Tabbar from "@/components/tabbar.uvue";
  33. import { router } from "@/cool";
  34. import { t } from "@/locale";
  35. import { useUi } from "@/uni_modules/cool-ui";
  36. import { computed } from "vue";
  37. const ui = useUi();
  38. type Item = {
  39. label: string;
  40. path?: string;
  41. children?: Item[];
  42. };
  43. const list = computed<Item[]>(() => [
  44. {
  45. label: t("商城"),
  46. children: [
  47. {
  48. label: t("商品分类"),
  49. path: "/pages/template/shop/goods-category"
  50. },
  51. {
  52. label: t("商品详情")
  53. },
  54. {
  55. label: t("商品列表、筛选")
  56. },
  57. {
  58. label: t("购物车")
  59. },
  60. {
  61. label: t("订单列表、详情")
  62. }
  63. ]
  64. },
  65. {
  66. label: t("聊天"),
  67. children: [
  68. {
  69. label: t("对话列表、历史记录")
  70. }
  71. ]
  72. },
  73. {
  74. label: "AI",
  75. children: [
  76. {
  77. label: t("流式回复")
  78. },
  79. {
  80. label: t("语言合成")
  81. },
  82. {
  83. label: t("语音识别")
  84. }
  85. ]
  86. },
  87. {
  88. label: t("其他"),
  89. children: [
  90. {
  91. label: t("文件管理")
  92. }
  93. ]
  94. }
  95. ]);
  96. function toPath(item: Item) {
  97. if (item.path == null) {
  98. return ui.showToast({
  99. message: t("该模板正在开发中")
  100. });
  101. }
  102. router.to(item.path!);
  103. }
  104. </script>