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,286 @@
1
+ /*
2
+ * @Author: zhangyang
3
+ * @Date: 2022-12-27 14:20:09
4
+ * @LastEditTime: 2023-01-09 14:36:32
5
+ * @Description:
6
+ */
7
+ import { Provide } from '@midwayjs/decorator';
8
+ import { InjectEntityModel } from '@midwayjs/typeorm';
9
+ import type { Repository } from 'typeorm';
10
+ import { Api, Menu, Role } from '../entities';
11
+ import { BasicService } from './basic';
12
+
13
+ export type CreateRoleItem = Partial<Role> & {
14
+ /**
15
+ * 接口 id 数组
16
+ */
17
+ aid?: number[];
18
+ /**
19
+ * 菜单 id 数组
20
+ */
21
+ mid?: number[];
22
+ };
23
+
24
+ @Provide()
25
+ export class RoleService extends BasicService<Role, CreateRoleItem> {
26
+ @InjectEntityModel(Role)
27
+ repo: Repository<Role>;
28
+
29
+ async create(item: CreateRoleItem) {
30
+ const role = new Role();
31
+ for (const [key, value] of Object.entries(item)) {
32
+ if (key === 'aid' && Array.isArray(value)) {
33
+ const api_repo = this.dataSource.getRepository(Api);
34
+
35
+ for (const aid of value) {
36
+ const u = await api_repo.findOne({ where: { id: aid as number } });
37
+ if (u) {
38
+ if (role.apis) {
39
+ role.apis.push(u);
40
+ } else {
41
+ role.apis = [u];
42
+ }
43
+ } else {
44
+ throw new Error(`apiId: ${aid} doesn't exsist`);
45
+ }
46
+ }
47
+ } else if (key === 'mid' && Array.isArray(value)) {
48
+ const menu_repo = this.dataSource.getRepository(Menu);
49
+ for (const mid of value) {
50
+ const u = await menu_repo.findOne({ where: { id: mid as number } });
51
+ if (u) {
52
+ if (role.menus) {
53
+ role.menus.push(u);
54
+ } else {
55
+ role.menus = [u];
56
+ }
57
+ } else {
58
+ throw new Error(`menuId: ${mid} doesn't exsist`);
59
+ }
60
+ }
61
+ } else {
62
+ role[key] = value;
63
+ }
64
+ }
65
+ await this.repo.save(role);
66
+ }
67
+
68
+ async getAccessMenus(id: number) {
69
+ const query = this.repo.createQueryBuilder('role');
70
+ query.leftJoinAndSelect('role.menus', 'menus');
71
+ query.leftJoinAndSelect('menus.parentId', 'parentId');
72
+ query.where(`role.id = :id`, { id });
73
+ query.andWhere(`menus.status = 1`);
74
+ query.orderBy('parentId.id');
75
+ query.orderBy('menus.sort');
76
+
77
+ const menus = (await query.getOne())?.menus ?? [];
78
+ for (const menu of menus) {
79
+ menu.id = Number(menu.id);
80
+ // @ts-expect-error
81
+ menu.parentId = parseInt(menu?.parentId?.id ?? 0, 10);
82
+ }
83
+ return menus;
84
+ }
85
+
86
+ async getAccessMenusTree(id: number) {
87
+ const menus = await this.getAccessMenus(id);
88
+ this.logger.info('access menus: ', menus);
89
+
90
+ /**
91
+ * 收集 parentId
92
+ * 存储 id 与 menu 的映射
93
+ */
94
+ const menuMap = new Map<number, Menu>();
95
+ menus.forEach((item) => {
96
+ if (+item.parentId !== 0) {
97
+ menuMap.set(item.id, item);
98
+ }
99
+ });
100
+
101
+ /**
102
+ * 遍历菜单
103
+ */
104
+ for (const menu of menus) {
105
+ if (+menu.parentId === 0) {
106
+ menu.children = [];
107
+ menuMap.set(menu.id, menu);
108
+ } else {
109
+ const parentMenu = menuMap.get(+menu.parentId);
110
+ if (parentMenu) {
111
+ if (!parentMenu.children) {
112
+ parentMenu.children = [];
113
+ }
114
+ if (menuMap.has(menu.id)) {
115
+ parentMenu.children.push(menuMap.get(menu.id));
116
+ } else {
117
+ parentMenu.children.push(menu);
118
+ }
119
+ }
120
+ }
121
+ }
122
+
123
+ return Array.from(menuMap.values()).filter((item) => +item.parentId === 0);
124
+ }
125
+
126
+ async getAccessApis(id: number) {
127
+ const query = this.repo.createQueryBuilder('role');
128
+ query.leftJoinAndSelect('role.apis', 'apis');
129
+ query.where(`role.id = :id`, { id });
130
+ query.andWhere(`apis.status = 1`);
131
+ const apis = (await query.getOne())?.apis ?? [];
132
+
133
+ return apis.filter((api) => api.status === 1);
134
+ }
135
+
136
+ async findAll(item: CreateRoleItem & Paginition) {
137
+ const query = this.repo.createQueryBuilder();
138
+ query.select('*');
139
+
140
+ const { noPagination, pageNum, pageSize, name, keyword, status } = item;
141
+
142
+ if (['', undefined, null].every((i) => status !== i) && !Number.isNaN(status)) {
143
+ query.andWhere(`status = :status`, { status });
144
+ }
145
+
146
+ if (name) {
147
+ query.andWhere(`name like '%${name}%'`);
148
+ }
149
+
150
+ if (keyword) {
151
+ query.andWhere(`keyword like '%${keyword}%'`);
152
+ }
153
+
154
+ const page = Number(pageNum) || 1;
155
+ const size = Number(pageSize) || 10;
156
+
157
+ if (!item.noPagination) {
158
+ const skip = (page - 1) * size;
159
+
160
+ query.skip(skip);
161
+ query.take(size);
162
+ }
163
+
164
+ const total = await query.getCount();
165
+ const list = await query.getRawMany();
166
+
167
+ list.forEach((role) => (role.id = Number(role.id)));
168
+
169
+ return {
170
+ pageNum: page,
171
+ pageSize: size,
172
+ total,
173
+ noPagination,
174
+ list,
175
+ };
176
+ }
177
+
178
+ async addMenus(id: number, menusId: number[]) {
179
+ const role = await this.getById(id);
180
+ let res: any = true;
181
+
182
+ const queryRunner = this.dataSource.createQueryRunner();
183
+ await queryRunner.connect();
184
+ await queryRunner.startTransaction();
185
+ try {
186
+ for (const mid of menusId) {
187
+ const menu = await this.dataSource.getRepository(Menu).findOne({
188
+ where: { id: mid },
189
+ });
190
+ if (menu) {
191
+ if (role.menus) {
192
+ role.menus.push(menu);
193
+ } else {
194
+ role.menus = [menu];
195
+ }
196
+ } else {
197
+ throw new Error(`menuId: ${mid} 不存在`);
198
+ }
199
+ }
200
+ await this.repo.save(role);
201
+ await queryRunner.commitTransaction();
202
+ } catch (error) {
203
+ await queryRunner.rollbackTransaction();
204
+ res = error;
205
+ } finally {
206
+ await queryRunner.release();
207
+ }
208
+
209
+ if (res !== true) {
210
+ throw res;
211
+ }
212
+ }
213
+
214
+ async delMenus(id: number, menusId: number[]) {
215
+ const role = await this.getById(id);
216
+ if (role.menus) {
217
+ role.menus = role.menus.filter((i) => !menusId.includes(Number(i.id)));
218
+ }
219
+ await this.repo.save(role);
220
+ }
221
+
222
+ async addApis(id: number, apisId: number[]) {
223
+ const role = await this.getById(id);
224
+ let res: any = true;
225
+
226
+ const queryRunner = this.dataSource.createQueryRunner();
227
+ await queryRunner.connect();
228
+ await queryRunner.startTransaction();
229
+ try {
230
+ for (const aid of apisId) {
231
+ const api = await this.dataSource.getRepository(Api).findOne({
232
+ where: { id: aid },
233
+ });
234
+ if (api) {
235
+ if (role.apis) {
236
+ role.apis.push(api);
237
+ } else {
238
+ role.apis = [api];
239
+ }
240
+ } else {
241
+ throw new Error(`apiId: ${aid} 不存在`);
242
+ }
243
+ }
244
+ await this.repo.save(role);
245
+ await queryRunner.commitTransaction();
246
+ } catch (error) {
247
+ await queryRunner.rollbackTransaction();
248
+ res = error;
249
+ } finally {
250
+ await queryRunner.release();
251
+ }
252
+
253
+ if (res !== true) {
254
+ throw res;
255
+ }
256
+ }
257
+
258
+ async delApis(id: number, apisId: number[]) {
259
+ const role = await this.getById(id);
260
+ if (role.apis) {
261
+ role.apis = role.apis.filter((i) => !apisId.includes(Number(i.id)));
262
+ }
263
+ await this.repo.save(role);
264
+ }
265
+
266
+ async getById(id: number) {
267
+ const role = await this.repo.findOne({
268
+ where: { id },
269
+ relations: ['menus', 'apis'],
270
+ });
271
+ if (!role) {
272
+ throw new Error(`roleId: ${id} 不存在`);
273
+ }
274
+ return role;
275
+ }
276
+
277
+ async update(id: number, item: CreateRoleItem) {
278
+ const m = await this.getById(id);
279
+ for (const [key, value] of Object.entries(item)) {
280
+ if (value !== undefined && value !== null) {
281
+ m[key] = value;
282
+ }
283
+ }
284
+ await this.repo.save(m);
285
+ }
286
+ }
@@ -0,0 +1,124 @@
1
+ /*
2
+ * @Author: zhangyang
3
+ * @Date: 2022-12-27 11:23:19
4
+ * @LastEditTime: 2023-01-09 10:17:23
5
+ * @Description:
6
+ */
7
+ import { Provide } from '@midwayjs/decorator';
8
+ import { InjectEntityModel } from '@midwayjs/typeorm';
9
+ import type { Repository } from 'typeorm';
10
+ import { Role, User } from '../entities';
11
+ import { BasicService } from './basic';
12
+
13
+ export type CreateUserItem = Partial<User> & { rid?: number };
14
+
15
+ @Provide()
16
+ export class UserService extends BasicService<User, CreateUserItem> {
17
+ @InjectEntityModel(User)
18
+ repo: Repository<User>;
19
+
20
+ async create(item: CreateUserItem) {
21
+ const user = new User();
22
+ for (const [key, value] of Object.entries(item)) {
23
+ if (key === 'rid') {
24
+ const role = await this.dataSource.getRepository(Role).findOne({
25
+ where: {
26
+ id: value as number,
27
+ },
28
+ });
29
+ if (role) {
30
+ user.role = role;
31
+ } else {
32
+ throw new Error(`roleId: ${value} doesn't exsist`);
33
+ }
34
+ } else {
35
+ user[key] = value;
36
+ }
37
+ }
38
+ await this.repo.save(user);
39
+ }
40
+
41
+ async findAll(item: Partial<User> & Paginition) {
42
+ const query = this.repo.createQueryBuilder();
43
+ query.select('*');
44
+
45
+ const { noPagination, pageNum, pageSize, username, mobile, status } = item;
46
+
47
+ if (['', undefined, null].every((i) => status !== i) && !Number.isNaN(status)) {
48
+ query.andWhere(`status = :status`, { status });
49
+ }
50
+
51
+ if (username) {
52
+ query.andWhere(`username like '%${username}%'`);
53
+ }
54
+
55
+ if (mobile) {
56
+ query.andWhere(`mobile like '%${mobile}%'`);
57
+ }
58
+
59
+ const page = Number(pageNum) || 1;
60
+ const size = Number(pageSize) || 10;
61
+
62
+ if (!item.noPagination) {
63
+ const skip = (page - 1) * size;
64
+
65
+ query.skip(skip);
66
+ query.take(size);
67
+ }
68
+
69
+ const total = await query.getCount();
70
+ const list = await query.getRawMany();
71
+
72
+ const roleList = await this.dataSource.getRepository(Role).find();
73
+ const roleObj: Record<string, string> = {};
74
+ for (const role of roleList) {
75
+ roleObj[role.id] = role.name;
76
+ }
77
+ for (const user of list) {
78
+ delete user.password;
79
+ user.id = Number(user.id);
80
+ user.roleId = Number(user.roleId);
81
+ user.role_name = roleObj[user.roleId];
82
+ }
83
+
84
+ return {
85
+ pageNum: page,
86
+ pageSize: size,
87
+ total,
88
+ noPagination,
89
+ list,
90
+ };
91
+ }
92
+
93
+ async update(id: number, item: CreateUserItem) {
94
+ const m = await this.getById(id);
95
+ for (const [key, value] of Object.entries(item)) {
96
+ if (value !== undefined && value !== null) {
97
+ if (key === 'rid') {
98
+ const role = await this.dataSource.getRepository(Role).findOne({
99
+ where: { id: Number(value) },
100
+ });
101
+ if (role) {
102
+ m.role = role;
103
+ } else {
104
+ throw new Error(`roleId: ${value} 不存在!`);
105
+ }
106
+ } else {
107
+ m[key] = value;
108
+ }
109
+ }
110
+ }
111
+ await this.repo.save(m);
112
+ }
113
+
114
+ async getById(id: number) {
115
+ const role = await this.repo.findOne({
116
+ where: { id },
117
+ relations: ['role'],
118
+ });
119
+ if (!role) {
120
+ throw new Error(`userId: ${id} 不存在`);
121
+ }
122
+ return role;
123
+ }
124
+ }
@@ -0,0 +1,26 @@
1
+ /*
2
+ * @Author: zhangyang
3
+ * @Date: 2022-12-27 16:04:53
4
+ * @LastEditTime: 2022-12-27 17:34:36
5
+ * @Description:
6
+ */
7
+ import { CustomStrategy, PassportStrategy } from '@midwayjs/passport';
8
+ import { Strategy, ExtractJwt } from 'passport-jwt';
9
+ import { Config } from '@midwayjs/decorator';
10
+
11
+ @CustomStrategy()
12
+ export class JwtStrategy extends PassportStrategy(Strategy, 'jwt') {
13
+ @Config('jwt')
14
+ jwtConfig;
15
+
16
+ async validate(payload) {
17
+ return payload;
18
+ }
19
+
20
+ getStrategyOptions(): any {
21
+ return {
22
+ secretOrKey: this.jwtConfig.secret,
23
+ jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
24
+ };
25
+ }
26
+ }
@@ -0,0 +1,42 @@
1
+ /*
2
+ * @Author: zhangyang
3
+ * @Date: 2022-12-27 11:15:10
4
+ * @LastEditTime: 2022-12-27 16:09:13
5
+ * @Description:
6
+ */
7
+
8
+ import defu from 'defu';
9
+ import '@midwayjs/core';
10
+
11
+ /**
12
+ * 接口状态码
13
+ */
14
+ export enum Code {
15
+ success = 0,
16
+ fail = -1,
17
+ }
18
+
19
+ const defaultSuccess: ResponseMsg = {
20
+ code: Code.success,
21
+ data: {},
22
+ msg: '操作成功!',
23
+ };
24
+
25
+ const defaultFail: ResponseMsg = {
26
+ code: Code.fail,
27
+ data: {},
28
+ msg: '操作失败!',
29
+ };
30
+
31
+ export const success = (res: Partial<ResponseMsg> = defaultSuccess) => defu(res, defaultSuccess);
32
+
33
+ export const fail = (res: Partial<ResponseMsg> = defaultSuccess) => defu(res, defaultFail);
34
+
35
+ declare module '@midwayjs/core' {
36
+ interface Context {
37
+ helper: {
38
+ success: typeof success;
39
+ fail: typeof fail;
40
+ };
41
+ }
42
+ }
@@ -0,0 +1,31 @@
1
+ /*
2
+ * @Author: zhangyang
3
+ * @Date: 2022-12-27 11:08:29
4
+ * @LastEditTime: 2022-12-27 14:28:06
5
+ * @Description:
6
+ */
7
+
8
+ /**
9
+ * 接口响应的数据结构
10
+ */
11
+ interface ResponseMsg {
12
+ /**
13
+ * 状态码
14
+ */
15
+ code: Code;
16
+ /**
17
+ * 消息提示
18
+ */
19
+ msg: string;
20
+ /**
21
+ * 响应的数据
22
+ */
23
+ data: any;
24
+ }
25
+
26
+ interface Paginition {
27
+ pageNum?: number;
28
+ pageSize?: number;
29
+ total?: number;
30
+ noPagination?: boolean;
31
+ }
@@ -0,0 +1,24 @@
1
+ {
2
+ "compileOnSave": true,
3
+ "compilerOptions": {
4
+ "target": "es2018",
5
+ "module": "CommonJS",
6
+ "moduleResolution": "NodeNext",
7
+ "experimentalDecorators": true,
8
+ "emitDecoratorMetadata": true,
9
+ "inlineSourceMap":true,
10
+ "noImplicitThis": true,
11
+ "noUnusedLocals": true,
12
+ "stripInternal": true,
13
+ "skipLibCheck": true,
14
+ "pretty": true,
15
+ "declaration": true,
16
+ "forceConsistentCasingInFileNames": true,
17
+ "typeRoots": ["./typings", "./node_modules/@types"],
18
+ "outDir": "dist"
19
+ },
20
+ "exclude": [
21
+ "dist",
22
+ "node_modules"
23
+ ]
24
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "recommendations": [
3
+ "vue.volar",
4
+ "rome.rome",
5
+ "obkoro1.korofileheader",
6
+ "vue.vscode-typescript-vue-plugin",
7
+ "antfu.unocss",
8
+ "voorjaar.windicss-intellisense"
9
+ ]
10
+ }
@@ -0,0 +1,108 @@
1
+ {
2
+ "list-add-admin": {
3
+ "prefix": "list-add",
4
+ "body": [
5
+ "<route lang=\"yaml\">",
6
+ "meta:",
7
+ " title: $1",
8
+ " authPath: $2",
9
+ "</route>",
10
+ "",
11
+ "<script lang=\"ts\" setup>",
12
+ "import { useFormMode, YoungDialog, YoungPagination, YoungTable, YoungSelect } from '@bluesyoung/ui-vue3-element-plus';",
13
+ "import type { TableHeadItem, TableDataItem, SelectOptionItem } 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
+ "const FORM_TEMP: Form = {};",
20
+ "const {",
21
+ " isAdd,",
22
+ " isEdit,",
23
+ " edit,",
24
+ " del,",
25
+ " sure,",
26
+ " clear,",
27
+ " form,",
28
+ " formRef,",
29
+ " validForm",
30
+ "} = useFormMode<Form>(FORM_TEMP, {",
31
+ " addCbk: async () => {",
32
+ " const res = await validForm() as boolean;",
33
+ " if (res) {",
34
+ " const v = deepClone(form.value);",
35
+ " // await apis.post.addUserItem(v);",
36
+ " ElMessage.success('新增成功!');",
37
+ " }",
38
+ " return res;",
39
+ " },",
40
+ " modCbk: async () => {",
41
+ " const res = await validForm() as boolean;",
42
+ " if (res) {",
43
+ " const v = deepClone(form.value);",
44
+ " // await apis.patch.changeUserItem(v);",
45
+ " ElMessage.success('修改成功!');",
46
+ " }",
47
+ " return res;",
48
+ " },",
49
+ " delCbk: async (row) => {",
50
+ " // await apis.delete.deleteUser(row.id.toString());",
51
+ " ElMessage.success('删除成功!');",
52
+ " query.pageNum = 1;",
53
+ " },",
54
+ " cgEffect: () => getList()",
55
+ "});",
56
+ "const tableHead: TableHeadItem<Form>[] = [",
57
+ " { prop: '', label: '' },",
58
+ "];",
59
+ "interface Query extends BaseQuery {};",
60
+ "const query = reactive<Query>({",
61
+ " pageNum: 1,",
62
+ " pageSize: 50,",
63
+ " total: 0,",
64
+ "});",
65
+ "",
66
+ "const tableData = ref<TableDataItem<Form>[]>([]);",
67
+ "const getList = async () => {",
68
+ " // const { list, pageNum, pageSize, total } = await apis.get.getUserList(query);",
69
+ " // tableData.value = deepClone(list || []);",
70
+ " // query.pageNum = +pageNum || 1;",
71
+ " // query.pageSize = +pageSize || 50;",
72
+ " // query.total = +total || 0;",
73
+ "};",
74
+ "",
75
+ "getList();",
76
+ "</script>",
77
+ "",
78
+ "<template>",
79
+ " <div class=\"flex\">",
80
+ " <div class=\"m-2\">",
81
+ " <ElInput v-model=\"query.\" placeholder=\"请输入\" />",
82
+ " </div>",
83
+ " <div class=\"m-2\">",
84
+ " <ElButton type=\"primary\" @click=\"getList\">搜索</ElButton>",
85
+ " </div>",
86
+ " <div class=\"m-2\">",
87
+ " <ElButton type=\"success\" @click=\"isAdd = true\">添加</ElButton>",
88
+ " </div>",
89
+ " </div>",
90
+ " <div class=\"m-2\">",
91
+ " <YoungTable :table-data=\"tableData\" :table-head=\"tableHead\" :table-height=\"680\" />",
92
+ " <YoungPagination v-show=\"query.total > 0\" v-model:page=\"query.pageNum\" v-model:limit=\"query.pageSize\"",
93
+ " :total=\"query.total\" @page-change=\"getList\" />",
94
+ " </div>",
95
+ " <YoungDialog :is-add=\"isAdd\" :is-edit=\"isEdit\" width=\"520px\" @sure=\"sure\" @clear=\"clear\">",
96
+ " <template #body>",
97
+ " <ElForm ref=\"formRef\" :model=\"form\" label-width=\"100px\">",
98
+ " <ElFormItem label=\"\" prop=\"\">",
99
+ " <ElInput v-model=\"form.\" class=\"!w-300px\" />",
100
+ " </ElFormItem>",
101
+ " </ElForm>",
102
+ " </template>",
103
+ " </YoungDialog>",
104
+ "</template>",
105
+ ],
106
+ "description": "list-add-admin"
107
+ }
108
+ }