@kevairy/template 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (293) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +14 -0
  3. package/package.json +37 -0
  4. package/template/.env +22 -0
  5. package/template/.env.development +13 -0
  6. package/template/.env.production +10 -0
  7. package/template/.prettierignore +3 -0
  8. package/template/.prettierrc +20 -0
  9. package/template/.stylelintignore +9 -0
  10. package/template/.stylelintrc.cjs +84 -0
  11. package/template/LICENSE +21 -0
  12. package/template/README.md +22 -0
  13. package/template/_gitignore +19 -0
  14. package/template/eslint-auto-import.json +324 -0
  15. package/template/eslint.config.mjs +83 -0
  16. package/template/index.html +25 -0
  17. package/template/package.json +79 -0
  18. package/template/playwright.config.ts +25 -0
  19. package/template/public/favicon.ico +0 -0
  20. package/template/src/App.vue +39 -0
  21. package/template/src/adapters/auth/index.ts +9 -0
  22. package/template/src/adapters/auth/mock.ts +10 -0
  23. package/template/src/adapters/auth/types.ts +11 -0
  24. package/template/src/adapters/navigation/index.ts +13 -0
  25. package/template/src/adapters/navigation/types.ts +6 -0
  26. package/template/src/api/auth.ts +23 -0
  27. package/template/src/assets/images/avatar/avatar.webp +0 -0
  28. package/template/src/assets/images/avatar/avatar1.webp +0 -0
  29. package/template/src/assets/images/avatar/avatar10.webp +0 -0
  30. package/template/src/assets/images/avatar/avatar2.webp +0 -0
  31. package/template/src/assets/images/avatar/avatar3.webp +0 -0
  32. package/template/src/assets/images/avatar/avatar4.webp +0 -0
  33. package/template/src/assets/images/avatar/avatar5.webp +0 -0
  34. package/template/src/assets/images/avatar/avatar6.webp +0 -0
  35. package/template/src/assets/images/avatar/avatar7.webp +0 -0
  36. package/template/src/assets/images/avatar/avatar8.webp +0 -0
  37. package/template/src/assets/images/avatar/avatar9.webp +0 -0
  38. package/template/src/assets/images/ceremony/hb.png +0 -0
  39. package/template/src/assets/images/ceremony/sd.png +0 -0
  40. package/template/src/assets/images/ceremony/xc.png +0 -0
  41. package/template/src/assets/images/ceremony/yd.png +0 -0
  42. package/template/src/assets/images/common/logo.webp +0 -0
  43. package/template/src/assets/images/draw/draw1.png +0 -0
  44. package/template/src/assets/images/favicon.ico +0 -0
  45. package/template/src/assets/images/lock/bg_dark.webp +0 -0
  46. package/template/src/assets/images/lock/bg_light.webp +0 -0
  47. package/template/src/assets/images/login/kylin-hero-source.png +0 -0
  48. package/template/src/assets/images/login/lf_icon2.webp +0 -0
  49. package/template/src/assets/images/settings/menu_layouts/dual_column.png +0 -0
  50. package/template/src/assets/images/settings/menu_layouts/horizontal.png +0 -0
  51. package/template/src/assets/images/settings/menu_layouts/mixed.png +0 -0
  52. package/template/src/assets/images/settings/menu_layouts/vertical.png +0 -0
  53. package/template/src/assets/images/settings/menu_styles/dark.png +0 -0
  54. package/template/src/assets/images/settings/menu_styles/design.png +0 -0
  55. package/template/src/assets/images/settings/menu_styles/light.png +0 -0
  56. package/template/src/assets/images/settings/theme_styles/dark.png +0 -0
  57. package/template/src/assets/images/settings/theme_styles/light.png +0 -0
  58. package/template/src/assets/images/settings/theme_styles/system.png +0 -0
  59. package/template/src/assets/images/svg/403.svg +1 -0
  60. package/template/src/assets/images/svg/404.svg +1 -0
  61. package/template/src/assets/images/svg/500.svg +5 -0
  62. package/template/src/assets/images/svg/login_icon.svg +1 -0
  63. package/template/src/assets/images/user/avatar.webp +0 -0
  64. package/template/src/assets/images/user/bg.webp +0 -0
  65. package/template/src/assets/styles/core/app.scss +227 -0
  66. package/template/src/assets/styles/core/dark.scss +93 -0
  67. package/template/src/assets/styles/core/el-dark.scss +2 -0
  68. package/template/src/assets/styles/core/el-light.scss +34 -0
  69. package/template/src/assets/styles/core/el-ui.scss +519 -0
  70. package/template/src/assets/styles/core/md.scss +1036 -0
  71. package/template/src/assets/styles/core/mixin.scss +157 -0
  72. package/template/src/assets/styles/core/reset.scss +41 -0
  73. package/template/src/assets/styles/core/router-transition.scss +104 -0
  74. package/template/src/assets/styles/core/tailwind.css +219 -0
  75. package/template/src/assets/styles/core/theme-animation.scss +63 -0
  76. package/template/src/assets/styles/core/theme-change.scss +11 -0
  77. package/template/src/assets/styles/custom/one-dark-pro.scss +98 -0
  78. package/template/src/assets/styles/index.scss +23 -0
  79. package/template/src/assets/svg/loading.ts +32 -0
  80. package/template/src/bootstrap/initializeApp.ts +30 -0
  81. package/template/src/components/core/banners/art-basic-banner/index.vue +343 -0
  82. package/template/src/components/core/banners/art-card-banner/index.vue +114 -0
  83. package/template/src/components/core/base/art-back-to-top/index.vue +40 -0
  84. package/template/src/components/core/base/art-logo/index.vue +34 -0
  85. package/template/src/components/core/base/art-svg-icon/index.vue +24 -0
  86. package/template/src/components/core/cards/art-bar-chart-card/index.vue +103 -0
  87. package/template/src/components/core/cards/art-data-list-card/index.vue +74 -0
  88. package/template/src/components/core/cards/art-donut-chart-card/index.vue +124 -0
  89. package/template/src/components/core/cards/art-image-card/index.vue +89 -0
  90. package/template/src/components/core/cards/art-line-chart-card/index.vue +126 -0
  91. package/template/src/components/core/cards/art-progress-card/index.vue +86 -0
  92. package/template/src/components/core/cards/art-stats-card/index.vue +67 -0
  93. package/template/src/components/core/cards/art-timeline-list-card/index.vue +69 -0
  94. package/template/src/components/core/charts/art-bar-chart/index.vue +203 -0
  95. package/template/src/components/core/charts/art-dual-bar-compare-chart/index.vue +195 -0
  96. package/template/src/components/core/charts/art-h-bar-chart/index.vue +208 -0
  97. package/template/src/components/core/charts/art-k-line-chart/index.vue +152 -0
  98. package/template/src/components/core/charts/art-line-chart/index.vue +371 -0
  99. package/template/src/components/core/charts/art-radar-chart/index.vue +105 -0
  100. package/template/src/components/core/charts/art-ring-chart/index.vue +133 -0
  101. package/template/src/components/core/charts/art-scatter-chart/index.vue +115 -0
  102. package/template/src/components/core/feedback/art-page-loading/index.vue +281 -0
  103. package/template/src/components/core/forms/art-button-more/index.vue +71 -0
  104. package/template/src/components/core/forms/art-button-table/index.vue +59 -0
  105. package/template/src/components/core/forms/art-drag-verify/index.vue +430 -0
  106. package/template/src/components/core/forms/art-excel-export/index.vue +390 -0
  107. package/template/src/components/core/forms/art-excel-import/index.vue +62 -0
  108. package/template/src/components/core/forms/art-form/index.vue +507 -0
  109. package/template/src/components/core/forms/art-wang-editor/index.vue +261 -0
  110. package/template/src/components/core/forms/art-wang-editor/style.scss +273 -0
  111. package/template/src/components/core/layouts/art-breadcrumb/index.vue +142 -0
  112. package/template/src/components/core/layouts/art-chat-window/index.vue +262 -0
  113. package/template/src/components/core/layouts/art-fast-enter/index.vue +113 -0
  114. package/template/src/components/core/layouts/art-fireworks-effect/index.vue +633 -0
  115. package/template/src/components/core/layouts/art-global-component/index.vue +14 -0
  116. package/template/src/components/core/layouts/art-global-search/index.vue +431 -0
  117. package/template/src/components/core/layouts/art-header-bar/index.vue +485 -0
  118. package/template/src/components/core/layouts/art-header-bar/widget/ArtUserMenu.vue +118 -0
  119. package/template/src/components/core/layouts/art-menus/art-horizontal-menu/index.vue +110 -0
  120. package/template/src/components/core/layouts/art-menus/art-horizontal-menu/widget/HorizontalSubmenu.vue +106 -0
  121. package/template/src/components/core/layouts/art-menus/art-mixed-menu/index.vue +279 -0
  122. package/template/src/components/core/layouts/art-menus/art-sidebar-menu/index.vue +354 -0
  123. package/template/src/components/core/layouts/art-menus/art-sidebar-menu/style.scss +251 -0
  124. package/template/src/components/core/layouts/art-menus/art-sidebar-menu/theme.scss +258 -0
  125. package/template/src/components/core/layouts/art-menus/art-sidebar-menu/widget/SidebarSubmenu.vue +190 -0
  126. package/template/src/components/core/layouts/art-notification/index.vue +456 -0
  127. package/template/src/components/core/layouts/art-page-content/index.vue +137 -0
  128. package/template/src/components/core/layouts/art-settings-panel/composables/useSettingsConfig.ts +248 -0
  129. package/template/src/components/core/layouts/art-settings-panel/composables/useSettingsHandlers.ts +167 -0
  130. package/template/src/components/core/layouts/art-settings-panel/composables/useSettingsPanel.ts +233 -0
  131. package/template/src/components/core/layouts/art-settings-panel/composables/useSettingsState.ts +37 -0
  132. package/template/src/components/core/layouts/art-settings-panel/index.vue +72 -0
  133. package/template/src/components/core/layouts/art-settings-panel/style.scss +92 -0
  134. package/template/src/components/core/layouts/art-settings-panel/widget/BasicSettings.vue +77 -0
  135. package/template/src/components/core/layouts/art-settings-panel/widget/BoxStyleSettings.vue +38 -0
  136. package/template/src/components/core/layouts/art-settings-panel/widget/ColorSettings.vue +35 -0
  137. package/template/src/components/core/layouts/art-settings-panel/widget/ContainerSettings.vue +33 -0
  138. package/template/src/components/core/layouts/art-settings-panel/widget/MenuLayoutSettings.vue +31 -0
  139. package/template/src/components/core/layouts/art-settings-panel/widget/MenuStyleSettings.vue +44 -0
  140. package/template/src/components/core/layouts/art-settings-panel/widget/SectionTitle.vue +17 -0
  141. package/template/src/components/core/layouts/art-settings-panel/widget/SettingActions.vue +236 -0
  142. package/template/src/components/core/layouts/art-settings-panel/widget/SettingDrawer.vue +51 -0
  143. package/template/src/components/core/layouts/art-settings-panel/widget/SettingHeader.vue +18 -0
  144. package/template/src/components/core/layouts/art-settings-panel/widget/SettingItem.vue +101 -0
  145. package/template/src/components/core/layouts/art-settings-panel/widget/ThemeSettings.vue +28 -0
  146. package/template/src/components/core/layouts/art-work-tab/index.vue +584 -0
  147. package/template/src/components/core/media/art-cutter-img/index.vue +350 -0
  148. package/template/src/components/core/media/art-video-player/index.vue +111 -0
  149. package/template/src/components/core/others/art-menu-right/index.vue +415 -0
  150. package/template/src/components/core/others/art-watermark/index.vue +64 -0
  151. package/template/src/components/core/text-effect/art-count-to/index.vue +310 -0
  152. package/template/src/components/core/text-effect/art-festival-text-scroll/index.vue +32 -0
  153. package/template/src/components/core/text-effect/art-text-scroll/index.vue +285 -0
  154. package/template/src/components/core/theme/theme-svg/index.vue +100 -0
  155. package/template/src/components/core/views/exception/ArtException.vue +55 -0
  156. package/template/src/components/core/views/login/AuthTopBar.vue +149 -0
  157. package/template/src/components/core/views/login/LoginLeftView.vue +602 -0
  158. package/template/src/components/core/views/result/ArtResultPage.vue +43 -0
  159. package/template/src/components/core/widget/art-icon-button/index.vue +23 -0
  160. package/template/src/config/assets/images.ts +61 -0
  161. package/template/src/config/index.ts +170 -0
  162. package/template/src/config/modules/component.ts +98 -0
  163. package/template/src/config/modules/fastEnter.ts +16 -0
  164. package/template/src/config/modules/festival.ts +51 -0
  165. package/template/src/config/modules/headerBar.ts +64 -0
  166. package/template/src/config/setting.ts +109 -0
  167. package/template/src/directives/core/auth.ts +66 -0
  168. package/template/src/directives/core/highlight-loader.ts +37 -0
  169. package/template/src/directives/core/highlight.ts +253 -0
  170. package/template/src/directives/core/ripple.ts +116 -0
  171. package/template/src/directives/core/roles.ts +87 -0
  172. package/template/src/directives/index.ts +14 -0
  173. package/template/src/enums/appEnum.ts +81 -0
  174. package/template/src/enums/formEnum.ts +17 -0
  175. package/template/src/env.d.ts +32 -0
  176. package/template/src/hooks/core/useAppMode.ts +45 -0
  177. package/template/src/hooks/core/useAuth.ts +74 -0
  178. package/template/src/hooks/core/useCeremony.ts +184 -0
  179. package/template/src/hooks/core/useChart.ts +745 -0
  180. package/template/src/hooks/core/useCommon.ts +87 -0
  181. package/template/src/hooks/core/useFastEnter.ts +55 -0
  182. package/template/src/hooks/core/useHeaderBar.ts +201 -0
  183. package/template/src/hooks/core/useLayoutHeight.ts +148 -0
  184. package/template/src/hooks/core/useTableColumns.ts +313 -0
  185. package/template/src/hooks/core/useTheme.ts +174 -0
  186. package/template/src/hooks/index.ts +29 -0
  187. package/template/src/locales/index.ts +123 -0
  188. package/template/src/locales/langs/en.json +283 -0
  189. package/template/src/locales/langs/zh.json +283 -0
  190. package/template/src/main.ts +29 -0
  191. package/template/src/mock/auth.ts +46 -0
  192. package/template/src/plugins/echarts.ts +76 -0
  193. package/template/src/plugins/index.ts +6 -0
  194. package/template/src/router/core/ComponentLoader.ts +82 -0
  195. package/template/src/router/core/IframeRouteManager.ts +78 -0
  196. package/template/src/router/core/MenuProcessor.ts +280 -0
  197. package/template/src/router/core/RoutePermissionValidator.ts +161 -0
  198. package/template/src/router/core/RouteRegistry.ts +90 -0
  199. package/template/src/router/core/RouteTransformer.ts +132 -0
  200. package/template/src/router/core/RouteValidator.ts +187 -0
  201. package/template/src/router/core/index.ts +14 -0
  202. package/template/src/router/guards/afterEach.ts +34 -0
  203. package/template/src/router/guards/beforeEach.ts +442 -0
  204. package/template/src/router/index.ts +24 -0
  205. package/template/src/router/modules/dashboard.ts +23 -0
  206. package/template/src/router/modules/examples.ts +109 -0
  207. package/template/src/router/modules/exception.ts +46 -0
  208. package/template/src/router/modules/index.ts +12 -0
  209. package/template/src/router/modules/result.ts +32 -0
  210. package/template/src/router/routes/asyncRoutes.ts +9 -0
  211. package/template/src/router/routes/staticRoutes.ts +60 -0
  212. package/template/src/router/routesAlias.ts +8 -0
  213. package/template/src/services/auth.ts +15 -0
  214. package/template/src/store/index.ts +52 -0
  215. package/template/src/store/modules/menu.ts +109 -0
  216. package/template/src/store/modules/setting.ts +450 -0
  217. package/template/src/store/modules/user.ts +218 -0
  218. package/template/src/store/modules/worktab.ts +568 -0
  219. package/template/src/types/api/api.d.ts +86 -0
  220. package/template/src/types/common/index.ts +95 -0
  221. package/template/src/types/common/response.ts +32 -0
  222. package/template/src/types/component/chart.ts +324 -0
  223. package/template/src/types/component/index.ts +86 -0
  224. package/template/src/types/config/index.ts +253 -0
  225. package/template/src/types/directive/directive.d.ts +15 -0
  226. package/template/src/types/import/auto-imports.d.ts +319 -0
  227. package/template/src/types/import/components.d.ts +126 -0
  228. package/template/src/types/index.ts +22 -0
  229. package/template/src/types/router/index.ts +80 -0
  230. package/template/src/types/store/index.ts +157 -0
  231. package/template/src/utils/form/index.ts +9 -0
  232. package/template/src/utils/form/validator.ts +316 -0
  233. package/template/src/utils/http/contract.ts +39 -0
  234. package/template/src/utils/http/error.ts +182 -0
  235. package/template/src/utils/http/index.ts +226 -0
  236. package/template/src/utils/http/status.ts +18 -0
  237. package/template/src/utils/index.ts +31 -0
  238. package/template/src/utils/navigation/index.ts +10 -0
  239. package/template/src/utils/navigation/jump.ts +68 -0
  240. package/template/src/utils/navigation/route.ts +85 -0
  241. package/template/src/utils/navigation/worktab.ts +67 -0
  242. package/template/src/utils/router.ts +63 -0
  243. package/template/src/utils/socket/index.ts +423 -0
  244. package/template/src/utils/storage/index.ts +7 -0
  245. package/template/src/utils/storage/storage-config.ts +127 -0
  246. package/template/src/utils/storage/storage-key-manager.ts +97 -0
  247. package/template/src/utils/storage/storage.ts +250 -0
  248. package/template/src/utils/sys/console.ts +9 -0
  249. package/template/src/utils/sys/error-handle.ts +143 -0
  250. package/template/src/utils/sys/index.ts +2 -0
  251. package/template/src/utils/sys/mittBus.ts +61 -0
  252. package/template/src/utils/ui/animation.ts +80 -0
  253. package/template/src/utils/ui/colors.ts +273 -0
  254. package/template/src/utils/ui/emojo.ts +24 -0
  255. package/template/src/utils/ui/iconify-loader.ts +31 -0
  256. package/template/src/utils/ui/index.ts +11 -0
  257. package/template/src/utils/ui/loading.ts +158 -0
  258. package/template/src/utils/ui/tabs.ts +60 -0
  259. package/template/src/views/auth/forget-password/index.vue +62 -0
  260. package/template/src/views/auth/login/index.vue +166 -0
  261. package/template/src/views/auth/login/style.css +38 -0
  262. package/template/src/views/auth/register/index.vue +240 -0
  263. package/template/src/views/dashboard/console/index.vue +173 -0
  264. package/template/src/views/examples/analytics/index.vue +389 -0
  265. package/template/src/views/examples/complex-form/index.vue +395 -0
  266. package/template/src/views/examples/crud-workspace/index.vue +412 -0
  267. package/template/src/views/examples/navigation/detail/index.vue +151 -0
  268. package/template/src/views/examples/navigation/state/index.vue +226 -0
  269. package/template/src/views/examples/overview/index.vue +309 -0
  270. package/template/src/views/examples/permissions/index.vue +303 -0
  271. package/template/src/views/examples/search-table/index.vue +182 -0
  272. package/template/src/views/examples/search-table/search.config.ts +81 -0
  273. package/template/src/views/examples/search-table/service.ts +116 -0
  274. package/template/src/views/examples/search-table/table.config.ts +37 -0
  275. package/template/src/views/exception/403/index.vue +16 -0
  276. package/template/src/views/exception/404/index.vue +16 -0
  277. package/template/src/views/exception/500/index.vue +16 -0
  278. package/template/src/views/index/index.vue +29 -0
  279. package/template/src/views/index/style.scss +93 -0
  280. package/template/src/views/outside/Iframe.vue +42 -0
  281. package/template/src/views/result/fail/index.vue +28 -0
  282. package/template/src/views/result/success/index.vue +21 -0
  283. package/template/tests/e2e/auth.spec.ts +14 -0
  284. package/template/tests/e2e/search-table.spec.ts +154 -0
  285. package/template/tests/unit/adapters/auth.spec.ts +38 -0
  286. package/template/tests/unit/config/app-config.spec.ts +17 -0
  287. package/template/tests/unit/directives/highlight.spec.ts +20 -0
  288. package/template/tests/unit/http/contract.spec.ts +47 -0
  289. package/template/tests/unit/mock/search-table.spec.ts +62 -0
  290. package/template/tests/unit/router/examples.spec.ts +52 -0
  291. package/template/tsconfig.json +28 -0
  292. package/template/vite.config.ts +181 -0
  293. package/template/vitest.config.ts +27 -0
