home.uvue 8.9 KB

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