create-bubbles 0.1.24 → 0.1.26

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 (204) hide show
  1. package/dist/index.js +15 -0
  2. package/package.json +1 -2
  3. package/template-nextjs-vinext-eslint/Dockerfile +4 -4
  4. package/template-nextjs-vinext-eslint/README.md +6 -2
  5. package/template-nextjs-vinext-eslint/docker-compose.yaml +4 -4
  6. package/template-nextjs-vinext-eslint/eslint.config.js +2 -0
  7. package/template-nextjs-vinext-eslint/package.json +28 -26
  8. package/template-nextjs-vinext-eslint/pnpm-workspace.yaml +13 -1
  9. package/template-nextjs-vinext-eslint/src/utils/request/core/index.ts +63 -45
  10. package/template-nextjs-vinext-eslint/src/utils/request/core/utils.ts +12 -6
  11. package/template-nextjs-vinext-eslint/vite.config.ts +1 -1
  12. package/template-react-rsbuild-biome/.agents/rules/SVG/344/275/277/347/224/250.md +8 -0
  13. package/template-react-rsbuild-biome/AGENTS.md +11 -0
  14. package/template-react-rsbuild-biome/index.html +2 -2
  15. package/template-react-rsbuild-biome/package.json +25 -24
  16. package/template-react-rsbuild-biome/pnpm-workspace.yaml +5 -0
  17. package/template-react-rsbuild-biome/rsbuild.config.ts +1 -1
  18. package/template-react-rsbuild-biome/src/assets/icon/logo.svg +1 -1
  19. package/template-react-rsbuild-biome/src/assets/svg/draft.svg +4 -0
  20. package/template-react-rsbuild-biome/src/components/Icon/svg-icon/README.md +37 -0
  21. package/template-react-rsbuild-biome/src/components/Icon/svg-icon/SvgIcon.tsx +27 -0
  22. package/template-react-rsbuild-biome/src/env.d.ts +7 -0
  23. package/template-react-rsbuild-biome/src/utils/request/index.ts +3 -4
  24. package/template-react-rsbuild-biome/tsconfig.json +1 -2
  25. package/template-taro-react-oxc/.oxlintrc.json +0 -1
  26. package/template-taro-react-oxc/package.json +53 -52
  27. package/template-taro-react-oxc/pnpm-workspace.yaml +46 -0
  28. package/template-taro-vue-eslint/package.json +56 -56
  29. package/template-vp-monorepo-react-hono/apps/web/.agents/rules/SVG/344/275/277/347/224/250.md +8 -0
  30. package/template-vp-monorepo-react-hono/apps/web/AGENTS.md +11 -0
  31. package/template-vp-monorepo-react-hono/apps/web/package.json +1 -0
  32. package/template-vp-monorepo-react-hono/apps/web/src/assets/svg/draft.svg +4 -0
  33. package/template-vp-monorepo-react-hono/apps/web/src/components/Icon/svg-icon/README.md +37 -0
  34. package/template-vp-monorepo-react-hono/apps/web/src/components/Icon/svg-icon/SvgIcon.tsx +27 -0
  35. package/template-vp-monorepo-react-hono/apps/web/tsconfig.json +1 -1
  36. package/template-vp-monorepo-react-hono/apps/web/vite.config.ts +2 -0
  37. package/template-vp-monorepo-react-hono/pnpm-workspace.yaml +1 -0
  38. package/template-vp-monorepo-react-nestjs/.agents/rules//344/273/243/347/240/201/350/256/276/350/256/241.md +4 -0
  39. package/template-vp-monorepo-react-nestjs/.agents/rules//345/205/261/344/272/253/344/273/243/347/240/201.md +4 -0
  40. package/template-vp-monorepo-react-nestjs/.spaces/01./344/274/201/344/270/232/347/272/247/351/241/271/347/233/256/347/272/247//351/234/200/346/261/202/346/226/207/346/241/243.md +177 -0
  41. package/template-vp-monorepo-react-nestjs/.spaces/server/04.upload.md +4504 -0
  42. package/template-vp-monorepo-react-nestjs/.spaces/server/05./344/270/212/344/274/240/346/224/271/351/200/240/346/226/271/346/241/210/README.md +858 -0
  43. package/template-vp-monorepo-react-nestjs/.spaces/server/06./345/205/254/345/205/261/351/230/237/345/210/227/346/216/245/345/205/245/346/226/271/346/241/210/README.md +1890 -0
  44. package/template-vp-monorepo-react-nestjs/.spaces/server/06./345/205/254/345/205/261/351/230/237/345/210/227/346/216/245/345/205/245/346/226/271/346/241/210//344/270/212/344/274/240/346/270/205/347/220/206.md +1465 -0
  45. package/template-vp-monorepo-react-nestjs/AGENTS.md +8 -12
  46. package/template-vp-monorepo-react-nestjs/apps/server/.agents/rules/error-handling.md +84 -0
  47. package/template-vp-monorepo-react-nestjs/apps/server/.env.development +60 -0
  48. package/template-vp-monorepo-react-nestjs/apps/server/.env.production +16 -0
  49. package/template-vp-monorepo-react-nestjs/apps/server/AGENTS.md +9 -0
  50. package/template-vp-monorepo-react-nestjs/apps/server/drizzle/0000_military_colonel_america.sql +11 -0
  51. package/template-vp-monorepo-react-nestjs/apps/server/drizzle/0001_loud_siren.sql +27 -0
  52. package/template-vp-monorepo-react-nestjs/apps/server/drizzle/meta/0000_snapshot.json +97 -0
  53. package/template-vp-monorepo-react-nestjs/apps/server/drizzle/meta/0001_snapshot.json +354 -0
  54. package/template-vp-monorepo-react-nestjs/apps/server/drizzle/meta/_journal.json +20 -0
  55. package/template-vp-monorepo-react-nestjs/apps/server/package.json +4 -0
  56. package/template-vp-monorepo-react-nestjs/apps/server/src/app.module.ts +14 -2
  57. package/template-vp-monorepo-react-nestjs/apps/server/src/common/adapters/fastify.adapter.ts +6 -0
  58. package/template-vp-monorepo-react-nestjs/apps/server/src/config/index.ts +2 -0
  59. package/template-vp-monorepo-react-nestjs/apps/server/src/config/queue.config.ts +105 -0
  60. package/template-vp-monorepo-react-nestjs/apps/server/src/config/storage.config.ts +33 -0
  61. package/template-vp-monorepo-react-nestjs/apps/server/src/database/schema.ts +57 -1
  62. package/template-vp-monorepo-react-nestjs/apps/server/src/main.ts +1 -0
  63. package/template-vp-monorepo-react-nestjs/apps/server/src/modules/auth/auth.service.ts +1 -3
  64. package/template-vp-monorepo-react-nestjs/apps/server/src/modules/auth/dto/auth-repsponse.dto.ts +2 -2
  65. package/template-vp-monorepo-react-nestjs/apps/server/src/modules/task-queue/queue-worker.bootstrap.ts +24 -0
  66. package/template-vp-monorepo-react-nestjs/apps/server/src/modules/task-queue/task-queue.constants.ts +24 -0
  67. package/template-vp-monorepo-react-nestjs/apps/server/src/modules/task-queue/task-queue.contracts.ts +35 -0
  68. package/template-vp-monorepo-react-nestjs/apps/server/src/modules/task-queue/task-queue.module.ts +56 -0
  69. package/template-vp-monorepo-react-nestjs/apps/server/src/modules/task-queue/task-queue.processor.ts +62 -0
  70. package/template-vp-monorepo-react-nestjs/apps/server/src/modules/task-queue/task-queue.service.ts +58 -0
  71. package/template-vp-monorepo-react-nestjs/apps/server/src/modules/test/error-catelog.spec.ts +34 -0
  72. package/template-vp-monorepo-react-nestjs/apps/server/src/modules/upload/dto/initiate-mutipart-upload.dto.ts +26 -0
  73. package/template-vp-monorepo-react-nestjs/apps/server/src/modules/upload/dto/upload-params.dto.ts +15 -0
  74. package/template-vp-monorepo-react-nestjs/apps/server/src/modules/upload/storage/exact-size.transform.ts +66 -0
  75. package/template-vp-monorepo-react-nestjs/apps/server/src/modules/upload/storage/minio-storage.adapter.ts +239 -0
  76. package/template-vp-monorepo-react-nestjs/apps/server/src/modules/upload/storage/storage.port.ts +61 -0
  77. package/template-vp-monorepo-react-nestjs/apps/server/src/modules/upload/upload.constants.ts +23 -0
  78. package/template-vp-monorepo-react-nestjs/apps/server/src/modules/upload/upload.controller.ts +109 -0
  79. package/template-vp-monorepo-react-nestjs/apps/server/src/modules/upload/upload.errors.ts +80 -0
  80. package/template-vp-monorepo-react-nestjs/apps/server/src/modules/upload/upload.module.ts +20 -0
  81. package/template-vp-monorepo-react-nestjs/apps/server/src/modules/upload/upload.reponsitory.ts +166 -0
  82. package/template-vp-monorepo-react-nestjs/apps/server/src/modules/upload/upload.service.ts +696 -0
  83. package/template-vp-monorepo-react-nestjs/apps/server/src/modules/upload/utils/object-key.ts +10 -0
  84. package/template-vp-monorepo-react-nestjs/apps/server/test/task-queue.integration.spec.ts +120 -0
  85. package/template-vp-monorepo-react-nestjs/apps/server/test/task-queue.processor.spec.ts +63 -0
  86. package/template-vp-monorepo-react-nestjs/apps/server/test/task-queue.service.spec.ts +106 -0
  87. package/template-vp-monorepo-react-nestjs/apps/web/.agents/rules/SVG/344/275/277/347/224/250.md +8 -0
  88. package/template-vp-monorepo-react-nestjs/apps/web/.agents/rules//345/274/271/347/252/227/347/273/204/344/273/266.md +4 -0
  89. package/template-vp-monorepo-react-nestjs/apps/web/.agents/rules//346/226/207/344/273/266/346/213/206/345/210/206.md +4 -0
  90. package/template-vp-monorepo-react-nestjs/apps/web/.agents/rules//347/273/204/344/273/266/345/221/275/345/220/215.md +3 -0
  91. package/template-vp-monorepo-react-nestjs/apps/web/.agents/rules//350/241/250/346/240/274/351/241/265/351/235/242.md +11 -0
  92. package/template-vp-monorepo-react-nestjs/apps/web/.agents/rules//351/241/265/351/235/242/346/216/245/345/217/243.md +3 -0
  93. package/template-vp-monorepo-react-nestjs/apps/web/.env.dev +1 -1
  94. package/template-vp-monorepo-react-nestjs/apps/web/AGENTS.md +16 -0
  95. package/template-vp-monorepo-react-nestjs/apps/web/README.MD +153 -0
  96. package/template-vp-monorepo-react-nestjs/apps/web/index.html +3 -2
  97. package/template-vp-monorepo-react-nestjs/apps/web/package.json +6 -1
  98. package/template-vp-monorepo-react-nestjs/apps/web/public/favicon.svg +9 -1
  99. package/template-vp-monorepo-react-nestjs/apps/web/src/App.module.css +5 -0
  100. package/template-vp-monorepo-react-nestjs/apps/web/src/App.tsx +16 -9
  101. package/template-vp-monorepo-react-nestjs/apps/web/src/api/auth.ts +9 -0
  102. package/template-vp-monorepo-react-nestjs/apps/web/src/assets/svg/draft.svg +4 -0
  103. package/template-vp-monorepo-react-nestjs/apps/web/src/components/DraftProTable/DraftProTable.module.css +78 -0
  104. package/template-vp-monorepo-react-nestjs/apps/web/src/components/DraftProTable/DraftProTable.tsx +99 -0
  105. package/template-vp-monorepo-react-nestjs/apps/web/src/components/DraftProTable/README.md +34 -0
  106. package/template-vp-monorepo-react-nestjs/apps/web/src/components/FullHeightProTable/FullHeightProTable.module.css +54 -0
  107. package/template-vp-monorepo-react-nestjs/apps/web/src/components/FullHeightProTable/FullHeightProTable.tsx +41 -0
  108. package/template-vp-monorepo-react-nestjs/apps/web/src/components/Icon/svg-icon/README.md +37 -0
  109. package/template-vp-monorepo-react-nestjs/apps/web/src/components/Icon/svg-icon/SvgIcon.tsx +27 -0
  110. package/template-vp-monorepo-react-nestjs/apps/web/src/components/Loading/PageLoading.module.css +7 -0
  111. package/template-vp-monorepo-react-nestjs/apps/web/src/components/Loading/PageLoading.tsx +2 -1
  112. package/template-vp-monorepo-react-nestjs/apps/web/src/config/theme.ts +20 -0
  113. package/template-vp-monorepo-react-nestjs/apps/web/src/layouts/BasicLayout.module.css +17 -0
  114. package/template-vp-monorepo-react-nestjs/apps/web/src/layouts/BasicLayout.tsx +106 -0
  115. package/template-vp-monorepo-react-nestjs/apps/web/src/pages/examples/i18n/index.module.css +23 -0
  116. package/template-vp-monorepo-react-nestjs/apps/web/src/pages/examples/i18n/index.tsx +53 -0
  117. package/template-vp-monorepo-react-nestjs/apps/web/src/pages/examples/pro-table/components/ProjectFormDialog.tsx +132 -0
  118. package/template-vp-monorepo-react-nestjs/apps/web/src/pages/examples/pro-table/config/columns.tsx +121 -0
  119. package/template-vp-monorepo-react-nestjs/apps/web/src/pages/examples/pro-table/config/index.ts +77 -0
  120. package/template-vp-monorepo-react-nestjs/apps/web/src/pages/examples/pro-table/draft/components/DraftProjectFormDialog.tsx +140 -0
  121. package/template-vp-monorepo-react-nestjs/apps/web/src/pages/examples/pro-table/draft/config/columns.tsx +127 -0
  122. package/template-vp-monorepo-react-nestjs/apps/web/src/pages/examples/pro-table/draft/config/index.ts +39 -0
  123. package/template-vp-monorepo-react-nestjs/apps/web/src/pages/examples/pro-table/draft/config/projects.ts +48 -0
  124. package/template-vp-monorepo-react-nestjs/apps/web/src/pages/examples/pro-table/draft/index.module.css +49 -0
  125. package/template-vp-monorepo-react-nestjs/apps/web/src/pages/examples/pro-table/draft/index.tsx +163 -0
  126. package/template-vp-monorepo-react-nestjs/apps/web/src/pages/examples/pro-table/index.module.css +53 -0
  127. package/template-vp-monorepo-react-nestjs/apps/web/src/pages/examples/pro-table/index.tsx +135 -0
  128. package/template-vp-monorepo-react-nestjs/apps/web/src/pages/home/index.module.css +23 -0
  129. package/template-vp-monorepo-react-nestjs/apps/web/src/pages/home/index.tsx +26 -43
  130. package/template-vp-monorepo-react-nestjs/apps/web/src/pages/login/api.ts +11 -0
  131. package/template-vp-monorepo-react-nestjs/apps/web/src/pages/login/index.tsx +183 -0
  132. package/template-vp-monorepo-react-nestjs/apps/web/src/pages/login/login.css +164 -0
  133. package/template-vp-monorepo-react-nestjs/apps/web/src/router/index.tsx +36 -12
  134. package/template-vp-monorepo-react-nestjs/apps/web/src/styles/index.css +11 -4
  135. package/template-vp-monorepo-react-nestjs/apps/web/src/utils/request/core/index.ts +55 -47
  136. package/template-vp-monorepo-react-nestjs/apps/web/src/utils/request/index.ts +10 -5
  137. package/template-vp-monorepo-react-nestjs/apps/web/src/utils/storage/cookie.ts +50 -0
  138. package/template-vp-monorepo-react-nestjs/apps/web/src/utils/storage/session.ts +33 -0
  139. package/template-vp-monorepo-react-nestjs/apps/web/test/draft-projects.spec.ts +89 -0
  140. package/template-vp-monorepo-react-nestjs/apps/web/test/request.spec.ts +145 -0
  141. package/template-vp-monorepo-react-nestjs/apps/web/test/storage.spec.ts +108 -0
  142. package/template-vp-monorepo-react-nestjs/apps/web/test/tsconfig.json +7 -0
  143. package/template-vp-monorepo-react-nestjs/apps/web/tsconfig.json +1 -1
  144. package/template-vp-monorepo-react-nestjs/apps/web/vite.config.ts +7 -0
  145. package/template-vp-monorepo-react-nestjs/apps/web-vue/tsconfig.tsbuildinfo +1 -0
  146. package/template-vp-monorepo-react-nestjs/docker-compose.yml +19 -0
  147. package/template-vp-monorepo-react-nestjs/mise.toml +1 -1
  148. package/template-vp-monorepo-react-nestjs/package.json +1 -6
  149. package/template-vp-monorepo-react-nestjs/pnpm-workspace.yaml +9 -1
  150. package/template-vp-react/.agents/rules/SVG/344/275/277/347/224/250.md +8 -0
  151. package/template-vp-react/AGENTS.md +11 -0
  152. package/template-vp-react/commitlint.config.js +0 -0
  153. package/template-vp-react/package.json +21 -26
  154. package/template-vp-react/pnpm-workspace.yaml +6 -0
  155. package/template-vp-react/src/assets/svg/draft.svg +4 -0
  156. package/template-vp-react/src/components/Icon/svg-icon/README.md +37 -0
  157. package/template-vp-react/src/components/Icon/svg-icon/SvgIcon.tsx +27 -0
  158. package/template-vp-react/src/utils/request/index.ts +18 -5
  159. package/template-vp-react/tsconfig.json +2 -3
  160. package/template-vp-react/vite.config.ts +2 -0
  161. package/template-vp-react-shadcn/.agents/rules/SVG/344/275/277/347/224/250.md +8 -0
  162. package/template-vp-react-shadcn/.vscode/settings.json +2 -2
  163. package/template-vp-react-shadcn/{agents.md → AGENTS.md} +12 -2
  164. package/template-vp-react-shadcn/README.md +41 -0
  165. package/template-vp-react-shadcn/commitlint.config.js +1 -1
  166. package/template-vp-react-shadcn/components.json +1 -1
  167. package/template-vp-react-shadcn/package.json +25 -32
  168. package/template-vp-react-shadcn/pnpm-workspace.yaml +10 -0
  169. package/template-vp-react-shadcn/src/App.tsx +10 -10
  170. package/template-vp-react-shadcn/src/assets/svg/draft.svg +4 -0
  171. package/template-vp-react-shadcn/src/components/Icon/svg-icon/README.md +37 -0
  172. package/template-vp-react-shadcn/src/components/Icon/svg-icon/SvgIcon.tsx +27 -0
  173. package/template-vp-react-shadcn/src/components/Loading/PageLoading.tsx +4 -4
  174. package/template-vp-react-shadcn/src/components/Player/VideoJS/index.tsx +94 -78
  175. package/template-vp-react-shadcn/src/components/Player/index.ts +1 -1
  176. package/template-vp-react-shadcn/src/components/ui/button.tsx +25 -32
  177. package/template-vp-react-shadcn/src/components/ui/spinner.tsx +8 -7
  178. package/template-vp-react-shadcn/src/components/ui/toast.tsx +229 -0
  179. package/template-vp-react-shadcn/src/lib/utils.ts +3 -3
  180. package/template-vp-react-shadcn/src/main.tsx +5 -4
  181. package/template-vp-react-shadcn/src/pages/home/index.tsx +43 -35
  182. package/template-vp-react-shadcn/src/router/index.tsx +15 -15
  183. package/template-vp-react-shadcn/src/styles/index.css +4 -4
  184. package/template-vp-react-shadcn/src/styles/shadcn.css +2 -2
  185. package/template-vp-react-shadcn/src/utils/env/index.tsx +2 -2
  186. package/template-vp-react-shadcn/src/utils/request/alova-core/index.ts +102 -30
  187. package/template-vp-react-shadcn/src/utils/request/alova-core/utils.ts +5 -2
  188. package/template-vp-react-shadcn/src/utils/request/index.ts +32 -19
  189. package/template-vp-react-shadcn/src/utils/request/readme.md +41 -38
  190. package/template-vp-react-shadcn/tsconfig.json +2 -3
  191. package/template-vp-react-shadcn/vite.config.ts +29 -15
  192. package/template-vp-vue-eslint-vapor/package.json +26 -33
  193. package/template-vp-vue-eslint-vapor/pnpm-workspace.yaml +29 -1
  194. package/template-vue-vp-eslint/README.md +3 -10
  195. package/template-vue-vp-eslint/package.json +27 -34
  196. package/template-vue-vp-eslint/pnpm-workspace.yaml +27 -2
  197. package/template-vue-vp-eslint/src/layout/default/index.vue +4 -3
  198. package/dist/index.mjs +0 -422
  199. package/template-vp-monorepo-react-nestjs/.agents/auth.config.ts +0 -0
  200. package/template-vp-monorepo-react-nestjs/.spaces/server/todo.md +0 -991
  201. package/template-vp-monorepo-react-nestjs/apps/server/README.md +0 -3
  202. package/template-vp-react-shadcn/.oxfmtrc.jsonc +0 -8
  203. package/template-vp-react-shadcn/.oxlintrc.jsonc +0 -3
  204. package/template-vp-react-shadcn/src/components/ui/sonner.tsx +0 -43
