home.uvue 9.3 KB

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