home.uvue 11 KB

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