@chenhui996/gg-cli 1.0.3 → 1.0.4

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 (31) hide show
  1. package/dist/template/operations-tem/.editorconfig +16 -0
  2. package/dist/template/operations-tem/.env.development +4 -0
  3. package/dist/template/operations-tem/.env.production +4 -0
  4. package/dist/template/operations-tem/.env.test +4 -0
  5. package/dist/template/operations-tem/.prettierignore +34 -0
  6. package/dist/template/operations-tem/.prettierrc +14 -0
  7. package/dist/template/operations-tem/README.md +54 -17
  8. package/dist/template/operations-tem/docs/Git/345/274/200/345/217/221/350/247/204/350/214/203.md +105 -0
  9. package/dist/template/operations-tem/docs/React/345/274/200/345/217/221/350/247/204/350/214/203.md +81 -0
  10. package/dist/template/operations-tem/docs/TypeScript/345/274/200/345/217/221/350/247/204/350/214/203.md +119 -0
  11. package/dist/template/operations-tem/docs//345/211/215/347/253/257/346/227/245/345/277/227/344/270/216/347/233/221/346/216/247/345/237/213/347/202/271/350/247/204/350/214/203.md +136 -0
  12. package/dist/template/operations-tem/docs//345/215/225/345/205/203/346/265/213/350/257/225/350/247/204/350/214/203.md +131 -0
  13. package/dist/template/operations-tem/docs//351/241/271/347/233/256/347/233/256/345/275/225/347/273/223/346/236/204/350/247/204/350/214/203.md +93 -0
  14. package/dist/template/operations-tem/package-lock.json +2035 -294
  15. package/dist/template/operations-tem/package.json +20 -3
  16. package/dist/template/operations-tem/src/api/user.ts +2 -2
  17. package/dist/template/operations-tem/src/components/ErrorBoundary/index.tsx +82 -0
  18. package/dist/template/operations-tem/src/layouts/BasicLayout.tsx +39 -48
  19. package/dist/template/operations-tem/src/main.tsx +11 -11
  20. package/dist/template/operations-tem/src/pages/404.test.tsx +20 -0
  21. package/dist/template/operations-tem/src/pages/dashboard/index.tsx +1 -1
  22. package/dist/template/operations-tem/src/pages/home/index.tsx +61 -32
  23. package/dist/template/operations-tem/src/router/index.tsx +27 -21
  24. package/dist/template/operations-tem/src/setupTests.ts +1 -0
  25. package/dist/template/operations-tem/src/store/useCounterStore.ts +6 -6
  26. package/dist/template/operations-tem/src/style.less +3 -3
  27. package/dist/template/operations-tem/src/utils/request/index.ts +5 -5
  28. package/dist/template/operations-tem/src/vite-env.d.ts +12 -0
  29. package/dist/template/operations-tem/tsconfig.app.json +7 -1
  30. package/dist/template/operations-tem/vite.config.ts +61 -2
  31. package/package.json +1 -1
@@ -7,7 +7,7 @@ import axios, { type AxiosRequestConfig, type AxiosResponse } from 'axios';
7
7
  // 定义通用的后端响应结构
8
8
  export interface BaseResponse<T = unknown> {
9
9
  code: number; // 业务状态码 (0/200: 成功, 其他: 失败)
10
- data: T; // 业务数据
10
+ data: T; // 业务数据
11
11
  message: string; // 提示信息
12
12
  }
13
13
 
@@ -27,7 +27,7 @@ function createRequest(config: AxiosRequestConfig) {
27
27
  },
28
28
  (error) => {
29
29
  return Promise.reject(error);
30
- }
30
+ },
31
31
  );
32
32
 
33
33
  // 响应拦截器
@@ -68,7 +68,7 @@ function createRequest(config: AxiosRequestConfig) {
68
68
  console.error('网络连接异常,请稍后再试!');
69
69
  }
70
70
  return Promise.reject(error);
71
- }
71
+ },
72
72
  );
73
73
 
74
74
  // 返回封装好的请求方法对象
@@ -95,7 +95,7 @@ function createRequest(config: AxiosRequestConfig) {
95
95
  },
96
96
  delete: <T = unknown>(url: string, config?: AxiosRequestConfig): Promise<T> => {
97
97
  return instance.delete(url, config);
98
- }
98
+ },
99
99
  };
100
100
  }
101
101
 
