create-bubbles 0.1.25 → 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 (203) hide show
  1. package/dist/index.js +3 -9
  2. package/package.json +1 -1
  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/template-vp-monorepo-react-nestjs/.agents/auth.config.ts +0 -0
  199. package/template-vp-monorepo-react-nestjs/.spaces/server/todo.md +0 -991
  200. package/template-vp-monorepo-react-nestjs/apps/server/README.md +0 -3
  201. package/template-vp-react-shadcn/.oxfmtrc.jsonc +0 -8
  202. package/template-vp-react-shadcn/.oxlintrc.jsonc +0 -3
  203. package/template-vp-react-shadcn/src/components/ui/sonner.tsx +0 -43
@@ -1,54 +1,61 @@
1
- import { PlayCircle } from "lucide-react";
2
- import { useState } from "react";
1
+ import { PlayCircle } from 'lucide-react'
2
+ import { useState } from 'react'
3
3
 
4
- import { VideoJS, VIDEO_JS_SOURCE_TYPES, type VideoJSSourceType } from "@/components/Player";
5
- import { Button } from "@/components/ui/button";
6
- import { cn } from "@/lib/utils";
4
+ import {
5
+ VideoJS,
6
+ VIDEO_JS_SOURCE_TYPES,
7
+ type VideoJSSourceType,
8
+ } from '@/components/Player'
9
+ import { Button } from '@/components/ui/button'
10
+ import { cn } from '@/lib/utils'
7
11
 
8
12
  const HOME_TEXT = {
9
- player: "VideoJS 播放器",
10
- title: "HLS / MP4 播放示例",
11
- play: "播放",
12
- } as const;
13
+ player: 'VideoJS 播放器',
14
+ title: 'HLS / MP4 播放示例',
15
+ play: '播放',
16
+ } as const
13
17
 
14
18
  type DemoSource = {
15
- id: Exclude<VideoJSSourceType, "auto" | "native">;
16
- name: string;
17
- src: string;
18
- type: string;
19
- poster: string;
20
- };
19
+ id: Exclude<VideoJSSourceType, 'auto' | 'native'>
20
+ name: string
21
+ src: string
22
+ type: string
23
+ poster: string
24
+ }
21
25
 
22
26
  const DEMO_SOURCES: DemoSource[] = [
23
27
  {
24
28
  id: VIDEO_JS_SOURCE_TYPES.HLS,
25
- name: "HLS",
26
- src: "https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8",
27
- type: "application/vnd.apple.mpegurl",
28
- poster: "https://image.mux.com/x36xhzz/thumbnail.jpg?time=0",
29
+ name: 'HLS',
30
+ src: 'https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8',
31
+ type: 'application/vnd.apple.mpegurl',
32
+ poster: 'https://image.mux.com/x36xhzz/thumbnail.jpg?time=0',
29
33
  },
30
34
  {
31
35
  id: VIDEO_JS_SOURCE_TYPES.MP4,
32
- name: "MP4",
33
- src: "https://media.w3.org/2010/05/sintel/trailer.mp4",
34
- type: "video/mp4",
35
- poster: "https://media.w3.org/2010/05/sintel/poster.png",
36
+ name: 'MP4',
37
+ src: 'https://media.w3.org/2010/05/sintel/trailer.mp4',
38
+ type: 'video/mp4',
39
+ poster: 'https://media.w3.org/2010/05/sintel/poster.png',
36
40
  },
37
- ];
41
+ ]
38
42
 
