create-bubbles 0.1.18 → 0.1.20
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.
- package/dist/index.js +406 -11
- package/package.json +3 -2
- package/template-nextjs-vinext-eslint/.dockerignore +3 -0
- package/template-nextjs-vinext-eslint/.vscode/settings.json +53 -0
- package/template-nextjs-vinext-eslint/Dockerfile +21 -0
- package/template-nextjs-vinext-eslint/README.md +100 -0
- package/template-nextjs-vinext-eslint/commitlint.config.js +1 -0
- package/template-nextjs-vinext-eslint/docker-compose.yaml +22 -0
- package/template-nextjs-vinext-eslint/eslint.config.js +20 -0
- package/template-nextjs-vinext-eslint/lefthook.yml +11 -0
- package/template-nextjs-vinext-eslint/next.config.ts +8 -0
- package/template-nextjs-vinext-eslint/nginx.conf +14 -0
- package/template-nextjs-vinext-eslint/package.json +50 -0
- package/template-nextjs-vinext-eslint/pnpm-workspace.yaml +7 -0
- package/template-nextjs-vinext-eslint/public/file.svg +1 -0
- package/template-nextjs-vinext-eslint/public/globe.svg +1 -0
- package/template-nextjs-vinext-eslint/public/logo-white.svg +128 -0
- package/template-nextjs-vinext-eslint/public/next.svg +1 -0
- package/template-nextjs-vinext-eslint/public/vercel.svg +1 -0
- package/template-nextjs-vinext-eslint/public/window.svg +1 -0
- package/template-nextjs-vinext-eslint/src/app/_components/Header/header.module.css +0 -0
- package/template-nextjs-vinext-eslint/src/app/_components/Header/header.tsx +7 -0
- package/template-nextjs-vinext-eslint/src/app/_components/Main/index.tsx +13 -0
- package/template-nextjs-vinext-eslint/src/app/antd-provider.tsx +30 -0
- package/template-nextjs-vinext-eslint/src/app/icon.svg +26 -0
- package/template-nextjs-vinext-eslint/src/app/layout.tsx +68 -0
- package/template-nextjs-vinext-eslint/src/app/page.module.css +141 -0
- package/template-nextjs-vinext-eslint/src/app/page.tsx +43 -0
- package/template-nextjs-vinext-eslint/src/app/uno-css.tsx +7 -0
- package/template-nextjs-vinext-eslint/src/assets/icon/logo-white.svg +128 -0
- package/template-nextjs-vinext-eslint/src/assets/icon/logo.svg +26 -0
- package/template-nextjs-vinext-eslint/src/assets/image/QR.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/banner_1.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/banner_2.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/banner_3.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/banner_4.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/banner_top.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/icon_title_left.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/icon_title_right.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/img.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_COCT.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/344/270/207/347/247/221.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/344/270/255/345/205/264.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/344/270/255/345/206/266/345/273/272/345/267/245.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/344/270/255/345/233/275/344/270/255/351/223/201.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/344/270/255/345/233/275/344/272/224/345/206/266.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/344/270/255/345/233/275/344/272/244/351/200/232/345/273/272/350/256/276.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/344/270/255/345/233/275/345/273/272/344/270/232.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/344/270/255/345/233/275/345/273/272/347/255/221/347/247/221/345/255/246/351/231/242.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/344/270/255/345/233/275/347/224/265/345/273/272.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/344/270/255/345/233/275/351/223/201/345/273/272.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/345/256/234/351/200/232/344/270/226/347/272/252.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/346/225/260/347/273/264/347/251/272/351/227/264.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/346/226/260/346/230/212/350/276/260/345/273/272/350/256/276.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/346/236/227/345/220/214/346/243/252/345/233/275/351/231/205.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/346/270/235/351/232/206/351/233/206/345/233/242.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/347/273/264/345/241/224/347/247/221/346/212/200.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/350/205/276/350/256/257.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/350/265/233/350/277/252/344/277/241/346/201/257.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/351/207/215/345/272/206/344/272/244/351/200/232/345/244/247/345/255/246.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/351/207/215/345/272/206/344/272/244/351/200/232/350/201/214/344/270/232/345/255/246/351/231/242.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/351/207/215/345/272/206/345/244/247/345/255/246.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/351/207/215/345/272/206/345/267/245/345/225/206/350/201/214/344/270/232/345/255/246/351/231/242.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/351/207/215/345/272/206/345/267/245/347/250/213/350/201/214/344/270/232/346/212/200/346/234/257/345/255/246/351/231/242.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/351/207/215/345/272/206/345/273/272/345/267/245.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/351/230/277/351/207/214/344/272/221.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/351/231/206/345/206/233/345/206/233/345/214/273/345/244/247/345/255/246.png +0 -0
- package/template-nextjs-vinext-eslint/src/assets/image/parteners/logo_/351/276/231/346/271/226.png +0 -0
- package/template-nextjs-vinext-eslint/src/styles/globals.css +47 -0
- package/template-nextjs-vinext-eslint/src/types/vite-env.d.ts +18 -0
- package/template-nextjs-vinext-eslint/src/utils/env.ts +14 -0
- package/template-nextjs-vinext-eslint/src/utils/index.ts +0 -0
- package/template-nextjs-vinext-eslint/src/utils/request/core/index.ts +425 -0
- package/template-nextjs-vinext-eslint/src/utils/request/core/utils.ts +39 -0
- package/template-nextjs-vinext-eslint/src/utils/request/index.ts +48 -0
- package/template-nextjs-vinext-eslint/tsconfig.json +34 -0
- package/template-nextjs-vinext-eslint/uno.config.ts +8 -0
- package/template-nextjs-vinext-eslint/vite.config.ts +8 -0
- package/template-react-rsbuild-biome/.env +5 -0
- package/template-react-rsbuild-biome/.env.development +1 -0
- package/template-react-rsbuild-biome/.env.production +1 -0
- package/template-react-rsbuild-biome/.prettierignore +34 -0
- package/template-react-rsbuild-biome/.prettierrc +16 -0
- package/template-react-rsbuild-biome/.vscode/settings.json +10 -0
- package/template-react-rsbuild-biome/README.md +29 -0
- package/template-react-rsbuild-biome/biome.json +116 -0
- package/template-react-rsbuild-biome/commitlint.config.js +1 -0
- package/template-react-rsbuild-biome/index.html +7 -0
- package/template-react-rsbuild-biome/lefthook.yml +14 -0
- package/template-react-rsbuild-biome/package.json +42 -0
- package/template-react-rsbuild-biome/public/.gitkeep +0 -0
- package/template-react-rsbuild-biome/rsbuild.config.ts +44 -0
- package/template-react-rsbuild-biome/src/App.tsx +9 -0
- package/template-react-rsbuild-biome/src/assets/font/AlimamaShuHeiTi-Bold.ttf +0 -0
- package/template-react-rsbuild-biome/src/assets/icon/logo.svg +7 -0
- package/template-react-rsbuild-biome/src/components/Loading/PageLoading.tsx +11 -0
- package/template-react-rsbuild-biome/src/env.d.ts +1 -0
- package/template-react-rsbuild-biome/src/index.tsx +18 -0
- package/template-react-rsbuild-biome/src/layout/default/index.tsx +10 -0
- package/template-react-rsbuild-biome/src/pages/home/index.tsx +5 -0
- package/template-react-rsbuild-biome/src/router/index.tsx +38 -0
- package/template-react-rsbuild-biome/src/store/index.ts +0 -0
- package/template-react-rsbuild-biome/src/store/modules/user.ts +11 -0
- package/template-react-rsbuild-biome/src/styles/fonts.scss +4 -0
- package/template-react-rsbuild-biome/src/styles/index.scss +19 -0
- package/template-react-rsbuild-biome/src/styles/variables.scss +4 -0
- package/template-react-rsbuild-biome/src/types/auto-import.d.ts +49 -0
- package/template-react-rsbuild-biome/src/utils/env.ts +10 -0
- package/template-react-rsbuild-biome/src/utils/request/core/index.ts +425 -0
- package/template-react-rsbuild-biome/src/utils/request/core/utils.ts +39 -0
- package/template-react-rsbuild-biome/src/utils/request/index.ts +42 -0
- package/template-react-rsbuild-biome/tsconfig.json +35 -0
- package/template-react-rsbuild-biome/uno.config.ts +8 -0
- package/template-taro-react-oxc/.editorconfig +12 -0
- package/template-taro-react-oxc/.env +1 -0
- package/template-taro-react-oxc/.env.development +6 -0
- package/template-taro-react-oxc/.env.production +5 -0
- package/template-taro-react-oxc/.oxfmtrc.json +12 -0
- package/template-taro-react-oxc/.oxlintrc.json +9 -0
- package/template-taro-react-oxc/.vscode/settings.json +13 -0
- package/template-taro-react-oxc/babel.config.js +45 -0
- package/template-taro-react-oxc/commitlint.config.mjs +1 -0
- package/template-taro-react-oxc/config/dev.ts +10 -0
- package/template-taro-react-oxc/config/index.ts +172 -0
- package/template-taro-react-oxc/config/prod.ts +39 -0
- package/template-taro-react-oxc/config/release.ts +106 -0
- package/template-taro-react-oxc/key/.gitkeep +0 -0
- package/template-taro-react-oxc/lefthook.yaml +18 -0
- package/template-taro-react-oxc/package.json +118 -0
- package/template-taro-react-oxc/patches/@tarojs__plugin-mini-ci.patch +13 -0
- package/template-taro-react-oxc/pnpm-workspace.yaml +13 -0
- package/template-taro-react-oxc/postcss.config.js +6 -0
- package/template-taro-react-oxc/project.config.json +15 -0
- package/template-taro-react-oxc/src/app.config.ts +11 -0
- package/template-taro-react-oxc/src/app.ts +14 -0
- package/template-taro-react-oxc/src/index.html +17 -0
- package/template-taro-react-oxc/src/pages/index/index.config.ts +3 -0
- package/template-taro-react-oxc/src/pages/index/index.scss +0 -0
- package/template-taro-react-oxc/src/pages/index/index.tsx +44 -0
- package/template-taro-react-oxc/src/store/taroStorage.ts +7 -0
- package/template-taro-react-oxc/src/store/user.ts +13 -0
- package/template-taro-react-oxc/src/styles/index.css +1 -0
- package/template-taro-react-oxc/src/utils/env.ts +10 -0
- package/template-taro-react-oxc/src/utils/request/core/index.ts +425 -0
- package/template-taro-react-oxc/src/utils/request/core/utils.ts +39 -0
- package/template-taro-react-oxc/src/utils/request/index.ts +37 -0
- package/template-taro-react-oxc/stylelint.config.mjs +28 -0
- package/template-taro-react-oxc/tailwind.config.js +12 -0
- package/template-taro-react-oxc/tsconfig.json +28 -0
- package/template-taro-react-oxc/types/global.d.ts +29 -0
- package/template-taro-vue-eslint/.editorconfig +12 -0
- package/template-taro-vue-eslint/.env +3 -0
- package/template-taro-vue-eslint/.env.development +5 -0
- package/template-taro-vue-eslint/.env.production +5 -0
- package/template-taro-vue-eslint/.vscode/settings.json +57 -0
- package/template-taro-vue-eslint/babel.config.js +12 -0
- package/template-taro-vue-eslint/commitlint.config.mjs +1 -0
- package/template-taro-vue-eslint/config/dev.ts +27 -0
- package/template-taro-vue-eslint/config/index.ts +134 -0
- package/template-taro-vue-eslint/config/output-root.ts +11 -0
- package/template-taro-vue-eslint/config/prod.ts +39 -0
- package/template-taro-vue-eslint/config/release.ts +113 -0
- package/template-taro-vue-eslint/eslint.config.mjs +22 -0
- package/template-taro-vue-eslint/lefthook.yaml +13 -0
- package/template-taro-vue-eslint/package.json +115 -0
- package/template-taro-vue-eslint/patches/@tarojs__plugin-mini-ci.patch +13 -0
- package/template-taro-vue-eslint/pnpm-workspace.yaml +13 -0
- package/template-taro-vue-eslint/project.config.json +16 -0
- package/template-taro-vue-eslint/src/api/common/upload.ts +53 -0
- package/template-taro-vue-eslint/src/app.config.ts +19 -0
- package/template-taro-vue-eslint/src/app.ts +14 -0
- package/template-taro-vue-eslint/src/assets/image/.gitkeep +0 -0
- package/template-taro-vue-eslint/src/index.html +17 -0
- package/template-taro-vue-eslint/src/pages/example/upload/index.config.ts +3 -0
- package/template-taro-vue-eslint/src/pages/example/upload/index.module.scss +4 -0
- package/template-taro-vue-eslint/src/pages/example/upload/index.vue +71 -0
- package/template-taro-vue-eslint/src/pages/index/index.config.ts +3 -0
- package/template-taro-vue-eslint/src/pages/index/index.module.scss +4 -0
- package/template-taro-vue-eslint/src/pages/index/index.vue +77 -0
- package/template-taro-vue-eslint/src/store/index.ts +10 -0
- package/template-taro-vue-eslint/src/store/modules/user.ts +15 -0
- package/template-taro-vue-eslint/src/store/taroStorage.ts +7 -0
- package/template-taro-vue-eslint/src/styles/index.css +1 -0
- package/template-taro-vue-eslint/src/styles/nut-theme.css +4 -0
- package/template-taro-vue-eslint/src/utils/env.ts +13 -0
- package/template-taro-vue-eslint/src/utils/index.ts +40 -0
- package/template-taro-vue-eslint/src/utils/request/core/index.ts +425 -0
- package/template-taro-vue-eslint/src/utils/request/core/utils.ts +39 -0
- package/template-taro-vue-eslint/src/utils/request/index.ts +73 -0
- package/template-taro-vue-eslint/tsconfig.json +30 -0
- package/template-taro-vue-eslint/types/components.d.ts +16 -0
- package/template-taro-vue-eslint/types/global.d.ts +31 -0
- package/template-taro-vue-eslint/types/vue.d.ts +10 -0
- package/template-taro-vue-eslint/unocss.config.ts +42 -0
- package/template-vp-monorepo-react-nestjs/.oxfmtrc.jsonc +8 -0
- package/template-vp-monorepo-react-nestjs/.oxlintrc.jsonc +3 -0
- package/template-vp-monorepo-react-nestjs/.specs//351/234/200/346/261/202.md +5 -0
- package/template-vp-monorepo-react-nestjs/.vite-hooks/commit-msg +1 -0
- package/template-vp-monorepo-react-nestjs/.vite-hooks/pre-commit +1 -0
- package/template-vp-monorepo-react-nestjs/README.md +29 -0
- package/template-vp-monorepo-react-nestjs/apps/service/.oxlintrc.jsonc +3 -0
- package/template-vp-monorepo-react-nestjs/apps/web/.env +1 -0
- package/template-vp-monorepo-react-nestjs/apps/web/.oxlintrc.jsonc +4 -0
- package/template-vp-monorepo-react-nestjs/apps/web/index.html +13 -0
- package/template-vp-monorepo-react-nestjs/apps/web/package.json +39 -0
- package/template-vp-monorepo-react-nestjs/apps/web/public/favicon.svg +1 -0
- package/template-vp-monorepo-react-nestjs/apps/web/public/icons.svg +24 -0
- package/template-vp-monorepo-react-nestjs/apps/web/src/App.tsx +24 -0
- package/template-vp-monorepo-react-nestjs/apps/web/src/assets/hero.png +0 -0
- package/template-vp-monorepo-react-nestjs/apps/web/src/assets/react.svg +1 -0
- package/template-vp-monorepo-react-nestjs/apps/web/src/assets/vite.svg +1 -0
- package/template-vp-monorepo-react-nestjs/apps/web/src/components/Loading/PageLoading.tsx +11 -0
- package/template-vp-monorepo-react-nestjs/apps/web/src/main.tsx +5 -0
- package/template-vp-monorepo-react-nestjs/apps/web/src/pages/home/index.tsx +17 -0
- package/template-vp-monorepo-react-nestjs/apps/web/src/router/index.tsx +25 -0
- package/template-vp-monorepo-react-nestjs/apps/web/src/router/modules/.gitkeep +0 -0
- package/template-vp-monorepo-react-nestjs/apps/web/src/styles/index.css +7 -0
- package/template-vp-monorepo-react-nestjs/apps/web/src/types/auto-imports.d.ts +58 -0
- package/template-vp-monorepo-react-nestjs/apps/web/tsconfig.json +32 -0
- package/template-vp-monorepo-react-nestjs/apps/web/vite.config.ts +32 -0
- package/template-vp-monorepo-react-nestjs/commitlint.config.js +0 -0
- package/template-vp-monorepo-react-nestjs/package.json +20 -0
- package/template-vp-monorepo-react-nestjs/packages/utils/README.md +23 -0
- package/template-vp-monorepo-react-nestjs/packages/utils/package.json +39 -0
- package/template-vp-monorepo-react-nestjs/packages/utils/src/index.ts +3 -0
- package/template-vp-monorepo-react-nestjs/packages/utils/tests/index.test.ts +6 -0
- package/template-vp-monorepo-react-nestjs/packages/utils/tsconfig.json +20 -0
- package/template-vp-monorepo-react-nestjs/packages/utils/tsdown.config.ts +9 -0
- package/template-vp-monorepo-react-nestjs/packages/utils/vite.config.ts +7 -0
- package/template-vp-monorepo-react-nestjs/pnpm-workspace.yaml +23 -0
- package/template-vp-monorepo-react-nestjs/tsconfig.json +9 -0
- package/template-vp-monorepo-react-nestjs/vite.config.ts +8 -0
- package/template-vp-react/.env +1 -0
- package/template-vp-react/.oxfmtrc.jsonc +8 -0
- package/template-vp-react/.oxlintrc.jsonc +11 -0
- package/template-vp-react/.vite-hooks/commit-msg +1 -0
- package/template-vp-react/.vite-hooks/pre-commit +1 -0
- package/template-vp-react/.vscode/extensions.json +3 -0
- package/template-vp-react/.vscode/settings.json +11 -0
- package/template-vp-react/commitlint.config.js +0 -0
- package/template-vp-react/index.html +13 -0
- package/template-vp-react/package.json +44 -0
- package/template-vp-react/public/favicon.svg +1 -0
- package/template-vp-react/public/icons.svg +24 -0
- package/template-vp-react/src/App.tsx +24 -0
- package/template-vp-react/src/assets/hero.png +0 -0
- package/template-vp-react/src/assets/react.svg +1 -0
- package/template-vp-react/src/assets/vite.svg +1 -0
- package/template-vp-react/src/components/Loading/PageLoading.tsx +11 -0
- package/template-vp-react/src/main.tsx +5 -0
- package/template-vp-react/src/pages/home/index.tsx +17 -0
- package/template-vp-react/src/router/index.tsx +25 -0
- package/template-vp-react/src/router/modules/.gitkeep +0 -0
- package/template-vp-react/src/styles/index.css +7 -0
- package/template-vp-react/src/types/auto-imports.d.ts +58 -0
- package/template-vp-react/src/utils/env/index.ts +6 -0
- package/template-vp-react/src/utils/request/core/index.ts +420 -0
- package/template-vp-react/src/utils/request/core/utils.ts +39 -0
- package/template-vp-react/src/utils/request/index.ts +48 -0
- package/template-vp-react/tsconfig.json +32 -0
- package/template-vp-react/vite.config.ts +35 -0
- package/template-vp-react-shadcn/.agents/skills/alova-client-usage/README.md +28 -0
- package/template-vp-react-shadcn/.agents/skills/alova-client-usage/SKILL.md +249 -0
- package/template-vp-react-shadcn/.agents/skills/alova-client-usage/references/SETUP.md +146 -0
- package/template-vp-react-shadcn/.agents/skills/shadcn/SKILL.md +260 -0
- package/template-vp-react-shadcn/.agents/skills/shadcn/agents/openai.yml +5 -0
- package/template-vp-react-shadcn/.agents/skills/shadcn/assets/shadcn-small.png +0 -0
- package/template-vp-react-shadcn/.agents/skills/shadcn/assets/shadcn.png +0 -0
- package/template-vp-react-shadcn/.agents/skills/shadcn/cli.md +276 -0
- package/template-vp-react-shadcn/.agents/skills/shadcn/customization.md +209 -0
- package/template-vp-react-shadcn/.agents/skills/shadcn/evals/evals.json +47 -0
- package/template-vp-react-shadcn/.agents/skills/shadcn/mcp.md +94 -0
- package/template-vp-react-shadcn/.agents/skills/shadcn/rules/base-vs-radix.md +306 -0
- package/template-vp-react-shadcn/.agents/skills/shadcn/rules/composition.md +195 -0
- package/template-vp-react-shadcn/.agents/skills/shadcn/rules/forms.md +192 -0
- package/template-vp-react-shadcn/.agents/skills/shadcn/rules/icons.md +101 -0
- package/template-vp-react-shadcn/.agents/skills/shadcn/rules/styling.md +162 -0
- package/template-vp-react-shadcn/.agents/skills/vite-plus/README.md +75 -0
- package/template-vp-react-shadcn/.agents/skills/vite-plus/SKILL.md +322 -0
- package/template-vp-react-shadcn/.agents/skills/vite-plus/evals.json +182 -0
- package/template-vp-react-shadcn/.agents/skills/vite-plus/references/config.md +162 -0
- package/template-vp-react-shadcn/.agents/skills/vite-plus/references/env-management.md +76 -0
- package/template-vp-react-shadcn/.agents/skills/vite-plus/references/task-runner.md +152 -0
- package/template-vp-react-shadcn/.agents/skills/vite-plus/sources.yaml +142 -0
- package/template-vp-react-shadcn/.env +1 -0
- package/template-vp-react-shadcn/.oxfmtrc.jsonc +8 -0
- package/template-vp-react-shadcn/.oxlintrc.jsonc +3 -0
- package/template-vp-react-shadcn/.vite-hooks/commit-msg +1 -0
- package/template-vp-react-shadcn/.vite-hooks/pre-commit +1 -0
- package/template-vp-react-shadcn/.vscode/extensions.json +3 -0
- package/template-vp-react-shadcn/.vscode/settings.json +12 -0
- package/template-vp-react-shadcn/agents.md +44 -0
- package/template-vp-react-shadcn/commitlint.config.js +1 -0
- package/template-vp-react-shadcn/components.json +25 -0
- package/template-vp-react-shadcn/index.html +13 -0
- package/template-vp-react-shadcn/package.json +56 -0
- package/template-vp-react-shadcn/public/favicon.svg +1 -0
- package/template-vp-react-shadcn/public/icons.svg +24 -0
- package/template-vp-react-shadcn/skills-lock.json +11 -0
- package/template-vp-react-shadcn/src/App.tsx +24 -0
- package/template-vp-react-shadcn/src/api/.gitkeep +0 -0
- package/template-vp-react-shadcn/src/assets/hero.png +0 -0
- package/template-vp-react-shadcn/src/assets/react.svg +1 -0
- package/template-vp-react-shadcn/src/assets/vite.svg +1 -0
- package/template-vp-react-shadcn/src/components/Loading/PageLoading.tsx +11 -0
- package/template-vp-react-shadcn/src/components/Player/VideoJS/index.tsx +163 -0
- package/template-vp-react-shadcn/src/components/Player/index.ts +7 -0
- package/template-vp-react-shadcn/src/components/ui/button.tsx +67 -0
- package/template-vp-react-shadcn/src/components/ui/sonner.tsx +43 -0
- package/template-vp-react-shadcn/src/components/ui/spinner.tsx +17 -0
- package/template-vp-react-shadcn/src/hooks/.gitkeep +0 -0
- package/template-vp-react-shadcn/src/lib/utils.ts +6 -0
- package/template-vp-react-shadcn/src/main.tsx +5 -0
- package/template-vp-react-shadcn/src/pages/home/index.tsx +96 -0
- package/template-vp-react-shadcn/src/router/index.tsx +25 -0
- package/template-vp-react-shadcn/src/router/modules/.gitkeep +0 -0
- package/template-vp-react-shadcn/src/store/.gitkeep +0 -0
- package/template-vp-react-shadcn/src/styles/index.css +16 -0
- package/template-vp-react-shadcn/src/styles/shadcn.css +127 -0
- package/template-vp-react-shadcn/src/types/auto-imports.d.ts +58 -0
- package/template-vp-react-shadcn/src/utils/env/index.tsx +6 -0
- package/template-vp-react-shadcn/src/utils/request/alova-core/index.ts +425 -0
- package/template-vp-react-shadcn/src/utils/request/alova-core/utils.ts +39 -0
- package/template-vp-react-shadcn/src/utils/request/index.ts +48 -0
- package/template-vp-react-shadcn/src/utils/request/readme.md +176 -0
- package/template-vp-react-shadcn/tsconfig.json +32 -0
- package/template-vp-react-shadcn/vite.config.ts +35 -0
- package/template-vue-vite-eslint/.env +6 -0
- package/template-vue-vite-eslint/.env.development +2 -0
- package/template-vue-vite-eslint/.env.production +1 -0
- package/template-vue-vite-eslint/README.md +3 -0
- package/template-vue-vite-eslint/commitlint.config.js +1 -0
- package/template-vue-vite-eslint/eslint.config.js +69 -0
- package/template-vue-vite-eslint/index.html +13 -0
- package/template-vue-vite-eslint/lefthook.yml +11 -0
- package/template-vue-vite-eslint/package.json +56 -0
- package/template-vue-vite-eslint/public/vite.svg +1 -0
- package/template-vue-vite-eslint/src/App.vue +19 -0
- package/template-vue-vite-eslint/src/api/index.ts +12 -0
- package/template-vue-vite-eslint/src/assets/icon/computer-data.svg +3 -0
- package/template-vue-vite-eslint/src/assets/icon/cpu.svg +3 -0
- package/template-vue-vite-eslint/src/assets/icon/data-search.svg +3 -0
- package/template-vue-vite-eslint/src/assets/icon/home.svg +3 -0
- package/template-vue-vite-eslint/src/assets/icon/knowledge-graph.svg +3 -0
- package/template-vue-vite-eslint/src/assets/icon/logo.svg +1 -0
- package/template-vue-vite-eslint/src/assets/icon/robot.svg +3 -0
- package/template-vue-vite-eslint/src/assets/image/.gitkeep +0 -0
- package/template-vue-vite-eslint/src/components/Icon/svg-icon.vue +29 -0
- package/template-vue-vite-eslint/src/hooks/chart/lib.ts +57 -0
- package/template-vue-vite-eslint/src/hooks/chart/useEcharts.ts +65 -0
- package/template-vue-vite-eslint/src/layout/default/header/index.vue +12 -0
- package/template-vue-vite-eslint/src/layout/default/index.vue +55 -0
- package/template-vue-vite-eslint/src/main.ts +16 -0
- package/template-vue-vite-eslint/src/router/guard/index.ts +7 -0
- package/template-vue-vite-eslint/src/router/guard/permissionGuard.ts +13 -0
- package/template-vue-vite-eslint/src/router/index.ts +18 -0
- package/template-vue-vite-eslint/src/router/interface.ts +9 -0
- package/template-vue-vite-eslint/src/router/modules/example.ts +21 -0
- package/template-vue-vite-eslint/src/router/modules/index.ts +36 -0
- package/template-vue-vite-eslint/src/store/index.ts +11 -0
- package/template-vue-vite-eslint/src/store/modules/user.ts +20 -0
- package/template-vue-vite-eslint/src/styles/font.scss +0 -0
- package/template-vue-vite-eslint/src/styles/index.scss +29 -0
- package/template-vue-vite-eslint/src/styles/variables.scss +3 -0
- package/template-vue-vite-eslint/src/types/auto-import.d.ts +78 -0
- package/template-vue-vite-eslint/src/types/components.d.ts +18 -0
- package/template-vue-vite-eslint/src/types/vite-env.d.ts +15 -0
- package/template-vue-vite-eslint/src/utils/env.ts +11 -0
- package/template-vue-vite-eslint/src/utils/request/core/index.ts +425 -0
- package/template-vue-vite-eslint/src/utils/request/core/utils.ts +39 -0
- package/template-vue-vite-eslint/src/utils/request/index.ts +42 -0
- package/template-vue-vite-eslint/src/views/example/echart/config.ts +1794 -0
- package/template-vue-vite-eslint/src/views/example/echart/index.vue +22 -0
- package/template-vue-vite-eslint/src/views/example/h-full.vue +24 -0
- package/template-vue-vite-eslint/src/views/example/tree-chart.vue +94 -0
- package/template-vue-vite-eslint/src/views/home/index.vue +25 -0
- package/template-vue-vite-eslint/src/views/login/index.vue +9 -0
- package/template-vue-vite-eslint/tsconfig.json +36 -0
- package/template-vue-vite-eslint/uno.config.ts +21 -0
- package/template-vue-vite-eslint/vite.config.ts +60 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { RouteRecordRaw } from 'vue-router'
|
|
2
|
+
|
|
3
|
+
import type { MenuRouteRecordRawType } from '../interface'
|
|
4
|
+
|
|
5
|
+
import { ExampleRoutes } from './example'
|
|
6
|
+
|
|
7
|
+
export const menuRoutes: MenuRouteRecordRawType [] = [
|
|
8
|
+
{
|
|
9
|
+
path: '/home',
|
|
10
|
+
name: 'Home',
|
|
11
|
+
meta: { title: '首页概览', icon: 'svg-home' },
|
|
12
|
+
component: () => import('@/views/home/index.vue'),
|
|
13
|
+
},
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
export const routes: RouteRecordRaw[] = [
|
|
17
|
+
{
|
|
18
|
+
path: '/',
|
|
19
|
+
name: 'layout',
|
|
20
|
+
component: () => import('@/layout/default/index.vue'),
|
|
21
|
+
children: [
|
|
22
|
+
{
|
|
23
|
+
path: '/',
|
|
24
|
+
redirect: '/home',
|
|
25
|
+
},
|
|
26
|
+
...menuRoutes,
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
...ExampleRoutes,
|
|
30
|
+
{
|
|
31
|
+
path: '/login',
|
|
32
|
+
name: 'login',
|
|
33
|
+
meta: { title: '登录' },
|
|
34
|
+
component: () => import('@/views/login/index.vue'),
|
|
35
|
+
},
|
|
36
|
+
]
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { App } from 'vue'
|
|
2
|
+
|
|
3
|
+
import { createPinia } from 'pinia'
|
|
4
|
+
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
|
|
5
|
+
|
|
6
|
+
export const store = createPinia()
|
|
7
|
+
store.use(piniaPluginPersistedstate)
|
|
8
|
+
|
|
9
|
+
export function setupStore(app: App) {
|
|
10
|
+
app.use(store)
|
|
11
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { defineStore } from 'pinia'
|
|
2
|
+
|
|
3
|
+
import { store } from '..'
|
|
4
|
+
|
|
5
|
+
export const useUserStore = defineStore(
|
|
6
|
+
'user',
|
|
7
|
+
{
|
|
8
|
+
state: () => {
|
|
9
|
+
return {
|
|
10
|
+
name: 'admin',
|
|
11
|
+
token: 'admin',
|
|
12
|
+
avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
export function useUserStoreWithOut() {
|
|
19
|
+
return useUserStore(store)
|
|
20
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
@use './font.scss';
|
|
2
|
+
@use './variables.scss';
|
|
3
|
+
|
|
4
|
+
html,
|
|
5
|
+
body,
|
|
6
|
+
#root {
|
|
7
|
+
width: 100%;
|
|
8
|
+
height: 100%;
|
|
9
|
+
font-family: 'SourceHanSansCN';
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
*,
|
|
13
|
+
*::before,
|
|
14
|
+
*::after {
|
|
15
|
+
margin: 0;
|
|
16
|
+
padding: 0;
|
|
17
|
+
box-sizing: border-box;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
//弹窗的标题样式
|
|
21
|
+
.dialog-title {
|
|
22
|
+
border-left: 3px solid #22b5ffff;
|
|
23
|
+
padding-left: 10px;
|
|
24
|
+
height: 16px;
|
|
25
|
+
color: #ffffffb8;
|
|
26
|
+
font: 700;
|
|
27
|
+
font-size: 16px;
|
|
28
|
+
line-height: 16px;
|
|
29
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/* prettier-ignore */
|
|
3
|
+
// @ts-nocheck
|
|
4
|
+
// noinspection JSUnusedGlobalSymbols
|
|
5
|
+
// Generated by unplugin-auto-import
|
|
6
|
+
// biome-ignore lint: disable
|
|
7
|
+
export {}
|
|
8
|
+
declare global {
|
|
9
|
+
const EffectScope: typeof import('vue').EffectScope
|
|
10
|
+
const computed: typeof import('vue').computed
|
|
11
|
+
const createApp: typeof import('vue').createApp
|
|
12
|
+
const customRef: typeof import('vue').customRef
|
|
13
|
+
const defineAsyncComponent: typeof import('vue').defineAsyncComponent
|
|
14
|
+
const defineComponent: typeof import('vue').defineComponent
|
|
15
|
+
const effectScope: typeof import('vue').effectScope
|
|
16
|
+
const getCurrentInstance: typeof import('vue').getCurrentInstance
|
|
17
|
+
const getCurrentScope: typeof import('vue').getCurrentScope
|
|
18
|
+
const getCurrentWatcher: typeof import('vue').getCurrentWatcher
|
|
19
|
+
const h: typeof import('vue').h
|
|
20
|
+
const inject: typeof import('vue').inject
|
|
21
|
+
const isProxy: typeof import('vue').isProxy
|
|
22
|
+
const isReactive: typeof import('vue').isReactive
|
|
23
|
+
const isReadonly: typeof import('vue').isReadonly
|
|
24
|
+
const isRef: typeof import('vue').isRef
|
|
25
|
+
const isShallow: typeof import('vue').isShallow
|
|
26
|
+
const markRaw: typeof import('vue').markRaw
|
|
27
|
+
const nextTick: typeof import('vue').nextTick
|
|
28
|
+
const onActivated: typeof import('vue').onActivated
|
|
29
|
+
const onBeforeMount: typeof import('vue').onBeforeMount
|
|
30
|
+
const onBeforeRouteLeave: typeof import('vue-router').onBeforeRouteLeave
|
|
31
|
+
const onBeforeRouteUpdate: typeof import('vue-router').onBeforeRouteUpdate
|
|
32
|
+
const onBeforeUnmount: typeof import('vue').onBeforeUnmount
|
|
33
|
+
const onBeforeUpdate: typeof import('vue').onBeforeUpdate
|
|
34
|
+
const onDeactivated: typeof import('vue').onDeactivated
|
|
35
|
+
const onErrorCaptured: typeof import('vue').onErrorCaptured
|
|
36
|
+
const onMounted: typeof import('vue').onMounted
|
|
37
|
+
const onRenderTracked: typeof import('vue').onRenderTracked
|
|
38
|
+
const onRenderTriggered: typeof import('vue').onRenderTriggered
|
|
39
|
+
const onScopeDispose: typeof import('vue').onScopeDispose
|
|
40
|
+
const onServerPrefetch: typeof import('vue').onServerPrefetch
|
|
41
|
+
const onUnmounted: typeof import('vue').onUnmounted
|
|
42
|
+
const onUpdated: typeof import('vue').onUpdated
|
|
43
|
+
const onWatcherCleanup: typeof import('vue').onWatcherCleanup
|
|
44
|
+
const provide: typeof import('vue').provide
|
|
45
|
+
const reactive: typeof import('vue').reactive
|
|
46
|
+
const readonly: typeof import('vue').readonly
|
|
47
|
+
const ref: typeof import('vue').ref
|
|
48
|
+
const resolveComponent: typeof import('vue').resolveComponent
|
|
49
|
+
const shallowReactive: typeof import('vue').shallowReactive
|
|
50
|
+
const shallowReadonly: typeof import('vue').shallowReadonly
|
|
51
|
+
const shallowRef: typeof import('vue').shallowRef
|
|
52
|
+
const toRaw: typeof import('vue').toRaw
|
|
53
|
+
const toRef: typeof import('vue').toRef
|
|
54
|
+
const toRefs: typeof import('vue').toRefs
|
|
55
|
+
const toValue: typeof import('vue').toValue
|
|
56
|
+
const triggerRef: typeof import('vue').triggerRef
|
|
57
|
+
const unref: typeof import('vue').unref
|
|
58
|
+
const useAttrs: typeof import('vue').useAttrs
|
|
59
|
+
const useCssModule: typeof import('vue').useCssModule
|
|
60
|
+
const useCssVars: typeof import('vue').useCssVars
|
|
61
|
+
const useId: typeof import('vue').useId
|
|
62
|
+
const useLink: typeof import('vue-router').useLink
|
|
63
|
+
const useModel: typeof import('vue').useModel
|
|
64
|
+
const useRoute: typeof import('vue-router').useRoute
|
|
65
|
+
const useRouter: typeof import('vue-router').useRouter
|
|
66
|
+
const useSlots: typeof import('vue').useSlots
|
|
67
|
+
const useTemplateRef: typeof import('vue').useTemplateRef
|
|
68
|
+
const watch: typeof import('vue').watch
|
|
69
|
+
const watchEffect: typeof import('vue').watchEffect
|
|
70
|
+
const watchPostEffect: typeof import('vue').watchPostEffect
|
|
71
|
+
const watchSyncEffect: typeof import('vue').watchSyncEffect
|
|
72
|
+
}
|
|
73
|
+
// for type re-export
|
|
74
|
+
declare global {
|
|
75
|
+
// @ts-ignore
|
|
76
|
+
export type { Component, Slot, Slots, ComponentPublicInstance, ComputedRef, DirectiveBinding, ExtractDefaultPropTypes, ExtractPropTypes, ExtractPublicPropTypes, InjectionKey, PropType, Ref, ShallowRef, MaybeRef, MaybeRefOrGetter, VNode, WritableComputedRef } from 'vue'
|
|
77
|
+
import('vue')
|
|
78
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
// biome-ignore lint: disable
|
|
4
|
+
// oxlint-disable
|
|
5
|
+
// ------
|
|
6
|
+
// Generated by unplugin-vue-components
|
|
7
|
+
// Read more: https://github.com/vuejs/core/pull/3399
|
|
8
|
+
|
|
9
|
+
export {}
|
|
10
|
+
|
|
11
|
+
/* prettier-ignore */
|
|
12
|
+
declare module 'vue' {
|
|
13
|
+
export interface GlobalComponents {
|
|
14
|
+
RouterLink: typeof import('vue-router')['RouterLink']
|
|
15
|
+
RouterView: typeof import('vue-router')['RouterView']
|
|
16
|
+
SvgIcon: typeof import('./../components/Icon/svg-icon.vue')['default']
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|
|
2
|
+
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
declare module '*.vue' {
|
|
5
|
+
import type { DefineComponent } from 'vue'
|
|
6
|
+
|
|
7
|
+
const component: DefineComponent<{}, {}, any>
|
|
8
|
+
export default component
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// vite-plugin-svg-icons 类型声明
|
|
12
|
+
declare module 'virtual:svg-icons-register' {
|
|
13
|
+
const register: () => void
|
|
14
|
+
export default register
|
|
15
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 通过一个文件导出所有的环境变量这样方便统一修改
|
|
3
|
+
* @returns
|
|
4
|
+
*/
|
|
5
|
+
export const envVariables = {
|
|
6
|
+
PORT: import.meta.env.VITE_PORT,
|
|
7
|
+
PATH: import.meta.env.VITE_PATH,
|
|
8
|
+
APP_NAME: import.meta.env.VITE_APP_NAME,
|
|
9
|
+
/** 后端接口前缀 */
|
|
10
|
+
API_AFFIX: import.meta.env.VITE_API_AFFIX,
|
|
11
|
+
}
|
|
@@ -0,0 +1,425 @@
|
|
|
1
|
+
import {
|
|
2
|
+
deepMergeObject,
|
|
3
|
+
isPlainObject,
|
|
4
|
+
isReadableStream,
|
|
5
|
+
tryParseJsonString,
|
|
6
|
+
} from './utils'
|
|
7
|
+
import type {
|
|
8
|
+
AlovaGlobalCacheAdapter,
|
|
9
|
+
AlovaOptions,
|
|
10
|
+
AlovaRequestAdapter,
|
|
11
|
+
GlobalCacheConfig,
|
|
12
|
+
StatesExport,
|
|
13
|
+
StatesHook,
|
|
14
|
+
} from 'alova'
|
|
15
|
+
import { createAlova } from 'alova'
|
|
16
|
+
import type { FetchRequestInit } from 'alova/fetch'
|
|
17
|
+
import adapterFetch from 'alova/fetch'
|
|
18
|
+
|
|
19
|
+
type MaybePromise<T> = T | Promise<T>
|
|
20
|
+
type HeaderValue =
|
|
21
|
+
| string
|
|
22
|
+
| number
|
|
23
|
+
| boolean
|
|
24
|
+
| null
|
|
25
|
+
| undefined
|
|
26
|
+
| (() => MaybePromise<string | number | boolean | null | undefined>)
|
|
27
|
+
type StatusMatcher<RE> = number | number[] | ((status: number, response: RE) => boolean)
|
|
28
|
+
type CodeMatcher = Array<number | string>
|
|
29
|
+
|
|
30
|
+
export interface StatusMap<RE = unknown> {
|
|
31
|
+
success?: StatusMatcher<RE>
|
|
32
|
+
unAuthorized?: StatusMatcher<RE>
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface CodeMap {
|
|
36
|
+
success?: CodeMatcher
|
|
37
|
+
unAuthorized?: CodeMatcher
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface RequestMeta {
|
|
41
|
+
isWrapped?: boolean
|
|
42
|
+
isTransformResponse?: boolean
|
|
43
|
+
isShowSuccessMessage?: boolean
|
|
44
|
+
isShowErrorMessage?: boolean
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface BaseRequestOption<
|
|
48
|
+
RC extends object = FetchRequestInit,
|
|
49
|
+
RE = Response,
|
|
50
|
+
RH = Headers,
|
|
51
|
+
SE extends StatesExport<any> = StatesExport<any>,
|
|
52
|
+
> extends RequestMeta {
|
|
53
|
+
baseUrl?: string
|
|
54
|
+
timeout?: number
|
|
55
|
+
commonHeaders?: () => Record<string, HeaderValue>
|
|
56
|
+
statusMap?: StatusMap<RE>
|
|
57
|
+
codeMap?: CodeMap
|
|
58
|
+
responseCodeKey?: string
|
|
59
|
+
responseDataKey?: string
|
|
60
|
+
responseMessageKey?: string
|
|
61
|
+
cacheFor?: GlobalCacheConfig<any> | null
|
|
62
|
+
cacheLogger?: boolean
|
|
63
|
+
statesHook?: StatesHook<SE>
|
|
64
|
+
successDefaultMessage?: string
|
|
65
|
+
errorDefaultMessage?: string
|
|
66
|
+
successMessageFunc?: (message: string) => void
|
|
67
|
+
errorMessageFunc?: (message: string) => void
|
|
68
|
+
unAuthorizedResponseFunc?: () => void
|
|
69
|
+
requestAdapter?: AlovaRequestAdapter<RC, RE, RH>
|
|
70
|
+
l1Cache?: AlovaGlobalCacheAdapter
|
|
71
|
+
l2Cache?: AlovaGlobalCacheAdapter
|
|
72
|
+
storageAdapter?: AlovaGlobalCacheAdapter
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export type baseRequestOption<
|
|
76
|
+
RC extends object = FetchRequestInit,
|
|
77
|
+
RE = Response,
|
|
78
|
+
RH = Headers,
|
|
79
|
+
SE extends StatesExport<any> = StatesExport<any>,
|
|
80
|
+
> = BaseRequestOption<RC, RE, RH, SE>
|
|
81
|
+
|
|
82
|
+
export type RequestOption<
|
|
83
|
+
RC extends object = FetchRequestInit,
|
|
84
|
+
RE = Response,
|
|
85
|
+
RH = Headers,
|
|
86
|
+
SE extends StatesExport<any> = StatesExport<any>,
|
|
87
|
+
> = BaseRequestOption<RC, RE, RH, SE>
|
|
88
|
+
|
|
89
|
+
type RequestAlovaGenerics<RC extends object, RE, RH, SE extends StatesExport<any>> = {
|
|
90
|
+
Responded: unknown
|
|
91
|
+
Transformed: unknown
|
|
92
|
+
RequestConfig: RC
|
|
93
|
+
Response: RE
|
|
94
|
+
ResponseHeader: RH
|
|
95
|
+
L1Cache: AlovaGlobalCacheAdapter
|
|
96
|
+
L2Cache: AlovaGlobalCacheAdapter
|
|
97
|
+
StatesExport: SE
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
type ResolvedRequestOption<RC extends object, RE, RH, SE extends StatesExport<any>> = Required<
|
|
101
|
+
Pick<
|
|
102
|
+
BaseRequestOption<RC, RE, RH, SE>,
|
|
103
|
+
| 'baseUrl'
|
|
104
|
+
| 'statusMap'
|
|
105
|
+
| 'codeMap'
|
|
106
|
+
| 'responseCodeKey'
|
|
107
|
+
| 'responseDataKey'
|
|
108
|
+
| 'responseMessageKey'
|
|
109
|
+
| 'isWrapped'
|
|
110
|
+
| 'isTransformResponse'
|
|
111
|
+
| 'isShowSuccessMessage'
|
|
112
|
+
| 'successDefaultMessage'
|
|
113
|
+
| 'isShowErrorMessage'
|
|
114
|
+
| 'errorDefaultMessage'
|
|
115
|
+
| 'cacheLogger'
|
|
116
|
+
>
|
|
117
|
+
> &
|
|
118
|
+
BaseRequestOption<RC, RE, RH, SE>
|
|
119
|
+
|
|
120
|
+
const DEFAULT_SUCCESS_MESSAGE = '操作成功'
|
|
121
|
+
const DEFAULT_ERROR_MESSAGE = '服务异常'
|
|
122
|
+
|
|
123
|
+
const defaultRequestOption: BaseRequestOption<any, any, any, any> = {
|
|
124
|
+
baseUrl: '/',
|
|
125
|
+
timeout: undefined,
|
|
126
|
+
statusMap: {
|
|
127
|
+
success: 200,
|
|
128
|
+
unAuthorized: 401,
|
|
129
|
+
},
|
|
130
|
+
codeMap: {
|
|
131
|
+
success: [200],
|
|
132
|
+
unAuthorized: [401],
|
|
133
|
+
},
|
|
134
|
+
responseCodeKey: 'code',
|
|
135
|
+
responseDataKey: 'data',
|
|
136
|
+
responseMessageKey: 'message',
|
|
137
|
+
isWrapped: true,
|
|
138
|
+
isTransformResponse: true,
|
|
139
|
+
isShowSuccessMessage: false,
|
|
140
|
+
successDefaultMessage: DEFAULT_SUCCESS_MESSAGE,
|
|
141
|
+
isShowErrorMessage: true,
|
|
142
|
+
errorDefaultMessage: DEFAULT_ERROR_MESSAGE,
|
|
143
|
+
cacheFor: null,
|
|
144
|
+
cacheLogger: true,
|
|
145
|
+
requestAdapter: adapterFetch() as AlovaRequestAdapter<any, any, any>,
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function getMethodMeta(method: unknown): RequestMeta {
|
|
149
|
+
const methodRecord = method as { meta?: RequestMeta; config?: { meta?: RequestMeta } } | undefined
|
|
150
|
+
return methodRecord?.config?.meta ?? methodRecord?.meta ?? {}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function getMetaFlag(meta: RequestMeta, key: keyof RequestMeta, fallback: boolean): boolean {
|
|
154
|
+
const value = meta[key]
|
|
155
|
+
return typeof value === 'boolean' ? value : fallback
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function isMatchedStatus<RE>(
|
|
159
|
+
status: number,
|
|
160
|
+
matcher: StatusMatcher<RE> | undefined,
|
|
161
|
+
response: RE,
|
|
162
|
+
): boolean {
|
|
163
|
+
if (matcher === undefined) return status >= 200 && status < 300
|
|
164
|
+
|
|
165
|
+
if (typeof matcher === 'function') return matcher(status, response)
|
|
166
|
+
|
|
167
|
+
return Array.isArray(matcher) ? matcher.includes(status) : matcher === status
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function isMatchedCode(code: unknown, matcher: CodeMatcher | undefined): boolean {
|
|
171
|
+
if (!matcher?.length) return true
|
|
172
|
+
|
|
173
|
+
return matcher.some((item) => String(item) === String(code))
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function getResponseStatus(response: unknown): number {
|
|
177
|
+
const responseRecord = response as { status?: unknown; statusCode?: unknown }
|
|
178
|
+
const status = responseRecord.statusCode ?? responseRecord.status
|
|
179
|
+
return typeof status === 'number' ? status : Number(status)
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function getResponseMessage(data: unknown, messageKey: string, defaultMessage: string): string {
|
|
183
|
+
if (!isPlainObject(data)) return defaultMessage
|
|
184
|
+
|
|
185
|
+
const message = data[messageKey] ?? data.message ?? data.msg
|
|
186
|
+
if (typeof message === 'string') return message || defaultMessage
|
|
187
|
+
if (typeof message === 'number') return String(message)
|
|
188
|
+
|
|
189
|
+
return defaultMessage
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function getResponseField(data: unknown, key: string): unknown {
|
|
193
|
+
return isPlainObject(data) ? data[key] : undefined
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
async function parseFetchResponse(response: {
|
|
197
|
+
status?: number
|
|
198
|
+
body?: unknown
|
|
199
|
+
headers?: Headers | Record<string, unknown>
|
|
200
|
+
clone?: () => Response
|
|
201
|
+
json?: () => Promise<unknown>
|
|
202
|
+
text?: () => Promise<string>
|
|
203
|
+
}): Promise<unknown> {
|
|
204
|
+
if (response.status === 204) return undefined
|
|
205
|
+
|
|
206
|
+
const reader = typeof response.clone === 'function' ? response.clone() : response
|
|
207
|
+
const contentType = getHeaderValue(response.headers, 'content-type')
|
|
208
|
+
|
|
209
|
+
if (contentType.includes('application/json') && typeof reader.json === 'function')
|
|
210
|
+
return reader.json()
|
|
211
|
+
|
|
212
|
+
if (contentType.startsWith('text/') && typeof reader.text === 'function')
|
|
213
|
+
return tryParseJsonString(await reader.text())
|
|
214
|
+
|
|
215
|
+
if (typeof reader.json === 'function') {
|
|
216
|
+
try {
|
|
217
|
+
return await reader.json()
|
|
218
|
+
} catch {
|
|
219
|
+
// Fall through to text parsing.
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
if (typeof reader.text === 'function') return tryParseJsonString(await reader.text())
|
|
224
|
+
|
|
225
|
+
return undefined
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function getHeaderValue(
|
|
229
|
+
headers: Headers | Record<string, unknown> | undefined,
|
|
230
|
+
key: string,
|
|
231
|
+
): string {
|
|
232
|
+
if (!headers) return ''
|
|
233
|
+
|
|
234
|
+
if (typeof Headers !== 'undefined' && headers instanceof Headers) return headers.get(key) ?? ''
|
|
235
|
+
|
|
236
|
+
const headerRecord = headers as Record<string, unknown>
|
|
237
|
+
const value =
|
|
238
|
+
headerRecord[key] ?? headerRecord[key.toLowerCase()] ?? headerRecord[key.toUpperCase()]
|
|
239
|
+
return typeof value === 'string' ? value : ''
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
async function getResponseData(response: unknown): Promise<unknown> {
|
|
243
|
+
const responseRecord = response as {
|
|
244
|
+
body?: unknown
|
|
245
|
+
data?: unknown
|
|
246
|
+
json?: () => Promise<unknown>
|
|
247
|
+
text?: () => Promise<string>
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
if ('data' in responseRecord && !isReadableStream(responseRecord.body))
|
|
251
|
+
return tryParseJsonString(responseRecord.data)
|
|
252
|
+
|
|
253
|
+
if (
|
|
254
|
+
isReadableStream(responseRecord.body) ||
|
|
255
|
+
typeof responseRecord.json === 'function' ||
|
|
256
|
+
typeof responseRecord.text === 'function'
|
|
257
|
+
) {
|
|
258
|
+
return parseFetchResponse(responseRecord)
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
return response
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
async function resolveHeaderValue(value: HeaderValue): Promise<string | undefined> {
|
|
265
|
+
const resolved = typeof value === 'function' ? await value() : value
|
|
266
|
+
if (resolved === null || resolved === undefined) return undefined
|
|
267
|
+
return String(resolved)
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
function setHeader(target: unknown, key: string, value: string): void {
|
|
271
|
+
if (typeof Headers !== 'undefined' && target instanceof Headers) {
|
|
272
|
+
target.set(key, value)
|
|
273
|
+
return
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
if (Array.isArray(target)) {
|
|
277
|
+
target.push([key, value])
|
|
278
|
+
return
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
;(target as Record<string, string>)[key] = value
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
function resolveConfig<RC extends object, RE, RH, SE extends StatesExport<any>>(
|
|
285
|
+
option: BaseRequestOption<RC, RE, RH, SE>,
|
|
286
|
+
): ResolvedRequestOption<RC, RE, RH, SE> {
|
|
287
|
+
return deepMergeObject(defaultRequestOption, option) as ResolvedRequestOption<RC, RE, RH, SE>
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
export function createInstance<
|
|
291
|
+
RC extends object = FetchRequestInit,
|
|
292
|
+
RE = Response,
|
|
293
|
+
RH = Headers,
|
|
294
|
+
SE extends StatesExport<any> = StatesExport<any>,
|
|
295
|
+
>(option: RequestOption<RC, RE, RH, SE> = {}) {
|
|
296
|
+
const config = resolveConfig(option)
|
|
297
|
+
|
|
298
|
+
const alovaOptions: AlovaOptions<RequestAlovaGenerics<RC, RE, RH, SE>> = {
|
|
299
|
+
baseURL: config.baseUrl,
|
|
300
|
+
timeout: config.timeout,
|
|
301
|
+
cacheFor: config.cacheFor as GlobalCacheConfig<any>,
|
|
302
|
+
cacheLogger: config.cacheLogger,
|
|
303
|
+
statesHook: config.statesHook,
|
|
304
|
+
requestAdapter: config.requestAdapter!,
|
|
305
|
+
l1Cache: config.l1Cache,
|
|
306
|
+
l2Cache: config.l2Cache ?? config.storageAdapter,
|
|
307
|
+
beforeRequest: async (method) => {
|
|
308
|
+
const methodConfig = method.config as { headers?: unknown }
|
|
309
|
+
const headers = methodConfig.headers ?? {}
|
|
310
|
+
methodConfig.headers = headers
|
|
311
|
+
|
|
312
|
+
for (const [key, value] of Object.entries(config.commonHeaders?.() ?? {})) {
|
|
313
|
+
const resolvedValue = await resolveHeaderValue(value)
|
|
314
|
+
if (resolvedValue !== undefined) setHeader(headers, key, resolvedValue)
|
|
315
|
+
}
|
|
316
|
+
},
|
|
317
|
+
responded: {
|
|
318
|
+
onSuccess: async (response, method) => {
|
|
319
|
+
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)
|
|
323
|
+
const isWrapped = getMetaFlag(meta, 'isWrapped', config.isWrapped)
|
|
324
|
+
|
|
325
|
+
if (!shouldTransform) return response
|
|
326
|
+
|
|
327
|
+
const status = getResponseStatus(response)
|
|
328
|
+
const data = await getResponseData(response)
|
|
329
|
+
|
|
330
|
+
if (!isMatchedStatus(status, config.statusMap.success, response)) {
|
|
331
|
+
if (isMatchedStatus(status, config.statusMap.unAuthorized, response))
|
|
332
|
+
config.unAuthorizedResponseFunc?.()
|
|
333
|
+
|
|
334
|
+
if (showError) {
|
|
335
|
+
config.errorMessageFunc?.(
|
|
336
|
+
getResponseMessage(data, config.responseMessageKey, config.errorDefaultMessage),
|
|
337
|
+
)
|
|
338
|
+
}
|
|
339
|
+
return Promise.reject(response)
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
if (!isWrapped) {
|
|
343
|
+
if (showSuccess) config.successMessageFunc?.(config.successDefaultMessage)
|
|
344
|
+
return data
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
const code = getResponseField(data, config.responseCodeKey)
|
|
348
|
+
const responseData = getResponseField(data, config.responseDataKey)
|
|
349
|
+
const responseMessage = getResponseMessage(
|
|
350
|
+
data,
|
|
351
|
+
config.responseMessageKey,
|
|
352
|
+
config.successDefaultMessage,
|
|
353
|
+
)
|
|
354
|
+
|
|
355
|
+
if (!isMatchedCode(code, config.codeMap.success)) {
|
|
356
|
+
if (isMatchedCode(code, config.codeMap.unAuthorized)) config.unAuthorizedResponseFunc?.()
|
|
357
|
+
|
|
358
|
+
if (showError) {
|
|
359
|
+
config.errorMessageFunc?.(
|
|
360
|
+
getResponseMessage(data, config.responseMessageKey, config.errorDefaultMessage),
|
|
361
|
+
)
|
|
362
|
+
}
|
|
363
|
+
return Promise.reject(response)
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
if (showSuccess) config.successMessageFunc?.(responseMessage)
|
|
367
|
+
|
|
368
|
+
return responseData
|
|
369
|
+
},
|
|
370
|
+
onError: (error, method) => {
|
|
371
|
+
const meta = getMethodMeta(method)
|
|
372
|
+
const showError = getMetaFlag(meta, 'isShowErrorMessage', config.isShowErrorMessage)
|
|
373
|
+
|
|
374
|
+
if (showError) {
|
|
375
|
+
config.errorMessageFunc?.(
|
|
376
|
+
error instanceof Error ? error.message : config.errorDefaultMessage,
|
|
377
|
+
)
|
|
378
|
+
}
|
|
379
|
+
return Promise.reject(error)
|
|
380
|
+
},
|
|
381
|
+
},
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
return createAlova(alovaOptions)
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
export type RequestInstance<
|
|
388
|
+
RC extends object = FetchRequestInit,
|
|
389
|
+
RE = Response,
|
|
390
|
+
RH = Headers,
|
|
391
|
+
SE extends StatesExport<any> = StatesExport<any>,
|
|
392
|
+
> = ReturnType<typeof createInstance<RC, RE, RH, SE>>
|
|
393
|
+
|
|
394
|
+
export type DualCallInstance<
|
|
395
|
+
RC extends object = FetchRequestInit,
|
|
396
|
+
RE = Response,
|
|
397
|
+
RH = Headers,
|
|
398
|
+
SE extends StatesExport<any> = StatesExport<any>,
|
|
399
|
+
> = RequestInstance<RC, RE, RH, SE> &
|
|
400
|
+
((option?: RequestOption<RC, RE, RH, SE>) => RequestInstance<RC, RE, RH, SE>)
|
|
401
|
+
|
|
402
|
+
export function createDualCallInstance<
|
|
403
|
+
RC extends object = FetchRequestInit,
|
|
404
|
+
RE = Response,
|
|
405
|
+
RH = Headers,
|
|
406
|
+
SE extends StatesExport<any> = StatesExport<any>,
|
|
407
|
+
>(baseConfig: BaseRequestOption<RC, RE, RH, SE>): DualCallInstance<RC, RE, RH, SE> {
|
|
408
|
+
const defaultInstance = createInstance(baseConfig)
|
|
409
|
+
const dualInstance = ((option?: RequestOption<RC, RE, RH, SE>) => {
|
|
410
|
+
if (!option) return defaultInstance
|
|
411
|
+
return createInstance(deepMergeObject(baseConfig, option))
|
|
412
|
+
}) as DualCallInstance<RC, RE, RH, SE>
|
|
413
|
+
|
|
414
|
+
Object.assign(dualInstance, defaultInstance)
|
|
415
|
+
dualInstance.Get = defaultInstance.Get.bind(defaultInstance)
|
|
416
|
+
dualInstance.Post = defaultInstance.Post.bind(defaultInstance)
|
|
417
|
+
dualInstance.Put = defaultInstance.Put.bind(defaultInstance)
|
|
418
|
+
dualInstance.Delete = defaultInstance.Delete.bind(defaultInstance)
|
|
419
|
+
dualInstance.Patch = defaultInstance.Patch.bind(defaultInstance)
|
|
420
|
+
dualInstance.Head = defaultInstance.Head.bind(defaultInstance)
|
|
421
|
+
dualInstance.Options = defaultInstance.Options.bind(defaultInstance)
|
|
422
|
+
dualInstance.Request = defaultInstance.Request.bind(defaultInstance)
|
|
423
|
+
|
|
424
|
+
return dualInstance
|
|
425
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export function deepMergeObject<T = any>(source: T, target: Partial<T>): T {
|
|
2
|
+
const merge = (src: any, tgt: any): any => {
|
|
3
|
+
if (!isPlainObject(src) || !isPlainObject(tgt)) return tgt === undefined ? src : tgt
|
|
4
|
+
|
|
5
|
+
const result = { ...src }
|
|
6
|
+
for (const key of Object.keys(tgt)) {
|
|
7
|
+
const targetValue = tgt[key]
|
|
8
|
+
result[key] = isPlainObject(targetValue) ? merge(result[key], targetValue) : targetValue
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
return result
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return merge(source, target)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function isPlainObject(data: unknown): data is Record<string, any> {
|
|
18
|
+
return Object.prototype.toString.call(data) === '[object Object]'
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function isReadableStream(data: unknown): boolean {
|
|
22
|
+
if (typeof ReadableStream === 'undefined') return false
|
|
23
|
+
return data instanceof ReadableStream
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function tryParseJsonString(data: unknown): unknown {
|
|
27
|
+
if (typeof data !== 'string') return data
|
|
28
|
+
|
|
29
|
+
const value = data.trim()
|
|
30
|
+
if (!value) return data
|
|
31
|
+
|
|
32
|
+
if (!value.startsWith('{') && !value.startsWith('[')) return data
|
|
33
|
+
|
|
34
|
+
try {
|
|
35
|
+
return JSON.parse(value)
|
|
36
|
+
} catch {
|
|
37
|
+
return data
|
|
38
|
+
}
|
|
39
|
+
}
|