create-young-proj 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +13 -2
  3. package/dist/index.mjs +18 -18
  4. package/index.mjs +3 -3
  5. package/package.json +10 -12
  6. package/template-admin-server/.editorconfig +11 -0
  7. package/template-admin-server/.nvmrc +1 -0
  8. package/template-admin-server/.vscode/extensions.json +6 -0
  9. package/template-admin-server/.vscode/settings.json +4 -0
  10. package/template-admin-server/README.md +73 -0
  11. package/template-admin-server/_gitignore +15 -0
  12. package/template-admin-server/boot.mjs +11 -0
  13. package/template-admin-server/package.json +60 -0
  14. package/template-admin-server/rome.json +22 -0
  15. package/template-admin-server/src/config/config.default.ts +56 -0
  16. package/template-admin-server/src/configuration.ts +47 -0
  17. package/template-admin-server/src/controller/admin.controller.ts +397 -0
  18. package/template-admin-server/src/controller/api.controller.ts +98 -0
  19. package/template-admin-server/src/controller/base.controller.ts +70 -0
  20. package/template-admin-server/src/controller/dto/api.ts +47 -0
  21. package/template-admin-server/src/controller/dto/index.ts +36 -0
  22. package/template-admin-server/src/controller/dto/menu.ts +41 -0
  23. package/template-admin-server/src/controller/dto/role.ts +41 -0
  24. package/template-admin-server/src/controller/dto/user.ts +52 -0
  25. package/template-admin-server/src/controller/menu.controller.ts +138 -0
  26. package/template-admin-server/src/controller/role.controller.ts +116 -0
  27. package/template-admin-server/src/controller/user.controller.ts +108 -0
  28. package/template-admin-server/src/entities/Api.ts +29 -0
  29. package/template-admin-server/src/entities/BaseCreate.ts +30 -0
  30. package/template-admin-server/src/entities/Menu.ts +39 -0
  31. package/template-admin-server/src/entities/Role.ts +36 -0
  32. package/template-admin-server/src/entities/User.ts +35 -0
  33. package/template-admin-server/src/entities/index.ts +10 -0
  34. package/template-admin-server/src/filter/default.filter.ts +22 -0
  35. package/template-admin-server/src/filter/notfound.filter.ts +23 -0
  36. package/template-admin-server/src/middleware/helper.middleware.ts +28 -0
  37. package/template-admin-server/src/middleware/index.ts +9 -0
  38. package/template-admin-server/src/middleware/jwt.middleware.ts +32 -0
  39. package/template-admin-server/src/middleware/report.middleware.ts +26 -0
  40. package/template-admin-server/src/service/api.service.ts +174 -0
  41. package/template-admin-server/src/service/basic.ts +118 -0
  42. package/template-admin-server/src/service/index.ts +10 -0
  43. package/template-admin-server/src/service/menu.service.ts +139 -0
  44. package/template-admin-server/src/service/role.service.ts +286 -0
  45. package/template-admin-server/src/service/user.service.ts +124 -0
  46. package/template-admin-server/src/strategy/jwt.strategy.ts +26 -0
  47. package/template-admin-server/src/types/index.ts +42 -0
  48. package/template-admin-server/src/types/types.d.ts +31 -0
  49. package/template-admin-server/tsconfig.json +24 -0
  50. package/template-vue-admin/.vscode/extensions.json +10 -0
  51. package/template-vue-admin/.vscode/list-add.code-snippets +108 -0
  52. package/template-vue-admin/.vscode/list-export.code-snippets +72 -0
  53. package/template-vue-admin/.vscode/list.code-snippets +61 -0
  54. package/template-vue-admin/.vscode/settings.json +7 -0
  55. package/template-vue-admin/Dockerfile +42 -0
  56. package/template-vue-admin/README.md +75 -0
  57. package/template-vue-admin/_env +8 -0
  58. package/template-vue-admin/_gitignore +30 -0
  59. package/template-vue-admin/boot.mjs +16 -0
  60. package/template-vue-admin/config/.devrc +2 -0
  61. package/template-vue-admin/config/.onlinerc +2 -0
  62. package/template-vue-admin/config/.testrc +2 -0
  63. package/template-vue-admin/index.html +21 -0
  64. package/template-vue-admin/nitro.config.ts +19 -0
  65. package/template-vue-admin/package.json +50 -0
  66. package/template-vue-admin/plugins/env.ts +26 -0
  67. package/template-vue-admin/public/vite.svg +1 -0
  68. package/template-vue-admin/rome.json +26 -0
  69. package/template-vue-admin/routes/api/[...all].ts +49 -0
  70. package/template-vue-admin/routes/get/env.ts +18 -0
  71. package/template-vue-admin/src/App.vue +14 -0
  72. package/template-vue-admin/src/apis/delete.ts +36 -0
  73. package/template-vue-admin/src/apis/get.ts +84 -0
  74. package/template-vue-admin/src/apis/index.ts +10 -0
  75. package/template-vue-admin/src/apis/patch.ts +79 -0
  76. package/template-vue-admin/src/apis/post.ts +77 -0
  77. package/template-vue-admin/src/assets/img/login_background.jpg +0 -0
  78. package/template-vue-admin/src/auto-components.d.ts +36 -0
  79. package/template-vue-admin/src/auto-imports.d.ts +282 -0
  80. package/template-vue-admin/src/layouts/blank.vue +9 -0
  81. package/template-vue-admin/src/layouts/default/components/Link.vue +23 -0
  82. package/template-vue-admin/src/layouts/default/components/Logo.vue +20 -0
  83. package/template-vue-admin/src/layouts/default/components/Menu.vue +54 -0
  84. package/template-vue-admin/src/layouts/default/components/NavSearch.vue +52 -0
  85. package/template-vue-admin/src/layouts/default/components/ScrollPane.vue +79 -0
  86. package/template-vue-admin/src/layouts/default/components/TagsView.vue +137 -0
  87. package/template-vue-admin/src/layouts/default/components/TopMenu.vue +21 -0
  88. package/template-vue-admin/src/layouts/default/components/UserCenter.vue +50 -0
  89. package/template-vue-admin/src/layouts/default/index.vue +95 -0
  90. package/template-vue-admin/src/main.ts +44 -0
  91. package/template-vue-admin/src/modules/1-router.ts +66 -0
  92. package/template-vue-admin/src/modules/2-pinia.ts +10 -0
  93. package/template-vue-admin/src/modules/3-net.ts +75 -0
  94. package/template-vue-admin/src/modules/4-auth.ts +122 -0
  95. package/template-vue-admin/src/stores/index.ts +9 -0
  96. package/template-vue-admin/src/stores/local/index.ts +23 -0
  97. package/template-vue-admin/src/stores/session/index.ts +63 -0
  98. package/template-vue-admin/src/stores/tags.ts +109 -0
  99. package/template-vue-admin/src/typings/global.d.ts +70 -0
  100. package/template-vue-admin/src/typings/index.ts +50 -0
  101. package/template-vue-admin/src/views/403.vue +32 -0
  102. package/template-vue-admin/src/views/[...all_404].vue +556 -0
  103. package/template-vue-admin/src/views/base/login.vue +193 -0
  104. package/template-vue-admin/src/views/dashboard/[name].vue +23 -0
  105. package/template-vue-admin/src/views/index.vue +19 -0
  106. package/template-vue-admin/src/views/system/api.vue +161 -0
  107. package/template-vue-admin/src/views/system/hooks/useRole.ts +286 -0
  108. package/template-vue-admin/src/views/system/menuList.vue +195 -0
  109. package/template-vue-admin/src/views/system/role.vue +132 -0
  110. package/template-vue-admin/src/views/system/user.vue +193 -0
  111. package/template-vue-admin/src/vite-env.d.ts +52 -0
  112. package/template-vue-admin/tsconfig.json +21 -0
  113. package/template-vue-admin/tsconfig.node.json +9 -0
  114. package/template-vue-admin/unocss.config.ts +47 -0
  115. package/template-vue-admin/vite.config.ts +77 -0
  116. package/template-vue-thin/package.json +14 -13
  117. package/template-vue-thin/vite.config.ts +1 -6
