home.uvue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535
  1. <template>
  2. <cl-page>
  3. <cl-topbar
  4. fixed
  5. :show-back="false"
  6. safe-area-top
  7. :height="isMp() ? null : 100"
  8. :pt="{
  9. className: '!z-50'
  10. }"
  11. >
  12. <view
  13. class="flex flex-row items-center p-3 flex-1 w-full"
  14. :class="{
  15. 'pt-0': isMp()
  16. }"
  17. >
  18. <view class="bg-primary-500 rounded-lg p-[12rpx]">
  19. <cl-image
  20. src="/static/logo.png"
  21. :width="32"
  22. :height="32"
  23. :show-loading="false"
  24. ></cl-image>
  25. </view>
  26. <cl-text
  27. color="primary"
  28. :pt="{
  29. className: '!text-xl mr-auto ml-2 flex-1'
  30. }"
  31. >
  32. {{ config.name }}
  33. </cl-text>
  34. <view
  35. class="bg-surface-500 h-8 w-8 rounded-full flex flex-row items-center justify-center mr-3"
  36. @tap="setSize"
  37. >
  38. <cl-icon name="font-size" color="white"></cl-icon>
  39. </view>
  40. <view
  41. class="bg-primary-500 h-8 w-8 rounded-full flex flex-row items-center justify-center"
  42. :class="{
  43. 'mr-24': isMp()
  44. }"
  45. @tap="setLocale"
  46. >
  47. <cl-icon name="translate" color="white"></cl-icon>
  48. </view>
  49. </view>
  50. </cl-topbar>
  51. <view class="p-3">
  52. <view class="group" v-for="item in data" :key="item.label">
  53. <cl-text :pt="{ className: '!text-sm !text-surface-400 mb-2 ml-2' }"
  54. >{{ item.label }}({{ item.children?.length ?? 0 }})</cl-text
  55. >
  56. <view class="list">
  57. <cl-row :gutter="10">
  58. <template v-for="child in item.children" :key="child.label">
  59. <cl-col :span="6" v-if="child.hidden != true">
  60. <view
  61. class="item dark:!bg-surface-800"
  62. hover-class="opacity-80"
  63. :hover-stay-time="250"
  64. @tap="toPath(child)"
  65. >
  66. <cl-icon :name="child.icon" :size="36"></cl-icon>
  67. <cl-text
  68. :pt="{
  69. className: 'mt-1 !text-xs text-center'
  70. }"
  71. >{{ child.label }}</cl-text
  72. >
  73. </view>
  74. </cl-col>
  75. </template>
  76. </cl-row>
  77. </view>
  78. </view>
  79. </view>
  80. <!-- 自定义底部导航栏 -->
  81. <custom-tabbar></custom-tabbar>
  82. <!-- 主题设置 -->
  83. <locale-set :ref="refs.set('localeSet')"></locale-set>
  84. <!-- 字体大小设置 -->
  85. <size-set :ref="refs.set('sizeSet')"></size-set>
  86. </cl-page>
  87. </template>
  88. <script lang="ts" setup>
  89. import { isApp, isMp, router, useRefs } from "@/cool";
  90. import { t } from "@/locale";
  91. import { computed } from "vue";
  92. import { useUi } from "@/uni_modules/cool-ui";
  93. import { config } from "@/config";
  94. import LocaleSet from "@/components/locale-set.uvue";
  95. import SizeSet from "@/components/size-set.uvue";
  96. import CustomTabbar from "@/components/tabbar.uvue";
  97. const ui = useUi();
  98. const refs = useRefs();
  99. type Item = {
  100. label: string;
  101. icon?: string;
  102. path?: string;
  103. disabled?: boolean;
  104. hidden?: boolean;
  105. children?: Item[];
  106. };
  107. const data = computed<Item[]>(() => {
  108. return [
  109. {
  110. label: t("基础组件"),
  111. children: [
  112. {
  113. label: t("文本"),
  114. icon: "text",
  115. path: "/pages/demo/basic/text"
  116. },
  117. {
  118. label: t("按钮"),
  119. icon: "mouse-line",
  120. path: "/pages/demo/basic/button"
  121. },
  122. {
  123. label: t("图片"),
  124. icon: "image-line",
  125. path: "/pages/demo/basic/image"
  126. },
  127. {
  128. label: t("图标"),
  129. icon: "puzzle-2-line",
  130. path: "/pages/demo/basic/icon"
  131. },
  132. {
  133. label: t("标签"),
  134. icon: "price-tag-3-line",
  135. path: "/pages/demo/basic/tag"
  136. }
  137. ]
  138. },
  139. {
  140. label: t("表单组件"),
  141. children: [
  142. {
  143. label: t("表单验证"),
  144. icon: "draft-line",
  145. path: "/pages/demo/form/form"
  146. },
  147. {
  148. label: t("输入框"),
  149. icon: "input-field",
  150. path: "/pages/demo/form/input"
  151. },
  152. {
  153. label: t("文本域"),
  154. icon: "text-block",
  155. path: "/pages/demo/form/textarea"
  156. },
  157. {
  158. label: t("计数器"),
  159. icon: "increase-decrease-line",
  160. path: "/pages/demo/form/input-number"
  161. },
  162. {
  163. label: t("口令输入"),
  164. icon: "input-method-line",
  165. path: "/pages/demo/form/input-otp"
  166. },
  167. {
  168. label: t("键盘"),
  169. icon: "keyboard-box-line",
  170. path: "/pages/demo/form/keyboard"
  171. },
  172. {
  173. label: t("单选框"),
  174. icon: "radio-button-line",
  175. path: "/pages/demo/form/radio"
  176. },
  177. {
  178. label: t("多选框"),
  179. icon: "checkbox-line",
  180. path: "/pages/demo/form/checkbox"
  181. },
  182. {
  183. label: t("开关"),
  184. icon: "toggle-line",
  185. path: "/pages/demo/form/switch"
  186. },
  187. {
  188. label: t("评分"),
  189. icon: "star-line",
  190. path: "/pages/demo/form/rate"
  191. },
  192. {
  193. label: t("滑块"),
  194. icon: "equalizer-2-line",
  195. path: "/pages/demo/form/slider"
  196. },
  197. {
  198. label: t("选择器"),
  199. icon: "dropdown-list",
  200. path: "/pages/demo/form/select"
  201. },
  202. {
  203. label: t("日期选择器"),
  204. icon: "calendar-line",
  205. path: "/pages/demo/form/select-date"
  206. },
  207. {
  208. label: t("时间选择器"),
  209. icon: "time-line",
  210. path: "/pages/demo/form/select-time"
  211. },
  212. {
  213. label: t("级联选择器"),
  214. icon: "stacked-view",
  215. path: "/pages/demo/form/cascader"
  216. },
  217. {
  218. label: t("文件上传"),
  219. icon: "file-upload-line",
  220. path: "/pages/demo/form/upload"
  221. },
  222. {
  223. label: t("日历"),
  224. icon: "calendar-line",
  225. path: "/pages/demo/form/calendar"
  226. }
  227. ]
  228. },
  229. {
  230. label: t("布局组件"),
  231. children: [
  232. {
  233. label: t("弹性布局"),
  234. icon: "layout-2-line",
  235. path: "/pages/demo/layout/flex"
  236. },
  237. {
  238. label: t("标签页"),
  239. icon: "function-add-line",
  240. path: "/pages/demo/layout/tabs"
  241. },
  242. {
  243. label: t("折叠面板"),
  244. icon: "collapse-vertical-line",
  245. path: "/pages/demo/layout/collapse"
  246. },
  247. {
  248. label: t("吸顶"),
  249. icon: "align-top",
  250. path: "/pages/demo/layout/sticky"
  251. },
  252. {
  253. label: t("导航栏"),
  254. icon: "layout-top-line",
  255. path: "/pages/demo/layout/topbar"
  256. },
  257. {
  258. label: t("底部视图"),
  259. icon: "layout-bottom-line",
  260. path: "/pages/demo/layout/footer"
  261. },
  262. {
  263. label: t("悬浮视图"),
  264. icon: "picture-in-picture-line",
  265. path: "/pages/demo/layout/float-view"
  266. }
  267. ]
  268. },
  269. {
  270. label: t("数据展示"),
  271. children: [
  272. {
  273. label: t("头像"),
  274. icon: "account-circle-line",
  275. path: "/pages/demo/data/avatar"
  276. },
  277. {
  278. label: t("查看更多"),
  279. icon: "menu-add-line",
  280. path: "/pages/demo/data/read-more"
  281. },
  282. {
  283. label: t("列表"),
  284. icon: "list-check",
  285. path: "/pages/demo/data/list"
  286. },
  287. {
  288. label: t("列表视图"),
  289. icon: "list-view",
  290. path: "/pages/demo/data/list-view"
  291. },
  292. {
  293. label: t("列表刷新"),
  294. icon: "refresh-line",
  295. path: "/pages/demo/data/list-view-refresh",
  296. disabled: false
  297. },
  298. {
  299. label: t("瀑布流"),
  300. icon: "layout-column-line",
  301. path: "/pages/demo/data/waterfall"
  302. },
  303. {
  304. label: t("轮播图"),
  305. icon: "carousel-view",
  306. path: "/pages/demo/data/banner"
  307. },
  308. {
  309. label: t("跑马灯"),
  310. icon: "film-line",
  311. path: "/pages/demo/data/marquee"
  312. },
  313. {
  314. label: t("分页"),
  315. icon: "page-separator",
  316. path: "/pages/demo/data/pagination"
  317. },
  318. {
  319. label: t("时间轴"),
  320. icon: "timeline-view",
  321. path: "/pages/demo/data/timeline"
  322. },
  323. {
  324. label: t("拖拽"),
  325. icon: "drag-move-line",
  326. path: "/pages/demo/data/draggable"
  327. },
  328. {
  329. label: t("筛选栏"),
  330. icon: "filter-line",
  331. path: "/pages/demo/data/filter-bar"
  332. },
  333. {
  334. label: t("树形结构"),
  335. icon: "node-tree",
  336. path: "/pages/demo/data/tree"
  337. }
  338. ]
  339. },
  340. {
  341. label: t("状态组件"),
  342. children: [
  343. {
  344. label: t("角标"),
  345. icon: "notification-badge-line",
  346. path: "/pages/demo/status/badge"
  347. },
  348. {
  349. label: t("通知栏"),
  350. icon: "error-warning-line",
  351. path: "/pages/demo/status/noticebar"
  352. },
  353. {
  354. label: t("倒计时"),
  355. icon: "timer-line",
  356. path: "/pages/demo/status/countdown"
  357. },
  358. {
  359. label: t("数字滚动"),
  360. icon: "arrow-up-box-line",
  361. path: "/pages/demo/status/rolling-number"
  362. },
  363. {
  364. label: t("进度条"),
  365. icon: "subtract-line",
  366. path: "/pages/demo/status/progress"
  367. },
  368. {
  369. label: t("圆形进度条"),
  370. icon: "circle-line",
  371. path: "/pages/demo/status/progress-circle"
  372. },
  373. {
  374. label: t("骨架图"),
  375. icon: "shadow-line",
  376. path: "/pages/demo/status/skeleton"
  377. },
  378. {
  379. label: t("加载更多"),
  380. icon: "loader-4-line",
  381. path: "/pages/demo/status/loadmore"
  382. }
  383. ]
  384. },
  385. {
  386. label: t("反馈组件"),
  387. children: [
  388. {
  389. label: t("操作菜单"),
  390. icon: "menu-line",
  391. path: "/pages/demo/feedback/action-sheet"
  392. },
  393. {
  394. label: t("弹窗"),
  395. icon: "chat-4-line",
  396. path: "/pages/demo/feedback/popup"
  397. },
  398. {
  399. label: t("确认框"),
  400. icon: "chat-check-line",
  401. path: "/pages/demo/feedback/confirm"
  402. },
  403. {
  404. label: t("提示框"),
  405. icon: "message-2-line",
  406. path: "/pages/demo/feedback/toast"
  407. }
  408. ]
  409. },
  410. {
  411. label: "其他",
  412. children: [
  413. {
  414. label: "QRCode",
  415. icon: "qr-code-line",
  416. path: "/pages/demo/other/qrcode"
  417. },
  418. {
  419. label: t("签名"),
  420. icon: "sketching",
  421. path: "/pages/demo/other/sign"
  422. },
  423. {
  424. label: t("水印"),
  425. icon: "copyright-line",
  426. path: "/pages/demo/other/watermark"
  427. },
  428. {
  429. label: t("图片裁剪"),
  430. icon: "crop-line",
  431. path: "/pages/demo/other/cropper"
  432. },
  433. {
  434. label: t("Canvas"),
  435. icon: "markup-line",
  436. path: "/pages/demo/other/canvas"
  437. },
  438. {
  439. label: t("富文本"),
  440. icon: "text-snippet",
  441. path: "/pages/demo/other/rict-text",
  442. disabled: true
  443. },
  444. {
  445. label: "DayUts",
  446. icon: "timer-2-line",
  447. path: "/pages/demo/other/day-uts"
  448. },
  449. {
  450. label: "Vibrate",
  451. icon: "volume-vibrate-line",
  452. path: "/pages/demo/other/vibrate"
  453. },
  454. {
  455. label: "SVG",
  456. icon: "bubble-chart-line",
  457. path: "/pages/demo/other/svg"
  458. },
  459. {
  460. label: "SlideVerify",
  461. icon: "contract-right-fill",
  462. path: "/pages/demo/other/slide-verify"
  463. },
  464. {
  465. label: "Animation",
  466. icon: "instance-line",
  467. path: "/pages/demo/other/animation"
  468. },
  469. {
  470. label: "Router",
  471. icon: "compass-discover-line",
  472. path: "/pages/demo/other/router/index"
  473. },
  474. {
  475. label: "Share",
  476. icon: "share-line",
  477. path: "/pages/demo/other/share",
  478. hidden: !isApp()
  479. },
  480. {
  481. label: "选座",
  482. icon: "armchair-line",
  483. path: "/pages/demo/other/select-seat"
  484. }
  485. ]
  486. }
  487. ];
  488. });
  489. function toPath(item: Item) {
  490. if (item.disabled == true) {
  491. return ui.showToast({
  492. message: t("该功能正在开发中")
  493. });
  494. }
  495. router.to(item.path!);
  496. }
  497. function setLocale() {
  498. refs.open("localeSet");
  499. }
  500. function setSize() {
  501. refs.open("sizeSet");
  502. }
  503. </script>
  504. <style lang="scss" scoped>
  505. .group {
  506. @apply mb-10;
  507. .list {
  508. .item {
  509. @apply flex flex-col items-center;
  510. @apply rounded-xl bg-white px-2;
  511. height: 140rpx;
  512. margin-bottom: 10rpx;
  513. padding-top: 36rpx;
  514. }
  515. }
  516. }
  517. </style>