@@ -0,0 +1,152 @@
1
+ <!-- k线图表 -->
2
+ <template>
3
+ <div
4
+ ref="chartRef"
5
+ class="relative w-full"
6
+ :style="{ height: props.height }"
7
+ v-loading="props.loading"
8
+ ></div>
9
+ </template>
10
+
11
+ <script setup lang="ts">
12
+ import type { EChartsOption } from '@/plugins/echarts'
13
+ import { useChartOps, useChartComponent } from '@/hooks/core/useChart'
14
+ import type { KLineChartProps } from '@/types/component/chart'
15
+
16
+ defineOptions({ name: 'ArtKLineChart' })
17
+
18
+ const props = withDefaults(defineProps<KLineChartProps>(), {
19
+ // 基础配置
20
+ height: useChartOps().chartHeight,
21
+ loading: false,
22
+ isEmpty: false,
23
+ colors: () => useChartOps().colors,
24
+
25
+ // 数据配置
26
+ data: () => [],
27
+ showDataZoom: false,
28
+ dataZoomStart: 0,
29
+ dataZoomEnd: 100
30
+ })
31
+
32
+ // 获取实际使用的颜色
33
+ const getActualColors = () => {
34
+ const defaultUpColor = '#4C87F3'
35
+ const defaultDownColor = '#8BD8FC'
36
+
37
+ return {
38
+ upColor: props.colors?.[0] || defaultUpColor,
39
+ downColor: props.colors?.[1] || defaultDownColor
40
+ }
41
+ }
42
+
43
+ // 使用新的图表组件抽象
44
+ const {
45
+ chartRef,
46
+ getAxisLineStyle,
47
+ getAxisLabelStyle,
48
+ getAxisTickStyle,
49
+ getSplitLineStyle,
50
+ getAnimationConfig,
51
+ getTooltipStyle
52
+ } = useChartComponent({
53
+ props,
54
+ checkEmpty: () => {
55
+ return (
56
+ !props.data?.length ||
57
+ props.data.every(
58
+ (item) => item.open === 0 && item.close === 0 && item.high === 0 && item.low === 0
59
+ )
60
+ )
61
+ },
62
+ watchSources: [
63
+ () => props.data,
64
+ () => props.colors,
65
+ () => props.showDataZoom,
66
+ () => props.dataZoomStart,
67
+ () => props.dataZoomEnd
68
+ ],
69
+ generateOptions: (): EChartsOption => {
70
+ const { upColor, downColor } = getActualColors()
71
+
72
+ return {
73
+ grid: {
74
+ top: 20,
75
+ right: 20,
76
+ bottom: props.showDataZoom ? 80 : 20,
77
+ left: 20,
78
+ containLabel: true
79
+ },
80
+ tooltip: getTooltipStyle('axis', {
81
+ axisPointer: {
82
+ type: 'cross'
83
+ },
84
+ formatter: (params: Array<{ name: string; data: number[] }>) => {
85
+ const param = params[0]
86
+ const data = param.data
87
+ return `
88
+ <div style="padding: 5px;">
89
+ <div><strong>时间:</strong>${param.name}</div>
90
+ <div><strong>开盘:</strong>${data[0]}</div>
91
+ <div><strong>收盘:</strong>${data[1]}</div>
92
+ <div><strong>最低:</strong>${data[2]}</div>
93
+ <div><strong>最高:</strong>${data[3]}</div>
94
+ </div>
95
+ `
96
+ }
97
+ }),
98
+ xAxis: {
99
+ type: 'category',
100
+ data: props.data.map((item) => item.time),
101
+ axisTick: getAxisTickStyle(),
102
+ axisLine: getAxisLineStyle(true),
103
+ axisLabel: getAxisLabelStyle(true)
104
+ },
105
+ yAxis: {
106
+ type: 'value',
107
+ scale: true,
108
+ axisLabel: getAxisLabelStyle(true),
109
+ axisLine: getAxisLineStyle(true),
110
+ splitLine: getSplitLineStyle(true)
111
+ },
112
+ series: [
113
+ {
114
+ type: 'candlestick',
115
+ data: props.data.map((item) => [item.open, item.close, item.low, item.high]),
116
+ itemStyle: {
117
+ color: upColor,
118
+ color0: downColor,
119
+ borderColor: upColor,
120
+ borderColor0: downColor,
121
+ borderWidth: 1
122
+ },
123
+ emphasis: {
124
+ itemStyle: {
125
+ borderWidth: 2,
126
+ shadowBlur: 10,
127
+ shadowColor: 'rgba(0, 0, 0, 0.3)'
128
+ }
129
+ },
130
+ ...getAnimationConfig()
131
+ }
132
+ ],
133
+ dataZoom: props.showDataZoom
134
+ ? [
135
+ {
136
+ type: 'inside',
137
+ start: props.dataZoomStart,
138
+ end: props.dataZoomEnd
139
+ },
140
+ {
141
+ show: true,
142
+ type: 'slider',
143
+ top: '90%',
144
+ start: props.dataZoomStart,
145
+ end: props.dataZoomEnd
146
+ }
147
+ ]
148
+ : undefined
149
+ }
150
+ }
151
+ })
152
+ </script>
@@ -0,0 +1,371 @@
1
+ <!-- 折线图,支持多组数据,支持阶梯式动画效果 -->
2
+ <template>
3
+ <div
4
+ ref="chartRef"
5
+ class="relative w-[calc(100%+10px)]"
6
+ :style="{ height: props.height }"
7
+ v-loading="props.loading"
8
+ >
9
+ </div>
10
+ </template>
11
+
12
+ <script setup lang="ts">
13
+ import { graphic, type EChartsOption } from '@/plugins/echarts'
14
+ import { getCssVar, hexToRgba } from '@/utils/ui'
15
+ import { useChartOps, useChartComponent } from '@/hooks/core/useChart'
16
+ import type { LineChartProps, LineDataItem } from '@/types/component/chart'
17
+
18
+ defineOptions({ name: 'ArtLineChart' })
19
+
20
+ const props = withDefaults(defineProps<LineChartProps>(), {
21
+ // 基础配置
22
+ height: useChartOps().chartHeight,
23
+ loading: false,
24
+ isEmpty: false,
25
+ colors: () => useChartOps().colors,
26
+
27
+ // 数据配置
28
+ data: () => [0, 0, 0, 0, 0, 0, 0],
29
+ xAxisData: () => [],
30
+ lineWidth: 2.5,
31
+ showAreaColor: false,
32
+ smooth: true,
33
+ symbol: 'none',
34
+ symbolSize: 6,
35
+ animationDelay: 200,
36
+
37
+ // 轴线显示配置
38
+ showAxisLabel: true,
39
+ showAxisLine: true,
40
+ showSplitLine: true,
41
+
42
+ // 交互配置
43
+ showTooltip: true,
44
+ showLegend: false,
45
+ legendPosition: 'bottom'
46
+ })
47
+
48
+ // 动画状态管理
49
+ const isAnimating = ref(false)
50
+ const animationTimers = ref<number[]>([])
51
+ const animatedData = ref<number[] | LineDataItem[]>([])
52
+
53
+ // 清理所有定时器
54
+ const clearAnimationTimers = () => {
55
+ animationTimers.value.forEach((timer) => clearTimeout(timer))
56
+ animationTimers.value = []
57
+ }
58
+
59
+ // 判断是否为多数据(使用 VueUse 的 computedEager 优化)
60
+ const isMultipleData = computed(() => {
61
+ return (
62
+ Array.isArray(props.data) &&
63
+ props.data.length > 0 &&
64
+ typeof props.data[0] === 'object' &&
65
+ 'name' in props.data[0]
66
+ )
67
+ })
68
+
69
+ // 缓存计算的最大值,避免重复计算
70
+ const maxValue = computed(() => {
71
+ if (isMultipleData.value) {
72
+ const multiData = props.data as LineDataItem[]
73
+ return multiData.reduce((max, item) => {
74
+ if (item.data?.length) {
75
+ const itemMax = Math.max(...item.data)
76
+ return Math.max(max, itemMax)
77
+ }
78
+ return max
79
+ }, 0)
80
+ } else {
81
+ const singleData = props.data as number[]
82
+ return singleData?.length ? Math.max(...singleData) : 0
83
+ }
84
+ })
85
+
86
+ // 初始化动画数据(优化:减少条件判断)
87
+ const initAnimationData = (): number[] | LineDataItem[] => {
88
+ if (isMultipleData.value) {
89
+ const multiData = props.data as LineDataItem[]
90
+ return multiData.map((item) => ({
91
+ ...item,
92
+ data: Array(item.data.length).fill(0)
93
+ }))
94
+ }
95
+ const singleData = props.data as number[]
96
+ return Array(singleData.length).fill(0)
97
+ }
98
+
99
+ // 复制真实数据(优化:使用结构化克隆)
100
+ const copyRealData = (): number[] | LineDataItem[] => {
101
+ if (isMultipleData.value) {
102
+ return (props.data as LineDataItem[]).map((item) => ({ ...item, data: [...item.data] }))
103
+ }
104
+ return [...(props.data as number[])]
105
+ }
106
+
107
+ // 获取颜色配置(优化:缓存主题色)
108
+ const primaryColor = computed(() => getCssVar('--el-color-primary'))
109
+
110
+ const getColor = (customColor?: string, index?: number): string => {
111
+ if (customColor) return customColor
112
+ if (index !== undefined) return props.colors![index % props.colors!.length]
113
+ return primaryColor.value
114
+ }
115
+
116
+ // 生成区域样式
117
+ const generateAreaStyle = (item: LineDataItem, color: string) => {
118
+ // 如果有 areaStyle 配置,或者显式开启了区域颜色,则显示区域样式
119
+ if (!item.areaStyle && !item.showAreaColor && !props.showAreaColor) return undefined
120
+
121
+ const areaConfig = item.areaStyle || {}
122
+ if (areaConfig.custom) return areaConfig.custom
123
+
124
+ return {
125
+ color: new graphic.LinearGradient(0, 0, 0, 1, [
126
+ {
127
+ offset: 0,
128
+ color: hexToRgba(color, areaConfig.startOpacity || 0.2).rgba
129
+ },
130
+ {
131
+ offset: 1,
132
+ color: hexToRgba(color, areaConfig.endOpacity || 0.02).rgba
133
+ }
134
+ ])
135
+ }
136
+ }
137
+
138
+ // 生成单数据区域样式
139
+ const generateSingleAreaStyle = () => {
140
+ if (!props.showAreaColor) return undefined
141
+
142
+ const color = getColor(props.colors[0])
143
+ return {
144
+ color: new graphic.LinearGradient(0, 0, 0, 1, [
145
+ {
146
+ offset: 0,
147
+ color: hexToRgba(color, 0.2).rgba
148
+ },
149
+ {
150
+ offset: 1,
151
+ color: hexToRgba(color, 0.02).rgba
152
+ }
153
+ ])
154
+ }
155
+ }
156
+
157
+ // 创建系列配置
158
+ const createSeriesItem = (config: {
159
+ name?: string
160
+ data: number[]
161
+ color?: string
162
+ smooth?: boolean
163
+ symbol?: string
164
+ symbolSize?: number
165
+ lineWidth?: number
166
+ areaStyle?: any
167
+ }) => {
168
+ return {
169
+ name: config.name,
170
+ data: config.data,
171
+ type: 'line' as const,
172
+ color: config.color,
173
+ smooth: config.smooth ?? props.smooth,
174
+ symbol: config.symbol ?? props.symbol,
175
+ symbolSize: config.symbolSize ?? props.symbolSize,
176
+ lineStyle: {
177
+ width: config.lineWidth ?? props.lineWidth,
178
+ color: config.color
179
+ },
180
+ areaStyle: config.areaStyle,
181
+ emphasis: {
182
+ focus: 'series' as const,
183
+ lineStyle: {
184
+ width: (config.lineWidth ?? props.lineWidth) + 1
185
+ }
186
+ }
187
+ }
188
+ }
189
+
190
+ // 生成图表配置
191
+ const generateChartOptions = (isInitial = false): EChartsOption => {
192
+ const options: EChartsOption = {
193
+ animation: true,
194
+ animationDuration: isInitial ? 0 : 1300,
195
+ animationDurationUpdate: isInitial ? 0 : 1300,
196
+ grid: getGridWithLegend(props.showLegend && isMultipleData.value, props.legendPosition, {
197
+ top: 15,
198
+ right: 15,
199
+ left: 0
200
+ }),
201
+ tooltip: props.showTooltip ? getTooltipStyle() : undefined,
202
+ xAxis: {
203
+ type: 'category',
204
+ boundaryGap: false,
205
+ data: props.xAxisData,
206
+ axisTick: getAxisTickStyle(),
207
+ axisLine: getAxisLineStyle(props.showAxisLine),
208
+ axisLabel: getAxisLabelStyle(props.showAxisLabel)
209
+ },
210
+ yAxis: {
211
+ type: 'value',
212
+ min: 0,
213
+ max: maxValue.value,
214
+ axisLabel: getAxisLabelStyle(props.showAxisLabel),
215
+ axisLine: getAxisLineStyle(props.showAxisLine),
216
+ splitLine: getSplitLineStyle(props.showSplitLine)
217
+ }
218
+ }
219
+
220
+ // 添加图例配置
221
+ if (props.showLegend && isMultipleData.value) {
222
+ options.legend = getLegendStyle(props.legendPosition)
223
+ }
224
+
225
+ // 生成系列数据
226
+ if (isMultipleData.value) {
227
+ const multiData = animatedData.value as LineDataItem[]
228
+ options.series = multiData.map((item, index) => {
229
+ const itemColor = getColor(props.colors[index], index)
230
+ const areaStyle = generateAreaStyle(item, itemColor)
231
+
232
+ return createSeriesItem({
233
+ name: item.name,
234
+ data: item.data,
235
+ color: itemColor,
236
+ smooth: item.smooth,
237
+ symbol: item.symbol,
238
+ lineWidth: item.lineWidth,
239
+ areaStyle
240
+ })
241
+ })
242
+ } else {
243
+ // 单数据情况
244
+ const singleData = animatedData.value as number[]
245
+ const computedColor = getColor(props.colors[0])
246
+ const areaStyle = generateSingleAreaStyle()
247
+
248
+ options.series = [
249
+ createSeriesItem({
250
+ data: singleData,
251
+ color: computedColor,
252
+ areaStyle
253
+ })
254
+ ]
255
+ }
256
+
257
+ return options
258
+ }
259
+
260
+ // 更新图表
261
+ const updateChartOptions = (options: EChartsOption) => {
262
+ initChart(options)
263
+ }
264
+
265
+ // 初始化动画函数(优化:统一定时器管理,减少内存泄漏风险)
266
+ const initChartWithAnimation = () => {
267
+ clearAnimationTimers()
268
+ isAnimating.value = true
269
+
270
+ // 初始化为0值数据
271
+ animatedData.value = initAnimationData()
272
+ updateChartOptions(generateChartOptions(true))
273
+
274
+ if (isMultipleData.value) {
275
+ // 多数据阶梯式动画
276
+ const multiData = props.data as LineDataItem[]
277
+ const currentAnimatedData = animatedData.value as LineDataItem[]
278
+
279
+ multiData.forEach((item, index) => {
280
+ const timer = window.setTimeout(
281
+ () => {
282
+ currentAnimatedData[index] = { ...item, data: [...item.data] }
283
+ animatedData.value = [...currentAnimatedData]
284
+ updateChartOptions(generateChartOptions(false))
285
+ },
286
+ index * props.animationDelay + 100
287
+ )
288
+
289
+ animationTimers.value.push(timer)
290
+ })
291
+
292
+ // 标记动画完成
293
+ const totalDelay = (multiData.length - 1) * props.animationDelay + 1500
294
+ const finishTimer = window.setTimeout(() => {
295
+ isAnimating.value = false
296
+ }, totalDelay)
297
+ animationTimers.value.push(finishTimer)
298
+ } else {
299
+ // 单数据简单动画 - 使用 nextTick 确保初始状态已渲染
300
+ nextTick(() => {
301
+ animatedData.value = copyRealData()
302
+ updateChartOptions(generateChartOptions(false))
303
+ isAnimating.value = false
304
+ })
305
+ }
306
+ }
307
+
308
+ // 空数据检查函数
309
+ const checkIsEmpty = () => {
310
+ // 检查单数据情况
311
+ if (Array.isArray(props.data) && typeof props.data[0] === 'number') {
312
+ const singleData = props.data as number[]
313
+ return !singleData.length || singleData.every((val) => val === 0)
314
+ }
315
+
316
+ // 检查多数据情况
317
+ if (Array.isArray(props.data) && typeof props.data[0] === 'object') {
318
+ const multiData = props.data as LineDataItem[]
319
+ return (
320
+ !multiData.length ||
321
+ multiData.every((item) => !item.data?.length || item.data.every((val) => val === 0))
322
+ )
323
+ }
324
+
325
+ return true
326
+ }
327
+
328
+ // 使用新的图表组件抽象
329
+ const {
330
+ chartRef,
331
+ initChart,
332
+ getAxisLineStyle,
333
+ getAxisLabelStyle,
334
+ getAxisTickStyle,
335
+ getSplitLineStyle,
336
+ getTooltipStyle,
337
+ getLegendStyle,
338
+ getGridWithLegend,
339
+ isEmpty
340
+ } = useChartComponent({
341
+ props,
342
+ checkEmpty: checkIsEmpty,
343
+ watchSources: [() => props.data, () => props.xAxisData, () => props.colors],
344
+ onVisible: () => {
345
+ // 当图表变为可见时,检查是否为空数据
346
+ if (!isEmpty.value) {
347
+ initChartWithAnimation()
348
+ }
349
+ },
350
+ generateOptions: () => generateChartOptions(false)
351
+ })
352
+
353
+ // 图表渲染函数(优化:防止动画期间重复触发)
354
+ const renderChart = () => {
355
+ if (!isAnimating.value && !isEmpty.value) {
356
+ initChartWithAnimation()
357
+ }
358
+ }
359
+
360
+ // 使用 VueUse 的 watchDebounced 优化数据监听(避免频繁更新)
361
+ watch([() => props.data, () => props.xAxisData, () => props.colors], renderChart, { deep: true })
362
+
363
+ // 生命周期
364
+ onMounted(() => {
365
+ renderChart()
366
+ })
367
+
368
+ onBeforeUnmount(() => {
369
+ clearAnimationTimers()
370
+ })
371
+ </script>
@@ -0,0 +1,105 @@
1
+ <!-- 雷达图 -->
2
+ <template>
3
+ <div
4
+ ref="chartRef"
5
+ class="relative w-full"
6
+ :style="{ height: props.height }"
7
+ v-loading="props.loading"
8
+ ></div>
9
+ </template>
10
+
11
+ <script setup lang="ts">
12
+ import type { EChartsOption } from '@/plugins/echarts'
13
+ import { useChartOps, useChartComponent } from '@/hooks/core/useChart'
14
+ import type { RadarChartProps } from '@/types/component/chart'
15
+
16
+ defineOptions({ name: 'ArtRadarChart' })
17
+
18
+ const props = withDefaults(defineProps<RadarChartProps>(), {
19
+ // 基础配置
20
+ height: useChartOps().chartHeight,
21
+ loading: false,
22
+ isEmpty: false,
23
+ colors: () => useChartOps().colors,
24
+
25
+ // 数据配置
26
+ indicator: () => [],
27
+ data: () => [],
28
+
29
+ // 交互配置
30
+ showTooltip: true,
31
+ showLegend: false,
32
+ legendPosition: 'bottom'
33
+ })
34
+
35
+ // 使用新的图表组件抽象
36
+ const { chartRef, isDark, getAnimationConfig, getTooltipStyle } = useChartComponent({
37
+ props,
38
+ checkEmpty: () => {
39
+ return !props.data?.length || props.data.every((item) => item.value.every((val) => val === 0))
40
+ },
41
+ watchSources: [() => props.data, () => props.indicator, () => props.colors],
42
+ generateOptions: (): EChartsOption => {
43
+ return {
44
+ tooltip: props.showTooltip ? getTooltipStyle('item') : undefined,
45
+ radar: {
46
+ indicator: props.indicator,
47
+ center: ['50%', '50%'],
48
+ radius: '70%',
49
+ axisName: {
50
+ color: isDark.value ? '#ccc' : '#666',
51
+ fontSize: 12
52
+ },
53
+ splitLine: {
54
+ lineStyle: {
55
+ color: isDark.value ? '#444' : '#e6e6e6'
56
+ }
57
+ },
58
+ axisLine: {
59
+ lineStyle: {
60
+ color: isDark.value ? '#444' : '#e6e6e6'
61
+ }
62
+ },
63
+ splitArea: {
64
+ show: true,
65
+ areaStyle: {
66
+ color: isDark.value
67
+ ? ['rgba(255, 255, 255, 0.02)', 'rgba(255, 255, 255, 0.05)']
68
+ : ['rgba(0, 0, 0, 0.02)', 'rgba(0, 0, 0, 0.05)']
69
+ }
70
+ }
71
+ },
72
+ series: [
73
+ {
74
+ type: 'radar',
75
+ data: props.data.map((item, index) => ({
76
+ name: item.name,
77
+ value: item.value,
78
+ symbolSize: 4,
79
+ lineStyle: {
80
+ width: 2,
81
+ color: props.colors[index % props.colors.length]
82
+ },
83
+ itemStyle: {
84
+ color: props.colors[index % props.colors.length]
85
+ },
86
+ areaStyle: {
87
+ color: props.colors[index % props.colors.length],
88
+ opacity: 0.1
89
+ },
90
+ emphasis: {
91
+ areaStyle: {
92
+ opacity: 0.25
93
+ },
94
+ lineStyle: {
95
+ width: 3
96
+ }
97
+ }
98
+ })),
99
+ ...getAnimationConfig(200, 1800)
100
+ }
101
+ ]
102
+ }
103
+ }
104
+ })
105
+ </script>