@@ -2,8 +2,8 @@ import { axiosRequestAdapter, type AlovaAxiosRequestConfig } from '@alova/adapte
2
2
  import reactHook, { type ReactHookExportType } from 'alova/react'
3
3
  import { message } from 'antd'
4
4
  import type { AxiosResponse, AxiosResponseHeaders } from 'axios'
5
- import { navigator } from '@/router'
6
5
  import { envVariables } from '@/utils/env'
6
+ import { cookie } from '@/utils/storage/cookie'
7
7
  import { createDualCallInstance, type BaseRequestOption } from './core/index.ts'
8
8
 
9
9
  type WebRequestOption = BaseRequestOption<
@@ -25,8 +25,8 @@ function normalizeBaseUrl(apiAffix?: string) {
25
25
  function getBaseConfig(): WebRequestOption {
26
26
  return {
27
27
  baseUrl: normalizeBaseUrl(envVariables.API_AFFIX),
28
+ isWrapped: false,
28
29
  statusMap: {
29
- success: [200, 201, 204],
30
30
  unAuthorized: 401,
31
31
  },
32
32
  codeMap: {
@@ -34,8 +34,12 @@ function getBaseConfig(): WebRequestOption {
34
34
  unAuthorized: [401],
35
35
  },
36
36
  responseDataKey: 'data',
37
- responseMessageKey: 'msg',
38
- commonHeaders: () => ({}),
37
+ responseMessageKey: 'message',
38
+ errorDefaultMessage: '请求失败,请稍后重试',
39
+ commonHeaders: () => {
40
+ const token = cookie.get('token')
41
+ return token ? { Authorization: `Bearer ${token}` } : {}
42
+ },
39
43
  successMessageFunc: (msg) => {
40
44
  message.success(msg)
41
45
  },
@@ -43,8 +47,9 @@ function getBaseConfig(): WebRequestOption {
43
47
  message.error(msg)
44
48
  },
45
49
  unAuthorizedResponseFunc: () => {
46
- void navigator('/login')
50
+ cookie.remove('token')
47
51
  message.error('登录过期或未登录')
52
+ window.location.assign('/login')
48
53
  },
49
54
  statesHook: reactHook,
50
55
  requestAdapter: axiosRequestAdapter(),
@@ -0,0 +1,50 @@
1
+ export interface CookieOptions {
2
+ path?: string
3
+ domain?: string
4
+ expires?: Date
5
+ /** 有效期,单位为秒;优先于 expires。 */
6
+ maxAge?: number
7
+ secure?: boolean
8
+ sameSite?: 'Strict' | 'Lax' | 'None'
9
+ }
10
+
11
+ export const cookie = {
12
+ get(key: string): string | null {
13
+ const prefix = `${encodeURIComponent(key)}=`
14
+ const entry = document.cookie.split(';').find((item) => item.trim().startsWith(prefix))
15
+ if (entry === undefined) return null
16
+
17
+ const value = entry.trim().slice(prefix.length)
18
+ try {
19
+ return decodeURIComponent(value)
20
+ } catch {
21
+ return value
22
+ }
23
+ },
24
+
25
+ /** 同名 Cookie 在相同 path、domain 下写入即为更新。 */
26
+ set(key: string, value: string, options: CookieOptions = {}): void {
27
+ const { path = '/', domain, expires, maxAge, sameSite = 'Lax' } = options
28
+ const secure = options.secure ?? window.location.protocol === 'https:'
29
+ const attributes = [
30
+ `${encodeURIComponent(key)}=${encodeURIComponent(value)}`,
31
+ `Path=${path}`,
32
+ `SameSite=${sameSite}`,
33
+ ]
34
+
35
+ if (domain) attributes.push(`Domain=${domain}`)
36
+ if (expires) attributes.push(`Expires=${expires.toUTCString()}`)
37
+ if (maxAge !== undefined) attributes.push(`Max-Age=${Math.trunc(maxAge)}`)
38
+ if (secure) attributes.push('Secure')
39
+
40
+ document.cookie = attributes.join('; ')
41
+ },
42
+
43
+ /** 删除时的 path、domain 必须与写入时一致。 */
44
+ remove(
45
+ key: string,
46
+ options: Pick<CookieOptions, 'path' | 'domain' | 'secure' | 'sameSite'> = {},
47
+ ): void {
48
+ cookie.set(key, '', { ...options, maxAge: 0, expires: new Date(0) })
49
+ },
50
+ }
@@ -0,0 +1,33 @@
1
+ function createStorage(type: 'localStorage' | 'sessionStorage') {
2
+ return {
3
+ /** 自动序列化为 JSON;同名写入即为更新。 */
4
+ set<T>(key: string, value: T): void {
5
+ const serialized = JSON.stringify(value)
6
+ if (serialized === undefined) throw new TypeError('存储值必须能够序列化为 JSON')
7
+ window[type].setItem(key, serialized)
8
+ },
9
+
10
+ /** 不存在或内容不是有效 JSON 时返回 null。 */
11
+ get<T = unknown>(key: string): T | null {
12
+ const value = window[type].getItem(key)
13
+ if (value === null) return null
14
+
15
+ try {
16
+ return JSON.parse(value) as T
17
+ } catch {
18
+ return null
19
+ }
20
+ },
21
+
22
+ remove(key: string): void {
23
+ window[type].removeItem(key)
24
+ },
25
+
26
+ clear(): void {
27
+ window[type].clear()
28
+ },
29
+ }
30
+ }
31
+
32
+ export const local = createStorage('localStorage')
33
+ export const session = createStorage('sessionStorage')
@@ -0,0 +1,89 @@
1
+ import { describe, expect, it } from 'vite-plus/test'
2
+ import {
3
+ currentUser,
4
+ initialRecords,
5
+ type DraftProjectRecord,
6
+ } from '../src/pages/examples/pro-table/draft/config'
7
+ import {
8
+ filterProjectRecords,
9
+ saveProjectRecord,
10
+ } from '../src/pages/examples/pro-table/draft/config/projects'
11
+
12
+ describe('项目草稿演示', () => {
13
+ it('允许保存未填完的草稿,并与正式项目分开显示', () => {
14
+ const records = saveProjectRecord(initialRecords, {
15
+ values: { name: ' 测试草稿 ' },
16
+ stage: 'draft',
17
+ })
18
+ const drafts = filterProjectRecords({ records, view: 'draft', search: {} })
19
+ expect(drafts).toHaveLength(4)
20
+ expect(drafts.find((record) => record.name === '测试草稿')).toMatchObject({
21
+ stage: 'draft',
22
+ createdBy: currentUser,
23
+ })
24
+ expect(drafts.find((record) => record.name === '测试草稿')?.owner).toBeUndefined()
25
+ expect(filterProjectRecords({ records, view: 'list', search: {} })).toHaveLength(18)
26
+ })
27
+
28
+ it('继续保存同一草稿不会产生重复记录,提交后保留编号并移入正式列表', () => {
29
+ const original = initialRecords.find((record) => record.id === 'PRJ-019')!
30
+ const saved = saveProjectRecord(initialRecords, {
31
+ original,
32
+ values: { name: '继续完善' },
33
+ stage: 'draft',
34
+ })
35
+ const updated = saved.find((record) => record.id === original.id)!
36
+ expect(saved).toHaveLength(initialRecords.length)
37
+ const submitted = saveProjectRecord(saved, {
38
+ original: updated,
39
+ values: {
40
+ name: '已完成项目',
41
+ owner: currentUser,
42
+ status: 'completed',
43
+ priority: 'medium',
44
+ progress: 75,
45
+ dueDate: '2026-10-01',
46
+ description: '',
47
+ },
48
+ stage: 'published',
49
+ })
50
+ expect(submitted.filter((record) => record.id === original.id)).toHaveLength(1)
51
+ expect(submitted.find((record) => record.id === original.id)).toMatchObject({
52
+ stage: 'published',
53
+ progress: 100,
54
+ })
55
+ expect(filterProjectRecords({ records: submitted, view: 'draft', search: {} })).toHaveLength(2)
56
+ expect(filterProjectRecords({ records: submitted, view: 'list', search: {} })).toHaveLength(19)
57
+ })
58
+
59
+ it('草稿可见性取决于创建人,负责人筛选不能显示其他人的草稿', () => {
60
+ const otherDraft: DraftProjectRecord = {
61
+ id: 'PRJ-099',
62
+ name: '其他人的草稿',
63
+ stage: 'draft',
64
+ createdBy: '其他人',
65
+ owner: currentUser,
66
+ savedAt: new Date().toISOString(),
67
+ }
68
+ const records = [...initialRecords, otherDraft]
69
+ expect(
70
+ filterProjectRecords({ records, view: 'draft', search: { owner: currentUser } }),
71
+ ).toHaveLength(3)
72
+ expect(
73
+ filterProjectRecords({ records, view: 'list', search: { name: 'PRJ-099' } }),
74
+ ).toHaveLength(0)
75
+ })
76
+
77
+ it('未填写业务状态的草稿仍可按编号搜索,状态筛选不把它当作待启动', () => {
78
+ expect(
79
+ filterProjectRecords({ records: initialRecords, view: 'draft', search: { name: 'prj-020' } }),
80
+ ).toHaveLength(1)
81
+ expect(
82
+ filterProjectRecords({
83
+ records: initialRecords,
84
+ view: 'draft',
85
+ search: { status: 'planning' },
86
+ }),
87
+ ).toHaveLength(2)
88
+ })
89
+ })
@@ -0,0 +1,145 @@
1
+ import { createServer, type Server } from 'node:http'
2
+ import type { AddressInfo } from 'node:net'
3
+ import { axiosRequestAdapter } from '@alova/adapter-axios'
4
+ import { afterAll, beforeAll, describe, expect, it, vi } from 'vite-plus/test'
5
+ import { createInstance } from '../src/utils/request/core'
6
+
7
+ let server: Server
8
+ let baseUrl: string
9
+
10
+ beforeAll(async () => {
11
+ server = createServer((req, res) => {
12
+ res.setHeader('Content-Type', 'application/json')
13
+ if (req.url === '/credentials') {
14
+ res
15
+ .writeHead(422)
16
+ .end(JSON.stringify({ code: 'AUTH.INVALID_CREDENTIALS', message: '账号或密码错误' }))
17
+ } else if (req.url === '/expired') {
18
+ res
19
+ .writeHead(401)
20
+ .end(JSON.stringify({ code: 'AUTH.SESSION_INVALID', message: '登录已失效,请重新登录' }))
21
+ } else if (req.url === '/unavailable') {
22
+ res.writeHead(503).end(
23
+ JSON.stringify({
24
+ code: 'AUTH.SERVICE_UNAVAILABLE',
25
+ message: '登录服务暂时不可用,请稍后重试',
26
+ }),
27
+ )
28
+ } else if (req.url === '/wrapped') {
29
+ res.end(JSON.stringify({ code: 200, data: { id: 'test-user' } }))
30
+ } else if (req.url?.startsWith('/http-status/')) {
31
+ const status = Number(req.url.split('/').at(-1))
32
+ res.writeHead(status).end(status === 204 ? undefined : JSON.stringify({ status }))
33
+ } else if (req.url?.startsWith('/wrapped-error/')) {
34
+ const code = Number(req.url.split('/').at(-1))
35
+ res.end(JSON.stringify({ code, message: '业务处理失败' }))
36
+ } else {
37
+ res.end(JSON.stringify({ id: 'test-user', authorization: req.headers.authorization }))
38
+ }
39
+ })
40
+ await new Promise<void>((resolve) => server.listen(0, '127.0.0.1', resolve))
41
+ baseUrl = `http://127.0.0.1:${(server.address() as AddressInfo).port}`
42
+ })
43
+
44
+ afterAll(
45
+ () =>
46
+ new Promise<void>((resolve, reject) =>
47
+ server.close((error) => (error ? reject(error) : resolve())),
48
+ ),
49
+ )
50
+
51
+ function setup() {
52
+ const unauthorized = vi.fn()
53
+ const errorMessage = vi.fn()
54
+ const request = createInstance({
55
+ baseUrl,
56
+ isWrapped: false,
57
+ requestAdapter: axiosRequestAdapter(),
58
+ commonHeaders: () => ({ Authorization: 'Bearer test-session' }),
59
+ unAuthorizedResponseFunc: unauthorized,
60
+ errorMessageFunc: errorMessage,
61
+ })
62
+ return { request, unauthorized, errorMessage }
63
+ }
64
+
65
+ describe('NestJS 响应适配', () => {
66
+ it('读取未包装的数据,并携带 Bearer 令牌', async () => {
67
+ const { request } = setup()
68
+ expect(await request.Get('/me')).toEqual({
69
+ id: 'test-user',
70
+ authorization: 'Bearer test-session',
71
+ })
72
+ expect(await request.Get('/wrapped', { meta: { isWrapped: true } })).toEqual({
73
+ id: 'test-user',
74
+ })
75
+ })
76
+
77
+ it('Axios 的 422 走统一错误解析,保留错误码和公开文案', async () => {
78
+ const { request, unauthorized, errorMessage } = setup()
79
+ await expect(request.Post('/credentials').send()).rejects.toMatchObject({
80
+ status: 422,
81
+ code: 'AUTH.INVALID_CREDENTIALS',
82
+ message: '账号或密码错误',
83
+ })
84
+ expect(errorMessage).toHaveBeenCalledExactlyOnceWith('账号或密码错误')
85
+ expect(unauthorized).not.toHaveBeenCalled()
86
+ })
87
+
88
+ it.each([201, 202, 204, 206])('HTTP %i 按 Axios 的 2xx 规则返回成功', async (status) => {
89
+ const { request, unauthorized, errorMessage } = setup()
90
+ await expect(request.Get(`/http-status/${status}`).send()).resolves.toEqual(
91
+ status === 204 ? '' : { status },
92
+ )
93
+ expect(errorMessage).not.toHaveBeenCalled()
94
+ expect(unauthorized).not.toHaveBeenCalled()
95
+ })
96
+
97
+ it('默认适配器的 HTTP 401 也走统一错误处理', async () => {
98
+ const unauthorized = vi.fn()
99
+ const errorMessage = vi.fn()
100
+ const request = createInstance({
101
+ baseUrl,
102
+ isWrapped: false,
103
+ unAuthorizedResponseFunc: unauthorized,
104
+ errorMessageFunc: errorMessage,
105
+ })
106
+
107
+ await expect(request.Get('/expired').send()).rejects.toMatchObject({
108
+ status: 401,
109
+ code: 'AUTH.SESSION_INVALID',
110
+ message: '登录已失效,请重新登录',
111
+ })
112
+ expect(unauthorized).toHaveBeenCalledOnce()
113
+ expect(errorMessage).toHaveBeenCalledExactlyOnceWith('登录已失效,请重新登录')
114
+ })
115
+
116
+ it.each([401, 422])('HTTP 200 下的业务错误 %i 仍会拒绝且只提示一次', async (code) => {
117
+ const { request, unauthorized, errorMessage } = setup()
118
+ await expect(
119
+ request.Get(`/wrapped-error/${code}`, { meta: { isWrapped: true } }).send(),
120
+ ).rejects.toMatchObject({ status: 200, code, message: '业务处理失败' })
121
+ expect(errorMessage).toHaveBeenCalledExactlyOnceWith('业务处理失败')
122
+ expect(unauthorized).toHaveBeenCalledTimes(code === 401 ? 1 : 0)
123
+ })
124
+
125
+ it('页面关闭全局提示后,401 仍触发会话失效回调', async () => {
126
+ const { request, unauthorized, errorMessage } = setup()
127
+ await expect(
128
+ request.Get('/expired', { meta: { isShowErrorMessage: false } }).send(),
129
+ ).rejects.toMatchObject({ status: 401 })
130
+ expect(unauthorized).toHaveBeenCalledOnce()
131
+ expect(unauthorized.mock.calls[0]?.[0].config.headers.get('Authorization')).toBe(
132
+ 'Bearer test-session',
133
+ )
134
+ expect(errorMessage).not.toHaveBeenCalled()
135
+ })
136
+
137
+ it('服务暂不可用时保留会话,不当成 401 注销用户', async () => {
138
+ const { request, unauthorized } = setup()
139
+ await expect(request.Get('/unavailable').send()).rejects.toMatchObject({
140
+ status: 503,
141
+ message: '登录服务暂时不可用,请稍后重试',
142
+ })
143
+ expect(unauthorized).not.toHaveBeenCalled()
144
+ })
145
+ })
@@ -0,0 +1,108 @@
1
+ import { afterEach, beforeEach, describe, expect, it, vi } from 'vite-plus/test'
2
+ import { cookie } from '../src/utils/storage/cookie'
3
+ import { local, session } from '../src/utils/storage/session'
4
+
5
+ function createMemoryStorage() {
6
+ const values = new Map<string, string>()
7
+ return {
8
+ getItem: (key: string) => values.get(key) ?? null,
9
+ setItem: (key: string, value: string) => values.set(key, value),
10
+ removeItem: (key: string) => values.delete(key),
11
+ clear: () => values.clear(),
12
+ }
13
+ }
14
+
15
+ beforeEach(() => {
16
+ vi.stubGlobal('window', {
17
+ location: { protocol: 'https:' },
18
+ localStorage: createMemoryStorage(),
19
+ sessionStorage: createMemoryStorage(),
20
+ })
21
+ vi.stubGlobal('document', { cookie: '' })
22
+ })
23
+
24
+ afterEach(() => vi.unstubAllGlobals())
25
+
26
+ describe('Cookie', () => {
27
+ it('准确区分名称,并解码包含中文、分隔符的值', () => {
28
+ document.cookie = 'token-old=wrong; token=%E4%B8%AD%E6%96%87%3B%3D%25; empty='
29
+ expect(cookie.get('token')).toBe('中文;=%')
30
+ expect(cookie.get('empty')).toBe('')
31
+ expect(cookie.get('missing')).toBeNull()
32
+ })
33
+
34
+ it('名称和值均编码,HTTPS 默认启用 Secure 并作用于整个站点', () => {
35
+ cookie.set('偏好', '中文;=')
36
+ expect(document.cookie).toBe(
37
+ '%E5%81%8F%E5%A5%BD=%E4%B8%AD%E6%96%87%3B%3D; Path=/; SameSite=Lax; Secure',
38
+ )
39
+ expect(cookie.get('偏好')).toBe('中文;=')
40
+ })
41
+
42
+ it('HTTP 开发环境可写入 Cookie,支持设置过期时间', () => {
43
+ window.location.protocol = 'http:'
44
+ const expires = new Date('2030-01-01T00:00:00Z')
45
+ cookie.set('token', 'value', { expires })
46
+ expect(document.cookie).toContain(`Expires=${expires.toUTCString()}`)
47
+ expect(document.cookie).not.toContain('Secure')
48
+ })
49
+
50
+ it('删除时覆盖原作用域,并同时设置立即过期时间和 Max-Age', () => {
51
+ cookie.remove('token', { path: '/workspace', domain: 'example.test' })
52
+ expect(document.cookie).toContain('token=;')
53
+ expect(document.cookie).toContain('Path=/workspace')
54
+ expect(document.cookie).toContain('Domain=example.test')
55
+ expect(document.cookie).toContain('Expires=Thu, 01 Jan 1970 00:00:00 GMT')
56
+ expect(document.cookie).toContain('Max-Age=0')
57
+ })
58
+
59
+ it('读取无法解码的现有 Cookie 时保留原值', () => {
60
+ document.cookie = 'token=%zz'
61
+ expect(cookie.get('token')).toBe('%zz')
62
+ })
63
+ })
64
+
65
+ describe.each([
66
+ ['local', local, 'localStorage'],
67
+ ['session', session, 'sessionStorage'],
68
+ ] as const)('%s 存储', (_name, storage, type) => {
69
+ it('保存和更新结构化数据,正确读取空字符串、false 和 0', () => {
70
+ for (const value of [{ title: '草稿', items: [1, 2] }, '', false, 0]) {
71
+ storage.set('draft', value)
72
+ expect(storage.get('draft')).toEqual(value)
73
+ }
74
+ storage.remove('draft')
75
+ expect(storage.get('draft')).toBeNull()
76
+ })
77
+
78
+ it('缺失或损坏的数据返回 null', () => {
79
+ expect(storage.get('missing')).toBeNull()
80
+ window[type].setItem('broken', '{invalid')
81
+ expect(storage.get('broken')).toBeNull()
82
+ })
83
+
84
+ it('不可序列化的数据不会覆盖已有值', () => {
85
+ storage.set('draft', 'saved')
86
+ expect(() => storage.set('draft', undefined)).toThrow(TypeError)
87
+ expect(storage.get('draft')).toBe('saved')
88
+ })
89
+
90
+ it('存储失败时向调用方抛出错误', () => {
91
+ vi.spyOn(window[type], 'setItem').mockImplementation(() => {
92
+ throw new Error('QuotaExceededError')
93
+ })
94
+ expect(() => storage.set('draft', 'value')).toThrow('QuotaExceededError')
95
+ })
96
+ })
97
+
98
+ it('local 和 session 的同名数据与清空操作相互独立', () => {
99
+ local.set('draft', 'local')
100
+ session.set('draft', 'session')
101
+ expect(local.get('draft')).toBe('local')
102
+ expect(session.get('draft')).toBe('session')
103
+ local.clear()
104
+ expect(local.get('draft')).toBeNull()
105
+ expect(session.get('draft')).toBe('session')
106
+ session.clear()
107
+ expect(session.get('draft')).toBeNull()
108
+ })
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "../tsconfig.json",
3
+ "compilerOptions": {
4
+ "types": ["node", "vite-plus/client"]
5
+ },
6
+ "include": ["./**/*.ts"]
7
+ }
@@ -4,7 +4,7 @@
4
4
  "target": "ES2023",
5
5
  "lib": ["ES2023", "DOM", "DOM.Iterable"],
6
6
  "jsx": "react-jsx",
7
- "types": ["vite-plus/client"],
7
+ "types": ["vite-plus/client", "vite-plugin-svgr/client"],
8
8
  "paths": {
9
9
  "@/*": ["./src/*"]
10
10
  },
@@ -2,6 +2,7 @@ import path from 'path'
2
2
  import tailwindcss from '@tailwindcss/vite'
3
3
  import react from '@vitejs/plugin-react'
4
4
  import AutoImport from 'unplugin-auto-import/vite'
5
+ import svgr from 'vite-plugin-svgr'
5
6
  import { defineConfig, loadEnv } from 'vite-plus'
6
7
 
7
8
  export default defineConfig(({ mode }) => {
@@ -17,6 +18,11 @@ export default defineConfig(({ mode }) => {
17
18
  `)
18
19
 
19
20
  return {
21
+ test: {
22
+ environment: 'node',
23
+ include: ['test/**/*.spec.ts'],
24
+ restoreMocks: true,
25
+ },
20
26
  resolve: {
21
27
  alias: {
22
28
  '@': path.resolve(__dirname, 'src'),
@@ -35,6 +41,7 @@ export default defineConfig(({ mode }) => {
35
41
  },
36
42
  plugins: [
37
43
  react(),
44
+ svgr({ svgrOptions: { icon: true, ref: true } }),
38
45
  AutoImport({
39
46
  imports: ['react', 'react-router', 'react-dom'],
40
47
  dts: './src/types/auto-imports.d.ts',
@@ -0,0 +1 @@
1
+ {"root":["./src/main.ts","./src/api/index.ts","./src/hooks/chart/lib.ts","./src/hooks/chart/useecharts.ts","./src/i18n/instance.ts","./src/router/index.ts","./src/router/interface.ts","./src/router/guard/index.ts","./src/router/guard/permissionguard.ts","./src/router/modules/index.ts","./src/store/index.ts","./src/store/modules/user.ts","./src/types/antdv-next.d.ts","./src/types/auto-import.d.ts","./src/types/components.d.ts","./src/types/vite-env.d.ts","./src/utils/env.ts","./src/utils/request/index.ts","./src/utils/request/core/index.ts","./src/utils/request/core/utils.ts","./src/views/example/echart/config.ts","./src/app.vue","./src/components/icon/svg-icon.vue","./src/layout/default/index.vue","./src/layout/default/header/index.vue","./src/views/example/tree-chart.vue","./src/views/example/echart/index.vue","./src/views/home/index.vue","./src/views/login/index.vue"],"errors":true,"version":"6.0.3"}
@@ -34,6 +34,25 @@ services:
34
34
  - '9001:9001'
35
35
  volumes:
36
36
  - minio-data:/data
37
+ minio-init:
38
+ image: quay.io/minio/mc:latest
39
+ container_name: vp-minio-init
40
+ depends_on:
41
+ minio:
42
+ condition: service_started
43
+ environment:
44
+ MINIO_ROOT_USER: minio
45
+ MINIO_ROOT_PASSWORD: minio123456
46
+ MINIO_BUCKET: uploads
47
+ entrypoint: >
48
+ /bin/sh -c "
49
+ until mc alias set local http://minio:9000 $$MINIO_ROOT_USER
50
+ $$MINIO_ROOT_PASSWORD;
51
+ do sleep 1; done;
52
+ mc mb --ignore-existing local/$$MINIO_BUCKET;
53
+ mc anonymous set none local/$$MINIO_BUCKET;
54
+ "
55
+ restart: 'no'
37
56
 
38
57
  volumes:
39
58
  postgres18-data:
@@ -1,3 +1,3 @@
1
1
  [tools]
2
2
  node = "26"
3
- pnpm = "11"
3
+ pnpm = "12"
@@ -24,12 +24,7 @@
24
24
  "devEngines": {
25
25
  "packageManager": {
26
26
  "name": "pnpm",
27
- "version": "11.9.0",
28
- "onFail": "download"
29
- },
30
- "runtime": {
31
- "name": "node",
32
- "version": ">=22.18.0",
27
+ "version": "11.24.0",
33
28
  "onFail": "download"
34
29
  }
35
30
  }
@@ -7,14 +7,19 @@ catalogMode: prefer
7
7
 
8
8
  catalog:
9
9
  '@alova/adapter-axios': ^2.0.18
10
+ '@ant-design/cssinjs': ^2.1.2
11
+ '@ant-design/icons': ^6.3.4
12
+ '@ant-design/pro-components': 3.1.14-7
10
13
  '@antdv-next/auto-import-resolver': ^1.1.0
11
14
  '@antdv-next/icons': ^1.1.1
12
15
  '@antfu/eslint-config': ^9.1.0
16
+ '@aws-sdk/client-s3': ^3.1120.0
13
17
  '@commitlint/cli': ^21.2.1
14
18
  '@commitlint/config-conventional': ^21.1.0
15
19
  '@fastify/cookie': ^11.1.2
16
20
  '@fastify/static': ^10.1.0
17
21
  '@nestjs-modules/ioredis': ^2.2.1
22
+ '@nestjs/bullmq': ^12.0.0
18
23
  '@nestjs/cli': ^11.0.0
19
24
  '@nestjs/common': ^11.1.27
20
25
  '@nestjs/config': ^4.0.4
@@ -41,10 +46,11 @@ catalog:
41
46
  '@vitejs/plugin-vue': ^6.0.7
42
47
  '@vue/tsconfig': ^0.9.1
43
48
  alova: ^3.5.1
44
- antd: ^6.4.5
49
+ antd: ^6.6.2
45
50
  antdv-next: ^1.4.1
46
51
  argon2: ^0.45.0
47
52
  axios: ^1.18.1
53
+ bullmq: ^6.3.4
48
54
  classnames: ^2.5.1
49
55
  cross-env: ^10.1.0
50
56
  dayjs: ^1.11.21
@@ -86,6 +92,7 @@ catalog:
86
92
  vite: npm:@voidzero-dev/vite-plus-core@0.2.4
87
93
  vite-plugin-inspect: ^11.4.1
88
94
  vite-plugin-svg-icons: ^2.0.1
95
+ vite-plugin-svgr: ^5.2.0
89
96
  vite-plus: 0.2.4
90
97
  vue: ^3.5.39
91
98
  vue-router: ^5.1.0
@@ -109,3 +116,4 @@ allowBuilds:
109
116
  argon2: true
110
117
  esbuild: true
111
118
  lefthook: true
119
+ msgpackr-extract: true
@@ -0,0 +1,8 @@
1
+ # SVG 使用
2
+
3
+ - 图标通过 `*.svg?react` 导入,使用 `@/components/Icon/svg-icon/SvgIcon` 渲染;用 `size`、`color` 控制大小和颜色,默认继承父级。
4
+ - 公共图标放 `src/assets/svg/`,页面专用图标放所属页面的 `assets/svg/`。
5
+ - 保留 `viewBox`;单色图标用 `currentColor`,保留 `none`、多色和渐变。
6
+ - 图片或背景直接导入 `*.svg` 获取 URL。
7
+
8
+ 参数、无障碍设置及示例见 [SvgIcon 使用说明](../../src/components/Icon/svg-icon/README.md)。
@@ -0,0 +1,11 @@
1
+ ## 适用范围
2
+
3
+ 本文件适用于本模板及其子目录。
4
+
5
+ ## 按需规则
6
+
7
+ 根据当前任务匹配下表,在执行相关操作前读取对应规则。不要预先加载整个 `.agents/rules/` 目录;任务范围变化时补读新命中的规则。
8
+
9
+ | 适用条件 | 规则文件 |
10
+ | -------------------- | ------------------------------------ |
11
+ | 新增、修改或使用 SVG | [SVG 使用](.agents/rules/SVG使用.md) |