39
43
  const Home = () => {
40
- const [activeSourceType, setActiveSourceType] = useState<DemoSource["id"]>(
44
+ const [activeSourceType, setActiveSourceType] = useState<DemoSource['id']>(
41
45
  VIDEO_JS_SOURCE_TYPES.HLS,
42
- );
46
+ )
43
47
  const activeSource =
44
- DEMO_SOURCES.find((source) => source.id === activeSourceType) ?? DEMO_SOURCES[0];
48
+ DEMO_SOURCES.find((source) => source.id === activeSourceType) ??
49
+ DEMO_SOURCES[0]
45
50
 
46
51
  return (
47
52
  <main className="min-h-screen bg-zinc-950 px-4 py-6 text-white sm:px-6 lg:px-8">
48
53
  <section className="mx-auto flex w-full max-w-6xl flex-col gap-5">
49
54
  <div className="flex flex-col gap-4 sm:flex-row sm:items-end sm:justify-between">
50
55
  <div className="space-y-2">
51
- <p className="text-sm font-medium text-emerald-300">{HOME_TEXT.player}</p>
56
+ <p className="text-sm font-medium text-emerald-300">
57
+ {HOME_TEXT.player}
58
+ </p>
52
59
  <h1 className="max-w-2xl text-3xl font-semibold tracking-normal text-white sm:text-4xl">
53
60
  {HOME_TEXT.title}
54
61
  </h1>
@@ -56,7 +63,7 @@ const Home = () => {
56
63
 
57
64
  <div className="flex rounded-lg border border-white/10 bg-white/5 p-1">
58
65
  {DEMO_SOURCES.map((source) => {
59
- const isActive = source.id === activeSource.id;
66
+ const isActive = source.id === activeSource.id
60
67
 
61
68
  return (
62
69
  <Button
@@ -64,15 +71,16 @@ const Home = () => {
64
71
  type="button"
65
72
  variant="ghost"
66
73
  className={cn(
67
- "h-9 gap-2 rounded-md px-4 text-white hover:bg-white/10 hover:text-white",
68
- isActive && "bg-white text-zinc-950 hover:bg-white hover:text-zinc-950",
74
+ 'h-9 gap-2 rounded-md px-4 text-white hover:bg-white/10 hover:text-white',
75
+ isActive &&
76
+ 'bg-white text-zinc-950 hover:bg-white hover:text-zinc-950',
69
77
  )}
70
78
  onClick={() => setActiveSourceType(source.id)}
71
79
  >
72
80
  <PlayCircle className="size-4" />
73
81
  {source.name}
74
82
  </Button>
75
- );
83
+ )
76
84
  })}
77
85
  </div>
78
86
  </div>
@@ -90,7 +98,7 @@ const Home = () => {
90
98
 
91
99
  <Button>{HOME_TEXT.play}</Button>
92
100
  </main>
93
- );
94
- };
101
+ )
102
+ }
95
103
 
96
- export default Home;
104
+ export default Home
@@ -1,25 +1,25 @@
1
- import { createBrowserRouter, Navigate, type RouteObject } from "react-router";
1
+ import { createBrowserRouter, Navigate, type RouteObject } from 'react-router'
2
2
 
3
- export const lazyLoad = (path: string, fileName = "index") => {
4
- const Module = lazy(() => import(`@/pages/${path}/${fileName}.tsx`));
5
- return <Module />;
6
- };
3
+ export const lazyLoad = (path: string, fileName = 'index') => {
4
+ const Module = lazy(() => import(`@/pages/${path}/${fileName}.tsx`))
5
+ return <Module />
6
+ }
7
7
 
8
8
  const routes: RouteObject[] = [
9
9
  {
10
- path: "/",
11
- id: "index",
12
- element: <Navigate to={"/home"} />,
10
+ path: '/',
11
+ id: 'index',
12
+ element: <Navigate to={'/home'} />,
13
13
  },
14
14
  {
15
- path: "/home",
16
- id: "home",
17
- element: lazyLoad("home"),
15
+ path: '/home',
16
+ id: 'home',
17
+ element: lazyLoad('home'),
18
18
  },
19
- ];
19
+ ]
20
20
 
21
21
  export const router = createBrowserRouter(routes, {
22
- basename: "/",
23
- });
22
+ basename: '/',
23
+ })
24
24
 
25
- export const navigator = router.navigate;
25
+ export const navigator = router.navigate
@@ -1,7 +1,7 @@
1
- @import "tailwindcss";
2
- @import "tw-animate-css";
3
- @import "@fontsource-variable/geist";
4
- @import "./shadcn.css";
1
+ @import 'tailwindcss';
2
+ @import 'tw-animate-css';
3
+ @import '@fontsource-variable/geist';
4
+ @import './shadcn.css';
5
5
 
6
6
  html,
