@moluoxixi/create-app 2.0.4 → 2.0.403
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/LICENSE.txt +21 -21
- package/README.md +129 -129
- package/dist/commands/create.d.ts +2 -1
- package/dist/commands/create.js +12 -8
- package/dist/commands/index.d.ts +1 -2
- package/dist/commands/index.js +1 -2
- package/dist/constants/index.d.ts +17 -0
- package/dist/constants/index.js +17 -0
- package/dist/generators/index.d.ts +3 -4
- package/dist/generators/index.js +3 -4
- package/dist/generators/project.d.ts +3 -2
- package/dist/generators/project.js +5 -4
- package/dist/generators/react.d.ts +4 -2
- package/dist/generators/react.js +10 -30
- package/dist/generators/vue.d.ts +4 -2
- package/dist/generators/vue.js +10 -31
- package/dist/index.d.ts +0 -1
- package/dist/index.js +21 -3
- package/dist/test.d.ts +5 -2
- package/dist/test.js +252 -206
- package/dist/types/ejs.d.ts +0 -1
- package/dist/types/ejs.js +0 -1
- package/dist/types/features.d.ts +1 -2
- package/dist/types/features.js +1 -1
- package/dist/types/index.d.ts +2 -4
- package/dist/types/index.js +2 -4
- package/dist/types/packageJson.d.ts +24 -0
- package/dist/types/packageJson.js +4 -0
- package/dist/types/viteConfig.d.ts +11 -9
- package/dist/types/viteConfig.js +0 -1
- package/dist/utils/deepMerge.d.ts +3 -1
- package/dist/utils/deepMerge.js +8 -1
- package/dist/utils/ejs.d.ts +3 -2
- package/dist/utils/ejs.js +2 -1
- package/dist/utils/featureMapping.d.ts +44 -0
- package/dist/utils/featureMapping.js +119 -0
- package/dist/utils/file.d.ts +22 -2
- package/dist/utils/file.js +35 -2
- package/dist/utils/generateFrameworkProject.d.ts +27 -0
- package/dist/utils/generateFrameworkProject.js +47 -0
- package/dist/utils/index.d.ts +11 -9
- package/dist/utils/index.js +11 -9
- package/dist/utils/install.d.ts +7 -4
- package/dist/utils/install.js +55 -12
- package/dist/utils/npmConfig.d.ts +15 -0
- package/dist/utils/npmConfig.js +79 -0
- package/dist/utils/prompts.d.ts +3 -2
- package/dist/utils/prompts.js +51 -5
- package/dist/utils/renderFeatures.d.ts +3 -2
- package/dist/utils/renderFeatures.js +41 -37
- package/dist/utils/renderTemplate.d.ts +13 -1
- package/dist/utils/renderTemplate.js +128 -61
- package/dist/utils/sortDependencies.d.ts +3 -2
- package/dist/utils/sortDependencies.js +3 -2
- package/dist/utils/viteConfigRender.d.ts +11 -14
- package/dist/utils/viteConfigRender.js +10 -173
- package/package.json +4 -2
- package/templates/common/base/.env +7 -7
- package/templates/common/base/.env.development +5 -5
- package/templates/common/base/.env.production +5 -5
- package/templates/common/base/package.json +23 -27
- package/templates/common/base/scripts/build.mts +37 -31
- package/templates/common/base/src/apis/index.ts +8 -8
- package/templates/common/base/src/apis/request.ts +43 -43
- package/templates/common/base/src/apis/services/example.ts +61 -40
- package/templates/common/base/src/apis/services/user.ts +33 -23
- package/templates/common/base/src/apis/types/common.ts +43 -28
- package/templates/common/base/src/apis/types/example.ts +15 -3
- package/templates/common/base/src/apis/types/index.ts +7 -7
- package/templates/common/base/src/apis/types/user.ts +39 -24
- package/templates/common/base/src/assets/fonts/index.css +7 -7
- package/templates/common/base/src/assets/styles/base.scss +72 -72
- package/templates/common/base/src/assets/styles/custom.scss +7 -7
- package/templates/common/base/src/assets/styles/tailwind.scss +6 -6
- package/templates/common/base/src/constants/index.ts +29 -29
- package/templates/common/base/src/utils/index.ts +88 -83
- package/templates/{vue/base/vite.config.ts → common/base/vite.config.ts.ejs} +28 -11
- package/templates/common/features/husky/.cz-config.cjs +35 -35
- package/templates/common/features/husky/commitlint.config.ts +32 -32
- package/templates/common/features/husky/node_modules/.bin/commitizen +17 -0
- package/templates/common/features/husky/node_modules/.bin/commitizen.CMD +12 -0
- package/templates/common/features/husky/node_modules/.bin/commitizen.ps1 +41 -0
- package/templates/common/features/husky/node_modules/.bin/commitlint +17 -0
- package/templates/common/features/husky/node_modules/.bin/commitlint.CMD +12 -0
- package/templates/common/features/husky/node_modules/.bin/commitlint.ps1 +41 -0
- package/templates/common/features/husky/node_modules/.bin/cz +17 -0
- package/templates/common/features/husky/node_modules/.bin/cz-cust +17 -0
- package/templates/common/features/husky/node_modules/.bin/cz-cust.CMD +12 -0
- package/templates/common/features/husky/node_modules/.bin/cz-cust.ps1 +41 -0
- package/templates/common/features/husky/node_modules/.bin/cz-customizable +17 -0
- package/templates/common/features/husky/node_modules/.bin/cz-customizable.CMD +12 -0
- package/templates/common/features/husky/node_modules/.bin/cz-customizable.ps1 +41 -0
- package/templates/common/features/husky/node_modules/.bin/cz.CMD +12 -0
- package/templates/common/features/husky/node_modules/.bin/cz.ps1 +41 -0
- package/templates/common/features/husky/node_modules/.bin/git-cz +17 -0
- package/templates/common/features/husky/node_modules/.bin/git-cz.CMD +12 -0
- package/templates/common/features/husky/node_modules/.bin/git-cz.ps1 +41 -0
- package/templates/common/features/husky/node_modules/.bin/husky +17 -0
- package/templates/common/features/husky/node_modules/.bin/husky.CMD +12 -0
- package/templates/common/features/husky/node_modules/.bin/husky.ps1 +41 -0
- package/templates/common/features/husky/node_modules/.bin/lint-staged +17 -0
- package/templates/common/features/husky/node_modules/.bin/lint-staged.CMD +12 -0
- package/templates/common/features/husky/node_modules/.bin/lint-staged.ps1 +41 -0
- package/templates/common/features/husky/package.json +6 -6
- package/templates/react/base/env.d.ts +19 -19
- package/templates/react/base/index.html +14 -14
- package/templates/react/base/node_modules/.bin/vite +17 -0
- package/templates/react/base/node_modules/.bin/vite.CMD +12 -0
- package/templates/react/base/node_modules/.bin/vite.ps1 +41 -0
- package/templates/react/base/package.json +18 -15
- package/templates/react/base/src/App.tsx +18 -18
- package/templates/react/base/src/assets/styles/main.scss +8 -8
- package/templates/react/base/src/main.tsx.ejs +51 -6
- package/templates/react/base/src/pages/about/index.tsx +14 -14
- package/templates/react/base/src/pages/home/index.tsx +14 -14
- package/templates/react/base/tsconfig.app.json +17 -17
- package/templates/react/base/tsconfig.base.json +23 -23
- package/templates/react/base/tsconfig.json +12 -12
- package/templates/react/base/tsconfig.node.json +15 -15
- package/templates/react/features/ant-design/package.json +6 -7
- package/templates/react/features/eslint/node_modules/.bin/eslint +17 -0
- package/templates/react/features/eslint/node_modules/.bin/eslint.CMD +12 -0
- package/templates/react/features/eslint/node_modules/.bin/eslint.ps1 +41 -0
- package/templates/react/features/eslint/package.json +3 -3
- package/templates/react/features/i18n/package.json +6 -7
- package/templates/react/features/i18n/src/locales/index.ts +7 -0
- package/templates/{common/base → react/features/i18n}/src/locales/lang/en.ts +30 -30
- package/templates/{common/base → react/features/i18n}/src/locales/lang/es.ts +30 -30
- package/templates/{common/base → react/features/i18n}/src/locales/lang/zh.ts +30 -30
- package/templates/react/features/manualRoutes/src/router/routes.tsx +13 -0
- package/templates/react/features/pageRoutes/package.json +1 -2
- package/templates/react/features/qiankun/package.json +6 -0
- package/templates/react/features/qiankun/src/qiankun/index.ts +80 -0
- package/templates/react/features/router/package.json +1 -1
- package/templates/react/features/sentry/package.json +6 -7
- package/templates/react/features/sentry/src/utils/sentry.ts +10 -0
- package/templates/react/features/zustand/package.json +1 -1
- package/templates/react/features/zustand/src/stores/user.ts +42 -6
- package/templates/react/features/zustand/src/types/stores.ts +8 -1
- package/templates/vue/base/env.d.ts +27 -27
- package/templates/vue/base/index.html +14 -14
- package/templates/vue/base/node_modules/.bin/vite +17 -0
- package/templates/vue/base/node_modules/.bin/vite.CMD +12 -0
- package/templates/vue/base/node_modules/.bin/vite.ps1 +41 -0
- package/templates/vue/base/node_modules/.bin/vue-tsc +17 -0
- package/templates/vue/base/node_modules/.bin/vue-tsc.CMD +12 -0
- package/templates/vue/base/node_modules/.bin/vue-tsc.ps1 +41 -0
- package/templates/vue/base/package.json +16 -13
- package/templates/vue/base/src/App.vue +13 -13
- package/templates/vue/base/src/assets/styles/main.scss +9 -9
- package/templates/vue/base/src/directives/index.ts +36 -36
- package/templates/vue/base/src/layouts/index.ts +5 -7
- package/templates/vue/base/src/main.ts.ejs +9 -25
- package/templates/vue/base/src/pages/about/index.vue +31 -31
- package/templates/vue/base/src/pages/home/index.vue +31 -31
- package/templates/vue/base/src/router/index.ts.ejs +10 -13
- package/templates/vue/base/tsconfig.app.json +17 -17
- package/templates/vue/base/tsconfig.base.json +23 -23
- package/templates/vue/base/tsconfig.json +12 -12
- package/templates/vue/base/tsconfig.node.json +15 -15
- package/templates/vue/features/ant-design-vue/package.json +6 -7
- package/templates/vue/{base → features/ant-design-vue}/src/layouts/AntDesign.vue +86 -86
- package/templates/vue/features/element-plus/package.json +6 -7
- package/templates/vue/{base → features/element-plus}/src/assets/styles/element/index.scss +27 -27
- package/templates/vue/features/element-plus/src/components/SubMenu/index.ts +9 -0
- package/templates/vue/{base → features/element-plus}/src/components/SubMenu/src/_types/index.ts +6 -6
- package/templates/vue/{base → features/element-plus}/src/components/SubMenu/src/_types/props.ts +11 -11
- package/templates/vue/{base → features/element-plus}/src/components/SubMenu/src/index.vue +24 -24
- package/templates/vue/{base → features/element-plus}/src/layouts/element.vue +81 -81
- package/templates/vue/features/eslint/node_modules/.bin/eslint +17 -0
- package/templates/vue/features/eslint/node_modules/.bin/eslint.CMD +12 -0
- package/templates/vue/features/eslint/node_modules/.bin/eslint.ps1 +41 -0
- package/templates/vue/features/eslint/package.json +3 -3
- package/templates/vue/features/i18n/package.json +5 -5
- package/templates/vue/features/i18n/src/locales/index.ts +23 -16
- package/templates/vue/features/i18n/src/locales/lang/en.ts +30 -0
- package/templates/vue/features/i18n/src/locales/lang/es.ts +30 -0
- package/templates/vue/features/i18n/src/locales/lang/zh.ts +30 -0
- package/templates/vue/features/manualRoutes/src/router/routes.ts +35 -27
- package/templates/vue/features/pageRoutes/package.json +5 -5
- package/templates/vue/features/pinia/package.json +3 -2
- package/templates/vue/features/pinia/src/stores/index.ts +8 -0
- package/templates/vue/features/pinia/src/stores/system.ts +60 -0
- package/templates/vue/features/pinia/src/stores/user.ts +33 -13
- package/templates/vue/features/qiankun/package.json +5 -5
- package/templates/vue/features/qiankun/src/qiankun/index.ts +19 -0
- package/templates/vue/features/router/package.json +1 -1
- package/templates/vue/features/sentry/package.json +6 -6
- package/templates/vue/features/sentry/src/utils/sentry.ts +12 -0
- package/dist/commands/create.d.ts.map +0 -1
- package/dist/commands/create.js.map +0 -1
- package/dist/commands/index.d.ts.map +0 -1
- package/dist/commands/index.js.map +0 -1
- package/dist/generators/index.d.ts.map +0 -1
- package/dist/generators/index.js.map +0 -1
- package/dist/generators/project.d.ts.map +0 -1
- package/dist/generators/project.js.map +0 -1
- package/dist/generators/react.d.ts.map +0 -1
- package/dist/generators/react.js.map +0 -1
- package/dist/generators/vue.d.ts.map +0 -1
- package/dist/generators/vue.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/test.d.ts.map +0 -1
- package/dist/test.js.map +0 -1
- package/dist/types/ejs.d.ts.map +0 -1
- package/dist/types/ejs.js.map +0 -1
- package/dist/types/features.d.ts.map +0 -1
- package/dist/types/features.js.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js.map +0 -1
- package/dist/types/viteConfig.d.ts.map +0 -1
- package/dist/types/viteConfig.js.map +0 -1
- package/dist/utils/deepMerge.d.ts.map +0 -1
- package/dist/utils/deepMerge.js.map +0 -1
- package/dist/utils/ejs.d.ts.map +0 -1
- package/dist/utils/ejs.js.map +0 -1
- package/dist/utils/file.d.ts.map +0 -1
- package/dist/utils/file.js.map +0 -1
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/install.d.ts.map +0 -1
- package/dist/utils/install.js.map +0 -1
- package/dist/utils/prompts.d.ts.map +0 -1
- package/dist/utils/prompts.js.map +0 -1
- package/dist/utils/renderFeatures.d.ts.map +0 -1
- package/dist/utils/renderFeatures.js.map +0 -1
- package/dist/utils/renderTemplate.d.ts.map +0 -1
- package/dist/utils/renderTemplate.js.map +0 -1
- package/dist/utils/sortDependencies.d.ts.map +0 -1
- package/dist/utils/sortDependencies.js.map +0 -1
- package/dist/utils/viteConfigRender.d.ts.map +0 -1
- package/dist/utils/viteConfigRender.js.map +0 -1
- package/templates/common/base/pnpm-workspace.yaml +0 -37
- package/templates/common/features/husky/pnpm-workspace.yaml +0 -9
- package/templates/react/base/pnpm-workspace.yaml +0 -9
- package/templates/react/base/src/stores/user.ts +0 -39
- package/templates/react/base/vite.config.ts +0 -52
- package/templates/react/features/ant-design/pnpm-workspace.yaml +0 -5
- package/templates/react/features/eslint/pnpm-workspace.yaml +0 -6
- package/templates/react/features/i18n/pnpm-workspace.yaml +0 -5
- package/templates/react/features/pageRoutes/pnpm-workspace.yaml +0 -4
- package/templates/react/features/pageRoutes/vite.config.data.ts +0 -10
- package/templates/react/features/router/pnpm-workspace.yaml +0 -3
- package/templates/react/features/sentry/pnpm-workspace.yaml +0 -5
- package/templates/react/features/sentry/vite.config.data.ts +0 -23
- package/templates/react/features/zustand/pnpm-workspace.yaml +0 -3
- package/templates/vue/base/pnpm-workspace.yaml +0 -6
- package/templates/vue/base/src/components/SubMenu/index.ts +0 -9
- package/templates/vue/base/src/stores/index.ts +0 -16
- package/templates/vue/base/src/stores/modules/system.ts +0 -52
- package/templates/vue/base/src/stores/modules/user.ts +0 -48
- package/templates/vue/features/ant-design-vue/pnpm-workspace.yaml +0 -5
- package/templates/vue/features/element-plus/pnpm-workspace.yaml +0 -5
- package/templates/vue/features/element-plus/vite.config.data.ts +0 -15
- package/templates/vue/features/eslint/pnpm-workspace.yaml +0 -6
- package/templates/vue/features/i18n/pnpm-workspace.yaml +0 -3
- package/templates/vue/features/pageRoutes/pnpm-workspace.yaml +0 -4
- package/templates/vue/features/pageRoutes/vite.config.data.ts +0 -9
- package/templates/vue/features/pinia/pnpm-workspace.yaml +0 -4
- package/templates/vue/features/qiankun/pnpm-workspace.yaml +0 -3
- package/templates/vue/features/router/pnpm-workspace.yaml +0 -3
- package/templates/vue/features/sentry/pnpm-workspace.yaml +0 -4
- package/templates/vue/features/sentry/vite.config.data.ts +0 -23
|
@@ -1,31 +1,37 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 构建后处理脚本
|
|
3
|
-
* 打包生成的 dist 目录为 zip 文件
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import path from 'node:path';
|
|
7
|
-
import process from 'node:process';
|
|
8
|
-
import compressing from 'compressing';
|
|
9
|
-
import dotenv from 'dotenv';
|
|
10
|
-
|
|
11
|
-
// 加载环境变量
|
|
12
|
-
dotenv.config({ path: '.env.production' });
|
|
13
|
-
|
|
14
|
-
const appCode = process.env.VITE_APP_CODE || 'app';
|
|
15
|
-
const rootPath = path.resolve();
|
|
16
|
-
const distPath = path.join(rootPath, 'dist');
|
|
17
|
-
const outputPath = path.join(rootPath, `${appCode}.zip`);
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
1
|
+
/**
|
|
2
|
+
* 构建后处理脚本
|
|
3
|
+
* 打包生成的 dist 目录为 zip 文件
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
import process from 'node:process';
|
|
8
|
+
import compressing from 'compressing';
|
|
9
|
+
import dotenv from 'dotenv';
|
|
10
|
+
|
|
11
|
+
// 加载环境变量
|
|
12
|
+
dotenv.config({ path: '.env.production' });
|
|
13
|
+
|
|
14
|
+
const appCode = process.env.VITE_APP_CODE || 'app';
|
|
15
|
+
const rootPath = path.resolve();
|
|
16
|
+
const distPath = path.join(rootPath, 'dist');
|
|
17
|
+
const outputPath = path.join(rootPath, `${appCode}.zip`);
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 构建 ZIP 压缩包
|
|
21
|
+
* 将 dist 目录压缩为 zip 文件
|
|
22
|
+
* @returns Promise<void>
|
|
23
|
+
* @throws {Error} 如果压缩失败
|
|
24
|
+
*/
|
|
25
|
+
async function buildZip(): Promise<void> {
|
|
26
|
+
try {
|
|
27
|
+
console.log(`📦 Compressing ${distPath} to ${outputPath}...`);
|
|
28
|
+
await compressing.zip.compressDir(distPath, outputPath);
|
|
29
|
+
console.log(`✅ Successfully created ${outputPath}`);
|
|
30
|
+
} catch (error) {
|
|
31
|
+
console.error('❌ Failed to compress:', error);
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
buildZip();
|
|
37
|
+
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* API 服务导出
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
export * from './services/user';
|
|
6
|
-
export * from './services/example';
|
|
7
|
-
export * from './types';
|
|
8
|
-
|
|
1
|
+
/**
|
|
2
|
+
* API 服务导出
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export * from './services/user';
|
|
6
|
+
export * from './services/example';
|
|
7
|
+
export * from './types';
|
|
8
|
+
|
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 请求封装
|
|
3
|
-
* 基于 @moluoxixi/ajax-package 的请求工具
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { createRequest } from '@moluoxixi/ajax-package'
|
|
7
|
-
|
|
8
|
-
/** 请求实例 */
|
|
9
|
-
export const request = createRequest({
|
|
10
|
-
baseURL: import.meta.env.VITE_API_BASE_URL,
|
|
11
|
-
timeout: 30000,
|
|
12
|
-
headers: {
|
|
13
|
-
'Content-Type': 'application/json',
|
|
14
|
-
},
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
/** 请求拦截器 */
|
|
18
|
-
request.interceptors.request.use(
|
|
19
|
-
(config) => {
|
|
20
|
-
const token = localStorage.getItem('token')
|
|
21
|
-
if (token) {
|
|
22
|
-
config.headers.Authorization = `Bearer ${token}`
|
|
23
|
-
}
|
|
24
|
-
return config
|
|
25
|
-
},
|
|
26
|
-
(error) => {
|
|
27
|
-
return Promise.reject(error)
|
|
28
|
-
},
|
|
29
|
-
)
|
|
30
|
-
|
|
31
|
-
/** 响应拦截器 */
|
|
32
|
-
request.interceptors.response.use(
|
|
33
|
-
(response) => {
|
|
34
|
-
return response.data
|
|
35
|
-
},
|
|
36
|
-
(error) => {
|
|
37
|
-
// 统一错误处理
|
|
38
|
-
console.error('Request error:', error)
|
|
39
|
-
return Promise.reject(error)
|
|
40
|
-
},
|
|
41
|
-
)
|
|
42
|
-
|
|
43
|
-
export default request
|
|
1
|
+
/**
|
|
2
|
+
* 请求封装
|
|
3
|
+
* 基于 @moluoxixi/ajax-package 的请求工具
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { createRequest } from '@moluoxixi/ajax-package'
|
|
7
|
+
|
|
8
|
+
/** 请求实例 */
|
|
9
|
+
export const request = createRequest({
|
|
10
|
+
baseURL: import.meta.env.VITE_API_BASE_URL,
|
|
11
|
+
timeout: 30000,
|
|
12
|
+
headers: {
|
|
13
|
+
'Content-Type': 'application/json',
|
|
14
|
+
},
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
/** 请求拦截器 */
|
|
18
|
+
request.interceptors.request.use(
|
|
19
|
+
(config) => {
|
|
20
|
+
const token = localStorage.getItem('token')
|
|
21
|
+
if (token) {
|
|
22
|
+
config.headers.Authorization = `Bearer ${token}`
|
|
23
|
+
}
|
|
24
|
+
return config
|
|
25
|
+
},
|
|
26
|
+
(error) => {
|
|
27
|
+
return Promise.reject(error)
|
|
28
|
+
},
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
/** 响应拦截器 */
|
|
32
|
+
request.interceptors.response.use(
|
|
33
|
+
(response) => {
|
|
34
|
+
return response.data
|
|
35
|
+
},
|
|
36
|
+
(error) => {
|
|
37
|
+
// 统一错误处理
|
|
38
|
+
console.error('Request error:', error)
|
|
39
|
+
return Promise.reject(error)
|
|
40
|
+
},
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
export default request
|
|
@@ -1,40 +1,61 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 示例服务
|
|
3
|
-
* 示例 API 接口
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import type {
|
|
7
|
-
ApiResponseType,
|
|
8
|
-
CreateExampleParamsType,
|
|
9
|
-
ExampleItemType,
|
|
10
|
-
ListResponseType,
|
|
11
|
-
PaginationParamsType,
|
|
12
|
-
UpdateExampleParamsType,
|
|
13
|
-
} from '../types'
|
|
14
|
-
|
|
15
|
-
import request from '../request'
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
1
|
+
/**
|
|
2
|
+
* 示例服务
|
|
3
|
+
* 示例 API 接口
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type {
|
|
7
|
+
ApiResponseType,
|
|
8
|
+
CreateExampleParamsType,
|
|
9
|
+
ExampleItemType,
|
|
10
|
+
ListResponseType,
|
|
11
|
+
PaginationParamsType,
|
|
12
|
+
UpdateExampleParamsType,
|
|
13
|
+
} from '../types'
|
|
14
|
+
|
|
15
|
+
import request from '../request'
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 获取示例列表
|
|
19
|
+
* @param params 分页参数
|
|
20
|
+
* @returns 示例列表响应
|
|
21
|
+
*/
|
|
22
|
+
export function getExampleList(params: PaginationParamsType): Promise<ListResponseType<ExampleItemType>> {
|
|
23
|
+
return request.get('/example/list', { params })
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 获取示例详情
|
|
28
|
+
* @param id 示例 ID
|
|
29
|
+
* @returns 示例详情响应
|
|
30
|
+
*/
|
|
31
|
+
export function getExampleDetail(id: string): Promise<ApiResponseType<ExampleItemType>> {
|
|
32
|
+
return request.get(`/example/${id}`)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* 创建示例
|
|
37
|
+
* @param data 创建参数
|
|
38
|
+
* @returns 创建结果响应
|
|
39
|
+
*/
|
|
40
|
+
export function createExample(data: CreateExampleParamsType): Promise<ApiResponseType<ExampleItemType>> {
|
|
41
|
+
return request.post('/example', data)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* 更新示例
|
|
46
|
+
* @param id 示例 ID
|
|
47
|
+
* @param data 更新参数
|
|
48
|
+
* @returns 更新结果响应
|
|
49
|
+
*/
|
|
50
|
+
export function updateExample(id: string, data: UpdateExampleParamsType): Promise<ApiResponseType<ExampleItemType>> {
|
|
51
|
+
return request.put(`/example/${id}`, data)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* 删除示例
|
|
56
|
+
* @param id 示例 ID
|
|
57
|
+
* @returns 删除结果响应
|
|
58
|
+
*/
|
|
59
|
+
export function deleteExample(id: string): Promise<ApiResponseType<null>> {
|
|
60
|
+
return request.delete(`/example/${id}`)
|
|
61
|
+
}
|
|
@@ -1,23 +1,33 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 用户服务
|
|
3
|
-
* 用户相关 API
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import type { ApiResponseType, LoginParamsType, LoginResponseType, UserInfoType } from '../types'
|
|
7
|
-
|
|
8
|
-
import request from '../request'
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
/**
|
|
2
|
+
* 用户服务
|
|
3
|
+
* 用户相关 API
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { ApiResponseType, LoginParamsType, LoginResponseType, UserInfoType } from '../types'
|
|
7
|
+
|
|
8
|
+
import request from '../request'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 用户登录
|
|
12
|
+
* @param params 登录参数
|
|
13
|
+
* @returns 登录响应(包含 token 和用户信息)
|
|
14
|
+
*/
|
|
15
|
+
export function login(params: LoginParamsType): Promise<ApiResponseType<LoginResponseType>> {
|
|
16
|
+
return request.post('/auth/login', params)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 获取用户信息
|
|
21
|
+
* @returns 用户信息响应
|
|
22
|
+
*/
|
|
23
|
+
export function getUserInfo(): Promise<ApiResponseType<UserInfoType>> {
|
|
24
|
+
return request.get('/user/info')
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* 用户登出
|
|
29
|
+
* @returns 登出响应
|
|
30
|
+
*/
|
|
31
|
+
export function logout(): Promise<ApiResponseType<null>> {
|
|
32
|
+
return request.post('/auth/logout')
|
|
33
|
+
}
|
|
@@ -1,28 +1,43 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 通用类型定义
|
|
3
|
-
* API 响应通用类型
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
1
|
+
/**
|
|
2
|
+
* 通用类型定义
|
|
3
|
+
* API 响应通用类型
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 分页参数类型
|
|
8
|
+
*/
|
|
9
|
+
export interface PaginationParamsType {
|
|
10
|
+
/** 页码 */
|
|
11
|
+
page: number
|
|
12
|
+
/** 每页数量 */
|
|
13
|
+
pageSize: number
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 分页响应类型
|
|
18
|
+
*/
|
|
19
|
+
export interface PaginationResponseType<T> {
|
|
20
|
+
/** 数据列表 */
|
|
21
|
+
list: T[]
|
|
22
|
+
/** 总记录数 */
|
|
23
|
+
total: number
|
|
24
|
+
/** 当前页码 */
|
|
25
|
+
page: number
|
|
26
|
+
/** 每页数量 */
|
|
27
|
+
pageSize: number
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* 通用响应类型
|
|
32
|
+
*/
|
|
33
|
+
export interface ApiResponseType<T = unknown> {
|
|
34
|
+
/** 响应码 */
|
|
35
|
+
code: number
|
|
36
|
+
/** 响应消息 */
|
|
37
|
+
message: string
|
|
38
|
+
/** 响应数据 */
|
|
39
|
+
data: T
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** 列表响应类型 */
|
|
43
|
+
export interface ListResponseType<T> extends ApiResponseType<PaginationResponseType<T>> {}
|
|
@@ -2,17 +2,29 @@
|
|
|
2
2
|
* 示例类型定义
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* 示例数据类型
|
|
7
|
+
*/
|
|
6
8
|
export interface ExampleItemType {
|
|
9
|
+
/** 示例 ID */
|
|
7
10
|
id: string
|
|
11
|
+
/** 示例名称 */
|
|
8
12
|
name: string
|
|
13
|
+
/** 示例描述 */
|
|
9
14
|
description: string
|
|
15
|
+
/** 创建时间 */
|
|
10
16
|
createdAt: string
|
|
11
17
|
}
|
|
12
18
|
|
|
13
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* 创建示例参数类型
|
|
21
|
+
* 排除 id 和 createdAt 字段
|
|
22
|
+
*/
|
|
14
23
|
export type CreateExampleParamsType = Omit<ExampleItemType, 'id' | 'createdAt'>
|
|
15
24
|
|
|
16
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* 更新示例参数类型
|
|
27
|
+
* 所有字段可选
|
|
28
|
+
*/
|
|
17
29
|
export type UpdateExampleParamsType = Partial<ExampleItemType>
|
|
18
30
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* API 类型导出
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
export * from './common'
|
|
6
|
-
export * from './example'
|
|
7
|
-
export * from './user'
|
|
1
|
+
/**
|
|
2
|
+
* API 类型导出
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export * from './common'
|
|
6
|
+
export * from './example'
|
|
7
|
+
export * from './user'
|
|
@@ -1,24 +1,39 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 用户类型定义
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
1
|
+
/**
|
|
2
|
+
* 用户类型定义
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 用户信息类型
|
|
7
|
+
*/
|
|
8
|
+
export interface UserInfoType {
|
|
9
|
+
/** 用户 ID */
|
|
10
|
+
id: string
|
|
11
|
+
/** 用户名 */
|
|
12
|
+
username: string
|
|
13
|
+
/** 邮箱 */
|
|
14
|
+
email: string
|
|
15
|
+
/** 头像 URL(可选) */
|
|
16
|
+
avatar?: string
|
|
17
|
+
/** 角色列表 */
|
|
18
|
+
roles: string[]
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 登录参数类型
|
|
23
|
+
*/
|
|
24
|
+
export interface LoginParamsType {
|
|
25
|
+
/** 用户名 */
|
|
26
|
+
username: string
|
|
27
|
+
/** 密码 */
|
|
28
|
+
password: string
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 登录响应类型
|
|
33
|
+
*/
|
|
34
|
+
export interface LoginResponseType {
|
|
35
|
+
/** 认证 token */
|
|
36
|
+
token: string
|
|
37
|
+
/** 用户信息 */
|
|
38
|
+
userInfo: UserInfoType
|
|
39
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 字体配置
|
|
3
|
-
* 自定义字体导入
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/* 可在此添加自定义字体 */
|
|
7
|
-
|
|
1
|
+
/**
|
|
2
|
+
* 字体配置
|
|
3
|
+
* 自定义字体导入
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/* 可在此添加自定义字体 */
|
|
7
|
+
|
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 基础样式
|
|
3
|
-
* CSS Reset 和全局基础样式
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
*,
|
|
7
|
-
*::before,
|
|
8
|
-
*::after {
|
|
9
|
-
box-sizing: border-box;
|
|
10
|
-
margin: 0;
|
|
11
|
-
padding: 0;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
html {
|
|
15
|
-
font-size: 16px;
|
|
16
|
-
line-height: 1.5;
|
|
17
|
-
-webkit-font-smoothing: antialiased;
|
|
18
|
-
-moz-osx-font-smoothing: grayscale;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
body {
|
|
22
|
-
min-height: 100vh;
|
|
23
|
-
font-family:
|
|
24
|
-
-apple-system,
|
|
25
|
-
BlinkMacSystemFont,
|
|
26
|
-
'Segoe UI',
|
|
27
|
-
Roboto,
|
|
28
|
-
'Helvetica Neue',
|
|
29
|
-
Arial,
|
|
30
|
-
sans-serif;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
img,
|
|
34
|
-
picture,
|
|
35
|
-
video,
|
|
36
|
-
canvas,
|
|
37
|
-
svg {
|
|
38
|
-
display: block;
|
|
39
|
-
max-width: 100%;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
input,
|
|
43
|
-
button,
|
|
44
|
-
textarea,
|
|
45
|
-
select {
|
|
46
|
-
font: inherit;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
p,
|
|
50
|
-
h1,
|
|
51
|
-
h2,
|
|
52
|
-
h3,
|
|
53
|
-
h4,
|
|
54
|
-
h5,
|
|
55
|
-
h6 {
|
|
56
|
-
overflow-wrap: break-word;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
a {
|
|
60
|
-
color: inherit;
|
|
61
|
-
text-decoration: none;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
ul,
|
|
65
|
-
ol {
|
|
66
|
-
list-style: none;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
#app {
|
|
70
|
-
min-height: 100vh;
|
|
71
|
-
}
|
|
72
|
-
|
|
1
|
+
/**
|
|
2
|
+
* 基础样式
|
|
3
|
+
* CSS Reset 和全局基础样式
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
*,
|
|
7
|
+
*::before,
|
|
8
|
+
*::after {
|
|
9
|
+
box-sizing: border-box;
|
|
10
|
+
margin: 0;
|
|
11
|
+
padding: 0;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
html {
|
|
15
|
+
font-size: 16px;
|
|
16
|
+
line-height: 1.5;
|
|
17
|
+
-webkit-font-smoothing: antialiased;
|
|
18
|
+
-moz-osx-font-smoothing: grayscale;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
body {
|
|
22
|
+
min-height: 100vh;
|
|
23
|
+
font-family:
|
|
24
|
+
-apple-system,
|
|
25
|
+
BlinkMacSystemFont,
|
|
26
|
+
'Segoe UI',
|
|
27
|
+
Roboto,
|
|
28
|
+
'Helvetica Neue',
|
|
29
|
+
Arial,
|
|
30
|
+
sans-serif;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
img,
|
|
34
|
+
picture,
|
|
35
|
+
video,
|
|
36
|
+
canvas,
|
|
37
|
+
svg {
|
|
38
|
+
display: block;
|
|
39
|
+
max-width: 100%;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
input,
|
|
43
|
+
button,
|
|
44
|
+
textarea,
|
|
45
|
+
select {
|
|
46
|
+
font: inherit;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
p,
|
|
50
|
+
h1,
|
|
51
|
+
h2,
|
|
52
|
+
h3,
|
|
53
|
+
h4,
|
|
54
|
+
h5,
|
|
55
|
+
h6 {
|
|
56
|
+
overflow-wrap: break-word;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
a {
|
|
60
|
+
color: inherit;
|
|
61
|
+
text-decoration: none;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
ul,
|
|
65
|
+
ol {
|
|
66
|
+
list-style: none;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
#app {
|
|
70
|
+
min-height: 100vh;
|
|
71
|
+
}
|
|
72
|
+
|