@@ -103,6 +103,6 @@ function createRequest(config: AxiosRequestConfig) {
103
103
  // 可以直接 import { request } from '@/utils/request' 使用
104
104
  export const request = createRequest({
105
105
  // 从环境变量 VITE_API_BASE_URL 获取基础地址,默认为 /api
106
- baseURL: import.meta.env.VITE_API_BASE_URL || '/api',
106
+ baseURL: import.meta.env.VITE_API_BASE_URL || '/api',
107
107
  timeout: 10000, // 超时时间 10s
108
108
  });
@@ -0,0 +1,12 @@
1
+ /// <reference types="vitest" />
2
+ /// <reference types="vite/client" />
3
+
4
+ interface ImportMetaEnv {
5
+ readonly VITE_ENV: string;
6
+ readonly VITE_API_BASE_URL: string;
7
+ readonly VITE_APP_TITLE: string;
8
+ }
9
+
10
+ interface ImportMeta {
11
+ readonly env: ImportMetaEnv;
12
+ }
@@ -5,7 +5,7 @@
5
5
  "useDefineForClassFields": true,
6
6
  "lib": ["ES2023", "DOM", "DOM.Iterable"],
7
7
  "module": "ESNext",
8
- "types": ["vite/client"],
8
+ "types": ["vite/client", "node"],
9
9
  "skipLibCheck": true,
10
10
 
11
11
  /* Bundler mode */
@@ -16,6 +16,12 @@
16
16
  "noEmit": true,
17
17
  "jsx": "react-jsx",
18
18
 
19
+ /* Path Aliases */
20
+ "baseUrl": ".",
21
+ "paths": {
22
+ "@/*": ["src/*"]
23
+ },
24
+
19
25
  /* Linting */
20
26
  "strict": true,
21
27
  "noUnusedLocals": true,
@@ -1,13 +1,61 @@
1
- import { defineConfig } from 'vite'
1
+ import { defineConfig } from 'vitest/config'
2
2
  import react, { reactCompilerPreset } from '@vitejs/plugin-react'
3
3
  import babel from '@rolldown/plugin-babel'
4
+ import path from 'path'
5
+ import { visualizer } from 'rollup-plugin-visualizer'
4
6
 
5
7
  // https://vite.dev/config/
6
8
  export default defineConfig({
7
9
  plugins: [
8
10
  react(),
9
- babel({ presets: [reactCompilerPreset()] })
11
+ babel({ presets: [reactCompilerPreset()] }),
12
+ process.env.ANALYZE === 'true' && visualizer({
13
+ open: true,
14
+ gzipSize: true,
15
+ brotliSize: true,
16
+ filename: 'dist/stats.html',
17
+ }),
10
18
  ],
19
+ resolve: {
20
+ alias: {
21
+ '@': path.resolve(__dirname, './src'),
22
+ },
23
+ },
24
+ // 生产环境打包配置
25
+ build: {
26
+ // 消除打包大小超过 500kb 警告
27
+ chunkSizeWarningLimit: 2000,
28
+ minify: 'terser',
29
+ terserOptions: {
30
+ compress: {
31
+ drop_console: process.env.NODE_ENV === 'production',
32
+ drop_debugger: process.env.NODE_ENV === 'production',
33
+ },
34
+ },
35
+ rollupOptions: {
36
+ output: {
37
+ // 静态资源分类打包
38
+ chunkFileNames: 'assets/js/[name]-[hash].js',
39
+ entryFileNames: 'assets/js/[name]-[hash].js',
40
+ assetFileNames: 'assets/[ext]/[name]-[hash].[ext]',
41
+ // 手动分包策略
42
+ manualChunks(id) {
43
+ // 1. 将 react 核心全家桶打包到一起
44
+ if (id.includes('node_modules/react') || id.includes('node_modules/react-dom') || id.includes('node_modules/react-router-dom')) {
45
+ return 'vendor-react';
46
+ }
47
+ // 2. 将 echarts 单独打包 (体积较大)
48
+ if (id.includes('node_modules/echarts') || id.includes('node_modules/zrender')) {
49
+ return 'vendor-echarts';
50
+ }
51
+ // 3. 将 antd 和图标单独打包
52
+ if (id.includes('node_modules/antd') || id.includes('node_modules/@ant-design')) {
53
+ return 'vendor-antd';
54
+ }
55
+ },
56
+ },
57
+ },
58
+ },
11
59
  css: {
12
60
  preprocessorOptions: {
13
61
  less: {
@@ -15,4 +63,15 @@ export default defineConfig({
15
63
  },
16
64
  },
17
65
  },
66
+ // Vitest 测试配置
67
+ test: {
68
+ environment: 'jsdom',
69
+ globals: true,
70
+ setupFiles: './src/setupTests.ts',
71
+ coverage: {
72
+ provider: 'v8',
73
+ reporter: ['text', 'json', 'html'],
74
+ exclude: ['node_modules/', 'src/setupTests.ts', 'dist/'],
75
+ },
76
+ },
18
77
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chenhui996/gg-cli",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "一个轻量级的现代前端脚手架工具,公网测试",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",