7
7
  body {
@@ -1,10 +1,10 @@
1
- @import "shadcn/tailwind.css";
1
+ @import 'shadcn/tailwind.css';
2
2
 
3
3
  @custom-variant dark (&:is(.dark *));
4
4
 
5
5
  @theme inline {
6
6
  --font-heading: var(--font-sans);
7
- --font-sans: "Geist Variable", sans-serif;
7
+ --font-sans: 'Geist Variable', sans-serif;
8
8
  --color-sidebar-ring: var(--sidebar-ring);
9
9
  --color-sidebar-border: var(--sidebar-border);
10
10
  --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
@@ -2,5 +2,5 @@ export const envVariables = {
2
2
  /**
3
3
  * API 前缀
4
4
  */
5
- API_AFFIX: import.meta.env.VITE_API_AFFIX ?? "",
6
- };
5
+ API_AFFIX: import.meta.env.VITE_API_AFFIX ?? '',
6
+ }
@@ -1,9 +1,3 @@
1
- import {
2
- deepMergeObject,
3
- isPlainObject,
4
- isReadableStream,
5
- tryParseJsonString,
6
- } from './utils'
7
1
  import type {
8
2
  AlovaGlobalCacheAdapter,
9
3
  AlovaOptions,
@@ -16,6 +10,13 @@ import { createAlova } from 'alova'
16
10
  import type { FetchRequestInit } from 'alova/fetch'
17
11
  import adapterFetch from 'alova/fetch'
18
12
 
13
+ import {
14
+ deepMergeObject,
15
+ isPlainObject,
16
+ isReadableStream,
17
+ tryParseJsonString,
18
+ } from './utils'
19
+
19
20
  type MaybePromise<T> = T | Promise<T>
20
21
  type HeaderValue =
21
22
  | string
@@ -24,7 +25,10 @@ type HeaderValue =
24
25
  | null
25
26
  | undefined
26
27
  | (() => MaybePromise<string | number | boolean | null | undefined>)
27
- type StatusMatcher<RE> = number | number[] | ((status: number, response: RE) => boolean)
28
+ type StatusMatcher<RE> =
29
+ | number
30
+ | number[]
31
+ | ((status: number, response: RE) => boolean)
28
32
  type CodeMatcher = Array<number | string>
29
33
 
30
34
  export interface StatusMap<RE = unknown> {
@@ -86,7 +90,12 @@ export type RequestOption<
86
90
  SE extends StatesExport<any> = StatesExport<any>,
87
91
  > = BaseRequestOption<RC, RE, RH, SE>
88
92
 
89
- type RequestAlovaGenerics<RC extends object, RE, RH, SE extends StatesExport<any>> = {
93
+ type RequestAlovaGenerics<
94
+ RC extends object,
95
+ RE,
96
+ RH,
97
+ SE extends StatesExport<any>,
98
+ > = {
90
99
  Responded: unknown
91
100
  Transformed: unknown
92
101
  RequestConfig: RC
@@ -97,7 +106,12 @@ type RequestAlovaGenerics<RC extends object, RE, RH, SE extends StatesExport<any
97
106
  StatesExport: SE
98
107
  }
99
108
 
100
- type ResolvedRequestOption<RC extends object, RE, RH, SE extends StatesExport<any>> = Required<
109
+ type ResolvedRequestOption<
110
+ RC extends object,
111
+ RE,
112
+ RH,
113
+ SE extends StatesExport<any>,
114
+ > = Required<
101
115
  Pick<
102
116
  BaseRequestOption<RC, RE, RH, SE>,
103
117
  | 'baseUrl'
@@ -146,11 +160,17 @@ const defaultRequestOption: BaseRequestOption<any, any, any, any> = {
146
160
  }
147
161
 
148
162
  function getMethodMeta(method: unknown): RequestMeta {
149
- const methodRecord = method as { meta?: RequestMeta; config?: { meta?: RequestMeta } } | undefined
163
+ const methodRecord = method as
164
+ | { meta?: RequestMeta; config?: { meta?: RequestMeta } }
165
+ | undefined
150
166
  return methodRecord?.config?.meta ?? methodRecord?.meta ?? {}
151
167
  }
152
168
 
153
- function getMetaFlag(meta: RequestMeta, key: keyof RequestMeta, fallback: boolean): boolean {
169
+ function getMetaFlag(
170
+ meta: RequestMeta,
171
+ key: keyof RequestMeta,
172
+ fallback: boolean,
173
+ ): boolean {
154
174
  const value = meta[key]
155
175
  return typeof value === 'boolean' ? value : fallback
156
176
  }
@@ -167,7 +187,10 @@ function isMatchedStatus<RE>(
167
187
  return Array.isArray(matcher) ? matcher.includes(status) : matcher === status
168
188
  }
169
189
 
170
- function isMatchedCode(code: unknown, matcher: CodeMatcher | undefined): boolean {
190
+ function isMatchedCode(
191
+ code: unknown,
192
+ matcher: CodeMatcher | undefined,
193
+ ): boolean {
171
194
  if (!matcher?.length) return true
172
195
 
173
196
  return matcher.some((item) => String(item) === String(code))
@@ -179,7 +202,11 @@ function getResponseStatus(response: unknown): number {
179
202
  return typeof status === 'number' ? status : Number(status)
180
203
  }
181
204
 
182
- function getResponseMessage(data: unknown, messageKey: string, defaultMessage: string): string {
205
+ function getResponseMessage(
206
+ data: unknown,
207
+ messageKey: string,
208
+ defaultMessage: string,
209
+ ): string {
183
210
  if (!isPlainObject(data)) return defaultMessage
184
211
 
185
212
  const message = data[messageKey] ?? data.message ?? data.msg
@@ -203,10 +230,14 @@ async function parseFetchResponse(response: {
203
230
  }): Promise<unknown> {
204
231
  if (response.status === 204) return undefined
205
232
 
206
- const reader = typeof response.clone === 'function' ? response.clone() : response
233
+ const reader =
234
+ typeof response.clone === 'function' ? response.clone() : response
207
235
  const contentType = getHeaderValue(response.headers, 'content-type')
208
236
 
209
- if (contentType.includes('application/json') && typeof reader.json === 'function')
237
+ if (
238
+ contentType.includes('application/json') &&
239
+ typeof reader.json === 'function'
240
+ )
210
241
  return reader.json()
211
242
 
212
243
  if (contentType.startsWith('text/') && typeof reader.text === 'function')
@@ -220,7 +251,8 @@ async function parseFetchResponse(response: {
220
251
  }
221
252
  }
222
253
 
223
- if (typeof reader.text === 'function') return tryParseJsonString(await reader.text())
254
+ if (typeof reader.text === 'function')
255
+ return tryParseJsonString(await reader.text())
224
256
 
225
257
  return undefined
226
258
  }
@@ -231,11 +263,14 @@ function getHeaderValue(
231
263
  ): string {
232
264
  if (!headers) return ''
233
265
 
234
- if (typeof Headers !== 'undefined' && headers instanceof Headers) return headers.get(key) ?? ''
266
+ if (typeof Headers !== 'undefined' && headers instanceof Headers)
267
+ return headers.get(key) ?? ''
235
268
 
236
269
  const headerRecord = headers as Record<string, unknown>
237
270
  const value =
238
- headerRecord[key] ?? headerRecord[key.toLowerCase()] ?? headerRecord[key.toUpperCase()]
271
+ headerRecord[key] ??
272
+ headerRecord[key.toLowerCase()] ??
273
+ headerRecord[key.toUpperCase()]
239
274
  return typeof value === 'string' ? value : ''
240
275
  }
241
276
 
@@ -261,7 +296,9 @@ async function getResponseData(response: unknown): Promise<unknown> {
261
296
  return response
262
297
  }
263
298
 
264
- async function resolveHeaderValue(value: HeaderValue): Promise<string | undefined> {
299
+ async function resolveHeaderValue(
300
+ value: HeaderValue,
301
+ ): Promise<string | undefined> {
265
302
  const resolved = typeof value === 'function' ? await value() : value
266
303
  if (resolved === null || resolved === undefined) return undefined
267
304
  return String(resolved)
@@ -284,7 +321,12 @@ function setHeader(target: unknown, key: string, value: string): void {
284
321
  function resolveConfig<RC extends object, RE, RH, SE extends StatesExport<any>>(
285
322
  option: BaseRequestOption<RC, RE, RH, SE>,
286
323
  ): ResolvedRequestOption<RC, RE, RH, SE> {
287
- return deepMergeObject(defaultRequestOption, option) as ResolvedRequestOption<RC, RE, RH, SE>
324
+ return deepMergeObject(defaultRequestOption, option) as ResolvedRequestOption<
325
+ RC,
326
+ RE,
327
+ RH,
328
+ SE
329
+ >
288
330
  }
289
331
 
290
332
  export function createInstance<
@@ -309,7 +351,9 @@ export function createInstance<
309
351
  const headers = methodConfig.headers ?? {}
310
352
  methodConfig.headers = headers
311
353
 
312
- for (const [key, value] of Object.entries(config.commonHeaders?.() ?? {})) {
354
+ for (const [key, value] of Object.entries(
355
+ config.commonHeaders?.() ?? {},
356
+ )) {
313
357
  const resolvedValue = await resolveHeaderValue(value)
314
358
  if (resolvedValue !== undefined) setHeader(headers, key, resolvedValue)
315
359
  }
@@ -317,9 +361,21 @@ export function createInstance<
317
361
  responded: {
318
362
  onSuccess: async (response, method) => {
319
363
  const meta = getMethodMeta(method)
320
- const shouldTransform = getMetaFlag(meta, 'isTransformResponse', config.isTransformResponse)
321
- const showSuccess = getMetaFlag(meta, 'isShowSuccessMessage', config.isShowSuccessMessage)
322
- const showError = getMetaFlag(meta, 'isShowErrorMessage', config.isShowErrorMessage)
364
+ const shouldTransform = getMetaFlag(
365
+ meta,
366
+ 'isTransformResponse',
367
+ config.isTransformResponse,
368
+ )
369
+ const showSuccess = getMetaFlag(
370
+ meta,
371
+ 'isShowSuccessMessage',
372
+ config.isShowSuccessMessage,
373
+ )
374
+ const showError = getMetaFlag(
375
+ meta,
376
+ 'isShowErrorMessage',
377
+ config.isShowErrorMessage,
378
+ )
323
379
  const isWrapped = getMetaFlag(meta, 'isWrapped', config.isWrapped)
324
380
 
325
381
  if (!shouldTransform) return response
@@ -333,14 +389,19 @@ export function createInstance<
333
389
 
334
390
  if (showError) {
335
391
  config.errorMessageFunc?.(
336
- getResponseMessage(data, config.responseMessageKey, config.errorDefaultMessage),
392
+ getResponseMessage(
393
+ data,
394
+ config.responseMessageKey,
395
+ config.errorDefaultMessage,
396
+ ),
337
397
  )
338
398
  }
339
399
  return Promise.reject(response)
340
400
  }
341
401
 
342
402
  if (!isWrapped) {
343
- if (showSuccess) config.successMessageFunc?.(config.successDefaultMessage)
403
+ if (showSuccess)
404
+ config.successMessageFunc?.(config.successDefaultMessage)
344
405
  return data
345
406
  }
346
407
 
@@ -353,11 +414,16 @@ export function createInstance<
353
414
  )
354
415
 
355
416
  if (!isMatchedCode(code, config.codeMap.success)) {
356
- if (isMatchedCode(code, config.codeMap.unAuthorized)) config.unAuthorizedResponseFunc?.()
417
+ if (isMatchedCode(code, config.codeMap.unAuthorized))
418
+ config.unAuthorizedResponseFunc?.()
357
419
 
358
420
  if (showError) {
359
421
  config.errorMessageFunc?.(
360
- getResponseMessage(data, config.responseMessageKey, config.errorDefaultMessage),
422
+ getResponseMessage(
423
+ data,
424
+ config.responseMessageKey,
425
+ config.errorDefaultMessage,
426
+ ),
361
427
  )
362
428
  }
363
429
  return Promise.reject(response)
@@ -369,7 +435,11 @@ export function createInstance<
369
435
  },
370
436
  onError: (error, method) => {
371
437
  const meta = getMethodMeta(method)
372
- const showError = getMetaFlag(meta, 'isShowErrorMessage', config.isShowErrorMessage)
438
+ const showError = getMetaFlag(
439
+ meta,
440
+ 'isShowErrorMessage',
441
+ config.isShowErrorMessage,
442
+ )
373
443
 
374
444
  if (showError) {
375
445
  config.errorMessageFunc?.(
@@ -404,7 +474,9 @@ export function createDualCallInstance<
404
474
  RE = Response,
405
475
  RH = Headers,
406
476
  SE extends StatesExport<any> = StatesExport<any>,
407
- >(baseConfig: BaseRequestOption<RC, RE, RH, SE>): DualCallInstance<RC, RE, RH, SE> {
477
+ >(
478
+ baseConfig: BaseRequestOption<RC, RE, RH, SE>,
479
+ ): DualCallInstance<RC, RE, RH, SE> {
408
480
  const defaultInstance = createInstance(baseConfig)
409
481
  const dualInstance = ((option?: RequestOption<RC, RE, RH, SE>) => {
410
482
  if (!option) return defaultInstance
@@ -1,11 +1,14 @@
1
1
  export function deepMergeObject<T = any>(source: T, target: Partial<T>): T {
2
2
  const merge = (src: any, tgt: any): any => {
3
- if (!isPlainObject(src) || !isPlainObject(tgt)) return tgt === undefined ? src : tgt
3
+ if (!isPlainObject(src) || !isPlainObject(tgt))
4
+ return tgt === undefined ? src : tgt
4
5
 
5
6
  const result = { ...src }
6
7
  for (const key of Object.keys(tgt)) {
7
8
  const targetValue = tgt[key]
8
- result[key] = isPlainObject(targetValue) ? merge(result[key], targetValue) : targetValue
9
+ result[key] = isPlainObject(targetValue)
10
+ ? merge(result[key], targetValue)
11
+ : targetValue
9
12
  }
10
13
 
11
14
  return result
@@ -1,21 +1,29 @@
1
- import reactHook from "alova/react";
2
- import { toast } from "sonner";
1
+ import type { FetchRequestInit } from 'alova/fetch'
2
+ import reactHook, { type ReactHookExportType } from 'alova/react'
3
3
 
4
- import { navigator } from "@/router";
5
- import { envVariables } from "@/utils/env";
4
+ import { toast } from '@/components/ui/toast'
5
+ import { navigator } from '@/router'
6
+ import { envVariables } from '@/utils/env'
6
7
 
7
- import { createDualCallInstance } from "./alova-core";
8
+ import { createDualCallInstance, type BaseRequestOption } from './alova-core'
9
+
10
+ type WebRequestOption = BaseRequestOption<
11
+ FetchRequestInit,
12
+ Response,
13
+ Headers,
14
+ ReactHookExportType<unknown>
15
+ >
8
16
 
9
17
  function normalizeBaseUrl(apiAffix?: string) {
10
- if (!apiAffix) return "/";
11
- if (/^https?:\/\//.test(apiAffix) || apiAffix.startsWith("/")) {
12
- return apiAffix;
18
+ if (!apiAffix) return '/'
19
+ if (/^https?:\/\//.test(apiAffix) || apiAffix.startsWith('/')) {
20
+ return apiAffix
13
21
  }
14
22
 
15
- return `/${apiAffix}`;
23
+ return `/${apiAffix}`
16
24
  }
17
25
 
18
- function getBaseConfig(): Parameters<typeof createDualCallInstance>[0] {
26
+ function getBaseConfig(): WebRequestOption {
19
27
  return {
20
28
  baseUrl: normalizeBaseUrl(envVariables.API_AFFIX),
21
29
  statusMap: {
@@ -26,23 +34,28 @@ function getBaseConfig(): Parameters<typeof createDualCallInstance>[0] {
26
34
  success: [200],
27
35
  unAuthorized: [401],
28
36
  },
29
- responseDataKey: "data",
30
- responseMessageKey: "msg",
37
+ responseDataKey: 'data',
38
+ responseMessageKey: 'msg',
31
39
  commonHeaders: () => ({}),
32
40
  successMessageFunc: (msg) => {
33
- toast.success(msg);
41
+ toast.add({ type: 'success', description: msg })
34
42
  },
35
43
  errorMessageFunc: (msg) => {
36
- toast.error(msg);
44
+ toast.add({ type: 'error', description: msg })
37
45
  },
38
46
  unAuthorizedResponseFunc: () => {
39
- navigator("/login");
40
- toast.error("登录过期或未登录");
47
+ navigator('/login')
48
+ toast.add({ type: 'error', description: '登录过期或未登录' })
41
49
  },
42
50
  statesHook: reactHook,
43
- };
51
+ }
44
52
  }
45
53
 
46
- const alovaRequest = createDualCallInstance(getBaseConfig());
54
+ const alovaRequest = createDualCallInstance<
55
+ FetchRequestInit,
56
+ Response,
57
+ Headers,
58
+ ReactHookExportType<unknown>
59
+ >(getBaseConfig())
47
60
 
48
- export default alovaRequest;
61
+ export default alovaRequest