@@ -0,0 +1,72 @@
1
+ {
2
+ "list-export-admin": {
3
+ "prefix": "list-export",
4
+ "body": [
5
+ "<route lang=\"yaml\">",
6
+ "meta:",
7
+ " title: $1",
8
+ " authPath: $2",
9
+ "</route>",
10
+ "",
11
+ "<script lang=\"ts\" setup>",
12
+ "import { YoungTable, YoungPagination} from '@bluesyoung/ui-vue3-element-plus';",
13
+ "import type { TableDataItem, TableHeadItem } from '@bluesyoung/ui-vue3-element-plus';",
14
+ "import type { $3 } from '@/typings';",
15
+ "import { apis } from '@/modules/3-net';",
16
+ "",
17
+ "interface Form extends $3 {};",
18
+ "",
19
+ "const tableHead: TableHeadItem<Form>[] = [",
20
+ " { prop: '', label: '' },",
21
+ "];",
22
+ "const tableData = ref<TableDataItem<Form>[]>([]);",
23
+ "",
24
+ "type Query = BaseQuery & Partial<Form>;",
25
+ "const query = reactive<Query>({",
26
+ " pageNum: 1,",
27
+ " pageSize: 10,",
28
+ " total: 0,",
29
+ "});",
30
+ "",
31
+ "const getList = async () => {",
32
+ " // const { list, pageNum, pageSize, total } = await apis.get.getApiList(query);",
33
+ " // tableData.value = deepClone(list || []);",
34
+ " // query.pageNum = +pageNum || 1;",
35
+ " // query.pageSize = +pageSize || 50;",
36
+ " // query.total = +total || 0;",
37
+ "};",
38
+ "",
39
+ "const exportHandler = async () => {",
40
+ " const { useExport2Excel } = await import('@bluesyoung/ui-vue3-element-plus');",
41
+ " await useExport2Excel({",
42
+ " filename: '数据导出',",
43
+ " tableHead: tableHead,",
44
+ " tableData: tableData.value",
45
+ " });",
46
+ "};",
47
+ "",
48
+ "getList();",
49
+ "</script>",
50
+ "",
51
+ "<template>",
52
+ " <div class=\"flex\">",
53
+ " <div class=\"m-2\">",
54
+ " <ElInput v-model=\"query.\" placeholder=\"请输入\" />",
55
+ " </div>",
56
+ " <div class=\"m-2\">",
57
+ " <ElButton type=\"primary\" @click=\"getList\">搜索</ElButton>",
58
+ " </div>",
59
+ " <div class=\"m-2\">",
60
+ " <ElButton :disabled=\"tableData.length <= 0\" type=\"success\" @click=\"exportHandler\">导出</ElButton>",
61
+ " </div>",
62
+ " </div>",
63
+ " <div class=\"m-2\">",
64
+ " <YoungTable :table-data=\"tableData\" :table-head=\"tableHead\" :table-height=\"680\" />",
65
+ " <YoungPagination v-model:page=\"query.pageNum\" v-model:limit=\"query.pageSize\" :total=\"query.total\"",
66
+ " @page-change=\"getList\" />",
67
+ " </div>",
68
+ "</template>"
69
+ ],
70
+ "description": "list-export-admin"
71
+ }
72
+ }
@@ -0,0 +1,61 @@
1
+ {
2
+ "list-admin": {
3
+ "prefix": "list",
4
+ "body": [
5
+ "<route lang=\"yaml\">",
6
+ "meta:",
7
+ " title: $1",
8
+ " authPath: $2",
9
+ "</route>",
10
+ "",
11
+ "<script lang=\"ts\" setup>",
12
+ "import { YoungPagination, YoungTable } from '@bluesyoung/ui-vue3-element-plus';",
13
+ "import type { TableHeadItem, TableDataItem } from '@bluesyoung/ui-vue3-element-plus';",
14
+ "import { deepClone } from '@bluesyoung/utils';",
15
+ "import { $3 } from '@/typings';",
16
+ "import { apis } from '@/modules/3-net';",
17
+ "",
18
+ "interface Form extends $3 { };",
19
+ "",
20
+ "const tableHead: TableHeadItem<Form>[] = [",
21
+ " { prop: '', label: '' },",
22
+ "];",
23
+ "interface Query extends BaseQuery {};",
24
+ "const query = reactive<Query>({",
25
+ " pageNum: 1,",
26
+ " pageSize: 50,",
27
+ " total: 0,",
28
+ "});",
29
+ "",
30
+ "const tableData = ref<TableDataItem<Form>[]>([]);",
31
+ "const roleList = ref<SelectOptionItem[]>([]);",
32
+ "const getList = async () => {",
33
+ " // const { list, pageNum, pageSize, total } = await apis.get.getUserList(query);",
34
+ " // tableData.value = deepClone(list || []);",
35
+ " // query.pageNum = +pageNum || 1;",
36
+ " // query.pageSize = +pageSize || 50;",
37
+ " // query.total = +total || 0;",
38
+ "};",
39
+ "",
40
+ "getList();",
41
+ "</script>",
42
+ "",
43
+ "<template>",
44
+ " <div class=\"flex\">",
45
+ " <div class=\"m-2\">",
46
+ " <ElInput v-model=\"query.\" placeholder=\"请输入\" />",
47
+ " </div>",
48
+ " <div class=\"m-2\">",
49
+ " <ElButton type=\"primary\" @click=\"getList\">搜索</ElButton>",
50
+ " </div>",
51
+ " </div>",
52
+ " <div class=\"m-2\">",
53
+ " <YoungTable :table-data=\"tableData\" :table-head=\"tableHead\" :table-height=\"680\" />",
54
+ " <YoungPagination v-show=\"query.total > 0\" v-model:page=\"query.pageNum\" v-model:limit=\"query.pageSize\" :total=\"query.total\"",
55
+ " @page-change=\"getList\" />",
56
+ " </div>",
57
+ "</template>",
58
+ ],
59
+ "description": "list-admin"
60
+ }
61
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "editor.formatOnSave": true,
3
+ "editor.defaultFormatter": "rome.rome",
4
+ "[vue]": {
5
+ "editor.defaultFormatter": "Vue.volar"
6
+ }
7
+ }
@@ -0,0 +1,42 @@
1
+ # 拉取基础镜像
2
+ FROM node:16-alpine as builder
3
+
4
+ # 维护者
5
+ MAINTAINER BluesYoung "bluesyoung_web@163.com"
6
+
7
+ # 工作目录
8
+ WORKDIR /app
9
+
10
+ # 没有压缩包,首选 COPY,如果需要自动解包或下载,则使用 ADD
11
+
12
+ # 对比依赖是否变更
13
+ COPY package.json yarn.lock /app/
14
+
15
+ # 设置npm仓库 + 下载依赖,上面的文件如果没有变化则跳过下载,直接使用缓存
16
+ RUN npm config set registry https://registry.npmmirror.com && \
17
+ yarn config set registry https://registry.npmmirror.com && \
18
+ yarn
19
+
20
+ # 加入代码
21
+ COPY . /app
22
+ # 打包
23
+ RUN yarn build
24
+
25
+ # 打包完成,构建最终的极简镜像
26
+ FROM node:16-alpine
27
+
28
+ # 工作目录
29
+ WORKDIR /app
30
+
31
+ # 复制运行需要的文件[及依赖]
32
+ # 直接复制源代码
33
+ COPY boot.mjs /app/
34
+ COPY config /app/config
35
+ # 复制上一步的打包产物
36
+ COPY --from=builder /app/.output /app/.output
37
+
38
+ # 暴露指定的端口号,暂不需要
39
+ # EXPOSE 3001
40
+
41
+ # 启动容器时运行的命令
42
+ ENTRYPOINT ["node", "boot.mjs"]
@@ -0,0 +1,75 @@
1
+ # 后台模板
2
+
3
+ ## 用户代码片段(页面模板)
4
+
5
+ 模板 | 触发关键字
6
+ --- | ---
7
+ 基础列表 | `list`
8
+ 列表 + `Excel` 导出 | `list-export`
9
+ 列表 + 弹出层 | `list-add`
10
+
11
+ ## **Docker 部署**
12
+
13
+ - 同一份代码,可以根据运行时的环境变量决定具体表现
14
+ - `node` 服务:
15
+ - 托管前端静态资源
16
+ - 根据环境变量读取对应的配置文件,并以接口的形式暴露给前端
17
+ - 跨域接口代理
18
+
19
+ 环境变量
20
+
21
+ ```sh
22
+ # 部署环境 dev | test | online
23
+ DEPLOY_ENV=dev
24
+ # DEPLOY_ENV=test
25
+ # DEPLOY_ENV=online
26
+ # node 服务监听的端口号
27
+ LISTEN_PORT=3000
28
+ # 网关主机地址
29
+ # APIGATEHOST='apisix.intranet.cn'
30
+ ```
31
+
32
+ ### 本地开发
33
+
34
+ **确保上述的环境变量存在**
35
+
36
+ 启动服务端程序 `yarn dev:server`
37
+
38
+ 启动客户端程序 `yarn dev`
39
+
40
+ ### 打包预览
41
+
42
+ `yarn build`
43
+
44
+ 确保上述的环境变量存在
45
+
46
+ `node boot.mjs`
47
+
48
+ ### 配置文件
49
+
50
+ 存放于 `config` 目录下的 `.${env}rc` 文件,`env` 为对应的环境标识
51
+
52
+ ## 常规部署
53
+
54
+ - `nginx` 托管前端静态资源
55
+ - 每次打包时读取环境变量,打包完成之后不可变
56
+ - 使用 `nginx` 代理跨域
57
+
58
+ 环境变量
59
+
60
+ ```sh
61
+ # 设置静态部署
62
+ VITE_USE_DEFAULT_DEPLOY_METHOD=true
63
+ # 其他的环境变量,根据环境区分
64
+ VITE_TITLE=管理后台
65
+ ```
66
+
67
+ ### 本地开发
68
+
69
+ 确保上述的环境变量存在,然后 `yarn dev` 即可
70
+
71
+ ### 打包预览
72
+
73
+ `yarn build`
74
+
75
+ `yarn preview`
@@ -0,0 +1,8 @@
1
+ # 部署环境 dev | test | online
2
+ DEPLOY_ENV=dev
3
+ # DEPLOY_ENV=test
4
+ # DEPLOY_ENV=online
5
+ # node 服务监听的端口号
6
+ LISTEN_PORT=3000
7
+ # 网关主机地址
8
+ # APIGATEHOST='apisix.intranet.cn'
@@ -0,0 +1,30 @@
1
+ # Logs
2
+ logs
3
+ *.log
4
+ npm-debug.log*
5
+ yarn-debug.log*
6
+ yarn-error.log*
7
+ pnpm-debug.log*
8
+ lerna-debug.log*
9
+
10
+ node_modules
11
+ dist
12
+ dist-ssr
13
+ *.local
14
+ .env
15
+
16
+ # Editor directories and files
17
+ .vscode/*
18
+ !.vscode/extensions.json
19
+ !.vscode/settings.json
20
+ !.vscode/*.code-snippets
21
+ .idea
22
+ .DS_Store
23
+ *.suo
24
+ *.ntvs*
25
+ *.njsproj
26
+ *.sln
27
+ *.sw?
28
+
29
+ .nitro
30
+ .output
@@ -0,0 +1,16 @@
1
+ /*
2
+ * @Author: zhangyang
3
+ * @Date: 2022-09-16 11:48:05
4
+ * @LastEditTime: 2022-12-29 16:21:59
5
+ * @Description:
6
+ */
7
+ (async () => {
8
+ const env = process.env.DEPLOY_ENV;
9
+ const listenPort = process.env.LISTEN_PORT || 3003;
10
+ console.log('当前环境:', env);
11
+ console.log('服务监听端口:', listenPort);
12
+
13
+ process.env.NITRO_PORT = listenPort;
14
+
15
+ await import('./.output/server/index.mjs');
16
+ })();
@@ -0,0 +1,2 @@
1
+ VITE_TITLE = 管理后台-dev
2
+ VITE_BASE_HTTP = http://localhost:7001
@@ -0,0 +1,2 @@
1
+ VITE_TITLE = 管理后台-online
2
+ VITE_BASE_HTTP = http://localhost:7001
@@ -0,0 +1,2 @@
1
+ VITE_TITLE = 管理后台-test
2
+ VITE_BASE_HTTP = http://localhost:7001
@@ -0,0 +1,21 @@
1
+ <!DOCTYPE html>
2
+ <html lang="zh-CN">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>Vite + Vue + TS</title>
8
+ <script>
9
+ // hack globalThis
10
+ this.globalThis || (this.globalThis = this);
11
+ // window.onerror = function(e) {
12
+ // console.log(e)
13
+ // window.alert('您的浏览器版本过低,请尝试使用其他浏览器或将浏览器升级至最新版本后重试!');
14
+ // }
15
+ </script>
16
+ </head>
17
+ <body>
18
+ <div id="app"></div>
19
+ <script type="module" src="/src/main.ts"></script>
20
+ </body>
21
+ </html>
@@ -0,0 +1,19 @@
1
+ /*
2
+ * @Author: zhangyang
3
+ * @Date: 2022-12-28 11:59:56
4
+ * @LastEditTime: 2023-01-04 19:01:20
5
+ * @Description:
6
+ */
7
+ import { defineNitroConfig } from 'nitropack';
8
+
9
+ export default defineNitroConfig({
10
+ /**
11
+ * 托管前端静态资源
12
+ */
13
+ serveStatic: 'node',
14
+ publicAssets: [
15
+ {
16
+ dir: 'dist',
17
+ },
18
+ ],
19
+ });
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "vue3_admin",
3
+ "private": true,
4
+ "version": "0.0.0",
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "vite --host",
8
+ "dev:server": "nitropack dev",
9
+ "build": "vite build && nitropack build",
10
+ "preview": "vite preview --host",
11
+ "format": "rome format .* --write",
12
+ "release": "changelogen && bumpp --no-push"
13
+ },
14
+ "dependencies": {
15
+ "@bluesyoung/http": "0.1.3",
16
+ "@bluesyoung/ui-vue3": "0.0.3",
17
+ "@bluesyoung/ui-vue3-element-plus": "0.0.6",
18
+ "@bluesyoung/utils": "0.0.3",
19
+ "@vueuse/core": "^9.4.0",
20
+ "core-js": "^3.26.0",
21
+ "element-plus": "^2.2.28",
22
+ "pinia": "^2.0.23",
23
+ "regenerator-runtime": "^0.13.10",
24
+ "vue": "^3.2.41",
25
+ "vue-router": "^4.1.6"
26
+ },
27
+ "devDependencies": {
28
+ "@iconify/json": "^2.2.1",
29
+ "@types/node": "16",
30
+ "@unocss/reset": "^0.48.0",
31
+ "@vitejs/plugin-legacy": "^3.0.1",
32
+ "@vitejs/plugin-vue": "^4.0.0",
33
+ "@vitejs/plugin-vue-jsx": "^3.0.0",
34
+ "bumpp": "^8.2.1",
35
+ "c12": "^1.1.0",
36
+ "changelogen": "^0.4.0",
37
+ "less": "^4.1.3",
38
+ "nitropack": "^1.0.0",
39
+ "rome": "^11.0.0",
40
+ "sass": "^1.57.1",
41
+ "terser": "^5.15.1",
42
+ "typescript": "^4.8.4",
43
+ "unocss": "^0.48.0",
44
+ "unplugin-auto-import": "^0.12.1",
45
+ "unplugin-vue-components": "^0.22.9",
46
+ "vite": "^4.0.4",
47
+ "vite-plugin-pages": "^0.28.0",
48
+ "vite-plugin-vue-layouts": "^0.7.0"
49
+ }
50
+ }
@@ -0,0 +1,26 @@
1
+ /*
2
+ * @Author: zhangyang
3
+ * @Date: 2023-01-04 18:53:23
4
+ * @LastEditTime: 2023-01-04 19:12:55
5
+ * @Description: 在插件中读取环境变量,避免重复的文件 io
6
+ */
7
+ import { resolve } from 'node:path';
8
+ import { loadConfig } from 'c12';
9
+ // @ts-ignore
10
+ export default defineNitroPlugin(async (app) => {
11
+ const env = (process.env.DEPLOY_ENV as 'dev' | 'test' | 'online') || 'dev';
12
+ const { config } = await loadConfig({
13
+ name: env,
14
+ cwd: resolve(process.cwd(), 'config'),
15
+ });
16
+
17
+ for (const key in config) {
18
+ if (Object.prototype.hasOwnProperty.call(config, key)) {
19
+ process.env[key] = config[key];
20
+ }
21
+ }
22
+
23
+ console.log('------------------------读取配置文件------------------------');
24
+ console.log(config);
25
+ console.log('------------------------------------------------------------');
26
+ });
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
@@ -0,0 +1,26 @@
1
+ {
2
+ "formatter": {
3
+ "ignore": [
4
+ "node_modules/**/*",
5
+ "src/utils/**/*.js",
6
+ "src/utils/**/*.map",
7
+ "*.d.ts",
8
+ "index.html",
9
+ "yarn.lock",
10
+ "*.json",
11
+ "README.md",
12
+ "dist/**/*"
13
+ ],
14
+ "indentStyle": "space",
15
+ "indentSize": 2,
16
+ "lineWidth": 100
17
+ },
18
+ "javascript": {
19
+ "formatter": {
20
+ "quoteStyle": "single"
21
+ }
22
+ },
23
+ "linter": {
24
+ "enabled": false
25
+ }
26
+ }
@@ -0,0 +1,49 @@
1
+ /*
2
+ * @Author: zhangyang
3
+ * @Date: 2023-01-04 15:16:30
4
+ * @LastEditTime: 2023-01-05 09:10:47
5
+ * @Description:
6
+ */
7
+ export default eventHandler(async (event) => {
8
+ const method = event.node.req.method;
9
+ const url = event.node.req.url;
10
+ let body;
11
+
12
+ if (!(method && method.toLowerCase() === 'get')) {
13
+ try {
14
+ body = await readBody(event);
15
+ console.log('🚀 ~ file: [...all].ts:16 ~ eventHandler ~ body', body);
16
+ } catch (error) {
17
+ console.log('🚀 ~ file: [...all].ts:18 ~ eventHandler ~ error', error);
18
+ }
19
+ }
20
+
21
+ // 开发服使用 http + 主机名,其他环境直接读取完整配置
22
+ const api_server_url = process.env.VITE_BASE_HTTP;
23
+ // 如果正式服报错,则设置一个请求头白名单,只传递对应的请求头
24
+ // console.log("🚀 ~ file: [...].post.ts:11 ~ defineEventHandler ~ api_server_url", api_server_url);
25
+ const headers = event.node.req.headers as Record<string, string>;
26
+
27
+ try {
28
+ const res = await $fetch(`${api_server_url}${url}`, {
29
+ method: event.node.req.method,
30
+ headers: {
31
+ time: headers['time'],
32
+ authorization: headers['authorization'],
33
+ sign: headers['sign'],
34
+ 'content-type': headers['content-type'],
35
+ 'x-forwarded-for': headers['x-forwarded-for'],
36
+ },
37
+ body,
38
+ });
39
+
40
+ return res;
41
+ } catch (error: any) {
42
+ if (error.toString().includes('401')) {
43
+ event.node.res.statusCode = 401;
44
+ return error.data;
45
+ } else {
46
+ return error;
47
+ }
48
+ }
49
+ });
@@ -0,0 +1,18 @@
1
+ /*
2
+ * @Author: zhangyang
3
+ * @Date: 2022-11-18 10:55:50
4
+ * @LastEditTime: 2023-01-04 19:06:46
5
+ * @Description:
6
+ */
7
+ export default defineEventHandler(async (event) => {
8
+ const envObj: any = {};
9
+ for (const key in process.env) {
10
+ if (Object.prototype.hasOwnProperty.call(process.env, key) && key.startsWith('VITE_')) {
11
+ envObj[key] = process.env[key];
12
+ }
13
+ }
14
+
15
+ event.node.res.setHeader('Access-Control-Allow-Origin', '*');
16
+
17
+ return envObj as ImportMetaEnv;
18
+ });
@@ -0,0 +1,14 @@
1
+ <!--
2
+ * @Author: zhangyang
3
+ * @Date: 2022-12-03 15:57:40
4
+ * @LastEditTime: 2023-01-05 14:07:02
5
+ * @Description:
6
+ -->
7
+ <script lang="ts" setup>
8
+ import locale from 'element-plus/lib/locale/lang/zh-cn';
9
+ </script>
10
+ <template>
11
+ <ElConfigProvider :locale="locale">
12
+ <RouterView />
13
+ </ElConfigProvider>
14
+ </template>
@@ -0,0 +1,36 @@
1
+ /*
2
+ * @Author: zhangyang
3
+ * @Date: 2023-01-06 10:50:53
4
+ * @LastEditTime: 2023-01-06 14:08:45
5
+ * @Description:
6
+ */
7
+ import { http } from '@/modules/3-net';
8
+
9
+ const method = 'DELETE';
10
+
11
+ const del = async (url: string, ids: string) => {
12
+ await http.authReq({
13
+ url,
14
+ method,
15
+ data: { ids },
16
+ });
17
+ };
18
+
19
+ export const useDeleteReq = () => ({
20
+ /**
21
+ * 删除用户
22
+ */
23
+ deleteUser: async (ids: string) => del('/user/delete/batch', ids),
24
+ /**
25
+ * 删除菜单
26
+ */
27
+ deleteMenu: async (ids: string) => del('/menu/delete/batch', ids),
28
+ /**
29
+ * 删除接口
30
+ */
31
+ deleteApi: async (ids: string) => del('/api/delete/batch', ids),
32
+ /**
33
+ * 删除角色
34
+ */
35
+ deleteRole: async (ids: string) => del('/role/delete/batch', ids),
36
+ });