create-meadminjs 1.0.1 → 1.0.2
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/package.json +1 -1
- package/template/meadmin/README.md +12 -1
- package/template/meadmin/packageTemplate.json +4 -4
- package/template/meadmin/src/app/admin/controller/userFile.controller.ts +84 -84
- package/template/meadmin/src/app/index/controller/file.controller.ts +2 -54
- package/template/meadmin/src/app/index/middleware/index.middleware.ts +1 -1
- package/template/meadmin/src/config/config.default.ts +154 -154
- package/template/meadmin/src/configuration.ts +107 -107
- package/template/meadmin/src/entities/abstract/base.entity.ts +40 -1
- package/template/meadmin/src/fileManage/storage/local.ts +93 -93
- package/template/meadmin/view/admin/src/components/meVxeTable/index.vue +2 -2
- package/template/meadmin/view/admin/src/config/login.ts +1 -1
- package/template/meadmin/view/admin/src/layout/components/header/components/topBar/components/right/components/user.vue +2 -7
- package/template/meadmin/view/index/src/app.ts +39 -39
- package/template/meadmin/view/index/src/components/meDialog/index.vue +3 -1
- package/template/meadmin/view/index/src/components/meVxeTable/index.vue +2 -2
- package/template/meadmin/view/index/src/components/service/meImageViewer.ts +6 -2
- package/template/meadmin/view/index/src/config/login.ts +1 -1
- package/template/meadmin/view/index/src/main.ts +1 -1
- package/template/meadmin/view/index/src/utils/cookies.ts +59 -59
- package/template/meadmin/view/index/src/utils/request.ts +2 -2
- package/template/meadmin/view/index/types/auto-imports.d.ts +0 -1
- package/template/meadmin/view/index/types/components.d.ts +2 -2
package/package.json
CHANGED
|
@@ -32,10 +32,21 @@ Me-admin 是一个免费开源的后台解决方案,后端基于medwayjs ,前台
|
|
|
32
32
|
|
|
33
33
|
### 调试项目
|
|
34
34
|
|
|
35
|
-
在项目根目录执行 `pnpm dev`
|
|
35
|
+
- 在项目根目录执行 `pnpm dev`
|
|
36
|
+
- 后台访问 [http://127.0.0.1:7001/admin](http://127.0.0.1:7001/admin)
|
|
37
|
+
- 前台访问 [http://127.0.0.1:7001/](http://127.0.0.1:7001/)
|
|
36
38
|
|
|
37
39
|
### 打包项目
|
|
38
40
|
- pnpm build
|
|
39
41
|
|
|
42
|
+
### 默认账户
|
|
43
|
+
|
|
44
|
+
## 后台
|
|
45
|
+
默认账户 admin
|
|
46
|
+
默认密码 meAdmin#202507!P
|
|
47
|
+
|
|
48
|
+
## 前台
|
|
49
|
+
默认账户 test
|
|
50
|
+
默认密码 123456789
|
|
40
51
|
|
|
41
52
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "my-midway-esm-project",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"private": true,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@meadmin/cli": "^1.0.
|
|
9
|
-
"@meadmin/core": "^1.0.
|
|
10
|
-
"@meadmin/midway-vite-view": "^1.0.
|
|
8
|
+
"@meadmin/cli": "^1.0.2",
|
|
9
|
+
"@meadmin/core": "^1.0.2",
|
|
10
|
+
"@meadmin/midway-vite-view": "^1.0.2",
|
|
11
11
|
"@midwayjs/bootstrap": "^3.20.11",
|
|
12
12
|
"@midwayjs/busboy": "3.20.19",
|
|
13
13
|
"@midwayjs/cache-manager": "^3.20.11",
|
|
@@ -1,84 +1,84 @@
|
|
|
1
|
-
import { AdminPermission, ApiOperationResponse } from '@/decorators/index.js';
|
|
2
|
-
import { uploadStorage } from '@/fileManage/index.js';
|
|
3
|
-
import { UploadMiddleware, UploadStreamFileInfo } from '@midwayjs/busboy';
|
|
4
|
-
import { Body, Controller, Fields, Files, Get, Inject, Param, Post } from '@midwayjs/core';
|
|
5
|
-
import { ApiBody, BodyContentType } from '@midwayjs/swagger';
|
|
6
|
-
import { UserFile } from '../../../entities/userFile.entity.js';
|
|
7
|
-
import { UserFileQueryDto } from '../dto/userFileQuery.dto.js';
|
|
8
|
-
import { UserFileUpDto } from '../dto/userFileUp.dto.js';
|
|
9
|
-
import { UserFileUpdateDto } from '../dto/userFileUpdate.dto.js';
|
|
10
|
-
import { UserFileService } from '../service/userFile.service.js';
|
|
11
|
-
import { BaseController } from './base.controller.js';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* 为了防止防火墙禁止PUT、DELETE请求,方便传参,除详情外统一使用post请求。
|
|
15
|
-
* meadmin对controller做了装饰器继承封装,当以/开头时会使用当前controller前缀地址,不以/开头时会递归继承controller前缀地址
|
|
16
|
-
*/
|
|
17
|
-
@Controller('userFile')
|
|
18
|
-
export class UserFileController extends BaseController {
|
|
19
|
-
@Inject()
|
|
20
|
-
userFileService: UserFileService;
|
|
21
|
-
|
|
22
|
-
@Post('/upload', { middleware: [UploadMiddleware] })
|
|
23
|
-
@ApiBody({
|
|
24
|
-
contentType: BodyContentType.Multipart,
|
|
25
|
-
schema: {
|
|
26
|
-
type: UserFileUpDto,
|
|
27
|
-
},
|
|
28
|
-
})
|
|
29
|
-
@ApiOperationResponse({
|
|
30
|
-
responseType: File,
|
|
31
|
-
summary: '上传附件',
|
|
32
|
-
description: '如果data为{}代表分片上传成功,为Fule对象代表文件上传完成(可能已存在秒传成功)',
|
|
33
|
-
})
|
|
34
|
-
async upload(@Files() files: Array<UploadStreamFileInfo>, @Fields() params: UserFileUpDto) {
|
|
35
|
-
const file = files[0]; //只获取一个文件,不支持多文件数组
|
|
36
|
-
const res = await uploadStorage.localStorage('index').upload(file, params);
|
|
37
|
-
return this.success(res ? await this.userFileService.create(res) : {});
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
//接口方法必须加async 方法的接口装饰器值必须/开头
|
|
41
|
-
@Post('/')
|
|
42
|
-
@ApiOperationResponse({
|
|
43
|
-
responsePage: UserFile,
|
|
44
|
-
summary: '获取用户附件表(前台)列表',
|
|
45
|
-
})
|
|
46
|
-
@AdminPermission('UserFileList')
|
|
47
|
-
async list(@Body() queryDto: UserFileQueryDto) {
|
|
48
|
-
return this.success(await this.userFileService.list(queryDto));
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
//接口方法必须加async 方法的接口装饰器值必须/开头
|
|
52
|
-
@Get('/info/:id')
|
|
53
|
-
@ApiOperationResponse({
|
|
54
|
-
responseType: UserFile,
|
|
55
|
-
summary: '根据id获取用户附件表(前台)详情',
|
|
56
|
-
})
|
|
57
|
-
@AdminPermission('UserFileEdit')
|
|
58
|
-
async findOne(@Param('id') id: string) {
|
|
59
|
-
const entity = await this.userFileService.findOne(id);
|
|
60
|
-
return this.success(entity);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
//接口方法必须加async 方法的接口装饰器值必须/开头
|
|
64
|
-
@Post('/up/:id')
|
|
65
|
-
@ApiOperationResponse({
|
|
66
|
-
responseType: UserFile,
|
|
67
|
-
summary: '根据id更新用户附件表(前台)详情',
|
|
68
|
-
})
|
|
69
|
-
@AdminPermission('UserFileEdit')
|
|
70
|
-
async update(@Param('id') id: string, @Body() updateDto: UserFileUpdateDto) {
|
|
71
|
-
return this.success(await this.userFileService.update(id, updateDto));
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
//接口方法必须加async 方法的接口装饰器值必须/开头
|
|
75
|
-
@Post('/del/:id')
|
|
76
|
-
@ApiOperationResponse({
|
|
77
|
-
summary: '根据id删除用户附件表(前台)信息',
|
|
78
|
-
})
|
|
79
|
-
@AdminPermission('UserFileDel')
|
|
80
|
-
async delete(@Param('id') id: string) {
|
|
81
|
-
await this.userFileService.remove(id);
|
|
82
|
-
return this.success();
|
|
83
|
-
}
|
|
84
|
-
}
|
|
1
|
+
import { AdminPermission, ApiOperationResponse } from '@/decorators/index.js';
|
|
2
|
+
import { uploadStorage } from '@/fileManage/index.js';
|
|
3
|
+
import { UploadMiddleware, UploadStreamFileInfo } from '@midwayjs/busboy';
|
|
4
|
+
import { Body, Controller, Fields, Files, Get, Inject, Param, Post } from '@midwayjs/core';
|
|
5
|
+
import { ApiBody, BodyContentType } from '@midwayjs/swagger';
|
|
6
|
+
import { UserFile } from '../../../entities/userFile.entity.js';
|
|
7
|
+
import { UserFileQueryDto } from '../dto/userFileQuery.dto.js';
|
|
8
|
+
import { UserFileUpDto } from '../dto/userFileUp.dto.js';
|
|
9
|
+
import { UserFileUpdateDto } from '../dto/userFileUpdate.dto.js';
|
|
10
|
+
import { UserFileService } from '../service/userFile.service.js';
|
|
11
|
+
import { BaseController } from './base.controller.js';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* 为了防止防火墙禁止PUT、DELETE请求,方便传参,除详情外统一使用post请求。
|
|
15
|
+
* meadmin对controller做了装饰器继承封装,当以/开头时会使用当前controller前缀地址,不以/开头时会递归继承controller前缀地址
|
|
16
|
+
*/
|
|
17
|
+
@Controller('userFile')
|
|
18
|
+
export class UserFileController extends BaseController {
|
|
19
|
+
@Inject()
|
|
20
|
+
userFileService: UserFileService;
|
|
21
|
+
|
|
22
|
+
@Post('/upload', { middleware: [UploadMiddleware] })
|
|
23
|
+
@ApiBody({
|
|
24
|
+
contentType: BodyContentType.Multipart,
|
|
25
|
+
schema: {
|
|
26
|
+
type: UserFileUpDto,
|
|
27
|
+
},
|
|
28
|
+
})
|
|
29
|
+
@ApiOperationResponse({
|
|
30
|
+
responseType: File,
|
|
31
|
+
summary: '上传附件',
|
|
32
|
+
description: '如果data为{}代表分片上传成功,为Fule对象代表文件上传完成(可能已存在秒传成功)',
|
|
33
|
+
})
|
|
34
|
+
async upload(@Files() files: Array<UploadStreamFileInfo>, @Fields() params: UserFileUpDto) {
|
|
35
|
+
const file = files[0]; //只获取一个文件,不支持多文件数组
|
|
36
|
+
const res = await uploadStorage.localStorage('index').upload(file, params);
|
|
37
|
+
return this.success(res ? await this.userFileService.create(res) : {});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
//接口方法必须加async 方法的接口装饰器值必须/开头
|
|
41
|
+
@Post('/')
|
|
42
|
+
@ApiOperationResponse({
|
|
43
|
+
responsePage: UserFile,
|
|
44
|
+
summary: '获取用户附件表(前台)列表',
|
|
45
|
+
})
|
|
46
|
+
@AdminPermission('UserFileList')
|
|
47
|
+
async list(@Body() queryDto: UserFileQueryDto) {
|
|
48
|
+
return this.success(await this.userFileService.list(queryDto));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
//接口方法必须加async 方法的接口装饰器值必须/开头
|
|
52
|
+
@Get('/info/:id')
|
|
53
|
+
@ApiOperationResponse({
|
|
54
|
+
responseType: UserFile,
|
|
55
|
+
summary: '根据id获取用户附件表(前台)详情',
|
|
56
|
+
})
|
|
57
|
+
@AdminPermission('UserFileEdit')
|
|
58
|
+
async findOne(@Param('id') id: string) {
|
|
59
|
+
const entity = await this.userFileService.findOne(id);
|
|
60
|
+
return this.success(entity);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
//接口方法必须加async 方法的接口装饰器值必须/开头
|
|
64
|
+
@Post('/up/:id')
|
|
65
|
+
@ApiOperationResponse({
|
|
66
|
+
responseType: UserFile,
|
|
67
|
+
summary: '根据id更新用户附件表(前台)详情',
|
|
68
|
+
})
|
|
69
|
+
@AdminPermission('UserFileEdit')
|
|
70
|
+
async update(@Param('id') id: string, @Body() updateDto: UserFileUpdateDto) {
|
|
71
|
+
return this.success(await this.userFileService.update(id, updateDto));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
//接口方法必须加async 方法的接口装饰器值必须/开头
|
|
75
|
+
@Post('/del/:id')
|
|
76
|
+
@ApiOperationResponse({
|
|
77
|
+
summary: '根据id删除用户附件表(前台)信息',
|
|
78
|
+
})
|
|
79
|
+
@AdminPermission('UserFileDel')
|
|
80
|
+
async delete(@Param('id') id: string) {
|
|
81
|
+
await this.userFileService.remove(id);
|
|
82
|
+
return this.success();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import { ApiOperationResponse } from '@/decorators/index.js';
|
|
1
|
+
import { ApiOperationResponse, IndexPermission } from '@/decorators/index.js';
|
|
2
2
|
import { uploadStorage } from '@/fileManage/index.js';
|
|
3
3
|
import { UploadMiddleware, UploadOptions, UploadStreamFileInfo } from '@midwayjs/busboy';
|
|
4
4
|
import { Body, Config, Controller, Fields, Files, Get, Inject, Param, Post } from '@midwayjs/core';
|
|
5
5
|
import { Context } from '@midwayjs/koa';
|
|
6
6
|
import { ApiBody, BodyContentType } from '@midwayjs/swagger';
|
|
7
7
|
import { File } from '../../../entities/file.entity.js';
|
|
8
|
-
import { FileCreateDto } from '../dto/fileCreate.dto.js';
|
|
9
8
|
import { FileQueryDto } from '../dto/fileQuery.dto.js';
|
|
10
9
|
import { FileUpDto } from '../dto/fileUp.dto.js';
|
|
11
|
-
import { FileUpdateDto } from '../dto/fileUpdate.dto.js';
|
|
12
10
|
import { FileService } from '../service/file.service.js';
|
|
13
11
|
import { BaseController } from './base.controller.js';
|
|
14
12
|
|
|
@@ -52,65 +50,15 @@ export class FileController extends BaseController {
|
|
|
52
50
|
return this.success(res ? await this.fileService.create(res) : {});
|
|
53
51
|
}
|
|
54
52
|
|
|
55
|
-
//接口方法必须加async 方法的接口装饰器值必须/开头
|
|
56
|
-
@Post('/add')
|
|
57
|
-
@ApiOperationResponse({
|
|
58
|
-
responseType: File,
|
|
59
|
-
summary: '添加附件信息',
|
|
60
|
-
})
|
|
61
|
-
async add(@Body() createDto: FileCreateDto) {
|
|
62
|
-
return this.success(await this.fileService.create(createDto));
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
//接口方法必须加async 方法的接口装饰器值必须/开头
|
|
66
|
-
@Post('/')
|
|
67
|
-
@ApiOperationResponse({
|
|
68
|
-
responsePage: File,
|
|
69
|
-
summary: '获取附件列表',
|
|
70
|
-
})
|
|
71
|
-
async list(@Body() queryDto: FileQueryDto) {
|
|
72
|
-
return this.success(await this.fileService.list(queryDto));
|
|
73
|
-
}
|
|
74
|
-
|
|
75
53
|
//接口方法必须加async 方法的接口装饰器值必须/开头
|
|
76
54
|
@Post('/my')
|
|
77
55
|
@ApiOperationResponse({
|
|
78
56
|
responsePage: File,
|
|
79
57
|
summary: '获取我的附件列表',
|
|
80
58
|
})
|
|
59
|
+
@IndexPermission()
|
|
81
60
|
async my(@Body() queryDto: FileQueryDto) {
|
|
82
61
|
queryDto.createdUserId = this.ctx.userInfo.id;
|
|
83
62
|
return this.success(await this.fileService.list(queryDto));
|
|
84
63
|
}
|
|
85
|
-
|
|
86
|
-
//接口方法必须加async 方法的接口装饰器值必须/开头
|
|
87
|
-
@Get('/info/:id')
|
|
88
|
-
@ApiOperationResponse({
|
|
89
|
-
responseType: File,
|
|
90
|
-
summary: '根据id获取附件详情',
|
|
91
|
-
})
|
|
92
|
-
async findOne(@Param('id') id: string) {
|
|
93
|
-
const entity = await this.fileService.findOne(id);
|
|
94
|
-
return this.success(entity);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
//接口方法必须加async 方法的接口装饰器值必须/开头
|
|
98
|
-
@Post('/up/:id')
|
|
99
|
-
@ApiOperationResponse({
|
|
100
|
-
responseType: File,
|
|
101
|
-
summary: '根据id更新附件详情',
|
|
102
|
-
})
|
|
103
|
-
async update(@Param('id') id: string, @Body() updateDto: FileUpdateDto) {
|
|
104
|
-
return this.success(await this.fileService.update(id, updateDto));
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
//接口方法必须加async 方法的接口装饰器值必须/开头
|
|
108
|
-
@Post('/del/:id')
|
|
109
|
-
@ApiOperationResponse({
|
|
110
|
-
summary: '根据id删除附件信息',
|
|
111
|
-
})
|
|
112
|
-
async delete(@Param('id') id: string) {
|
|
113
|
-
await this.fileService.remove(id);
|
|
114
|
-
return this.success();
|
|
115
|
-
}
|
|
116
64
|
}
|
|
@@ -1,154 +1,154 @@
|
|
|
1
|
-
import { uploadWhiteList } from '@midwayjs/busboy';
|
|
2
|
-
import { createRedisStore } from '@midwayjs/cache-manager';
|
|
3
|
-
import { MidwayConfig } from '@midwayjs/core';
|
|
4
|
-
import { TranslateOptions } from '@midwayjs/i18n';
|
|
5
|
-
import { resolve } from 'path';
|
|
6
|
-
import { formatText } from '../helper/utils.js';
|
|
7
|
-
import database from './database.js';
|
|
8
|
-
//配置文件避免出现@/等alisa,path引用
|
|
9
|
-
export default {
|
|
10
|
-
// use for cookie sign key, should change to your own and keep security
|
|
11
|
-
keys: '1714030878233_897',
|
|
12
|
-
koa: {
|
|
13
|
-
port: +process.env.SERVER_PORT,
|
|
14
|
-
},
|
|
15
|
-
debug: true,
|
|
16
|
-
validate: {
|
|
17
|
-
validationOptions: {
|
|
18
|
-
allowUnknown: false, // 全局生效 允许未定义的字段
|
|
19
|
-
convert: true, // 当为true时,尝试将值转换为所需的类型(例如,将字符串转换为数字.
|
|
20
|
-
stripUnknown: true, // 全局生效,移除多余的字段
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
i18n: {
|
|
24
|
-
// 默认语言 "zh-cn"
|
|
25
|
-
defaultLocale: 'zh-cn',
|
|
26
|
-
// used to alter the behaviour of missing keys
|
|
27
|
-
missingKeyFn: function (locale, value) {
|
|
28
|
-
return value;
|
|
29
|
-
},
|
|
30
|
-
|
|
31
|
-
// 把你的翻译文本放到这里
|
|
32
|
-
localeTable: {
|
|
33
|
-
'zh-cn': {
|
|
34
|
-
validate: {
|
|
35
|
-
'string.mobile': '{{#label}} 必须是一个正确的手机号',
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
'en': {
|
|
39
|
-
default: await import('../locales/en.json', { with: { type: 'json' } }),
|
|
40
|
-
validate: await import('@midwayjs/validate/locales/en_US.json', { with: { type: 'json' } }),
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
missingKeyHandler: (message: string, options?: TranslateOptions) => (options?.args ? formatText(message, options.args) : message),
|
|
45
|
-
},
|
|
46
|
-
sequelize: await database(),
|
|
47
|
-
view: {
|
|
48
|
-
//midwayjs 视图配置 说明参考 https://midwayjs.org/docs/extensions/render
|
|
49
|
-
defaultViewEngine: 'viteView',
|
|
50
|
-
},
|
|
51
|
-
// ...
|
|
52
|
-
staticFile: {
|
|
53
|
-
dirs: {
|
|
54
|
-
default: {
|
|
55
|
-
prefix: '/',
|
|
56
|
-
dir: 'public',
|
|
57
|
-
},
|
|
58
|
-
viewAdmin: {
|
|
59
|
-
prefix: '/html/admin/',
|
|
60
|
-
dir: 'view/admin/dist',
|
|
61
|
-
},
|
|
62
|
-
viewIndex: {
|
|
63
|
-
prefix: '/html/index/',
|
|
64
|
-
dir: 'view/index/dist',
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
viteView: {
|
|
69
|
-
//midway-vite-view 配置配置详细说明见下方
|
|
70
|
-
rootDir: 'view',
|
|
71
|
-
views: {
|
|
72
|
-
admin: {
|
|
73
|
-
//相对于rootDir的前端包路径
|
|
74
|
-
// entryServer: 'admin/src/entry-server.ts',//admin暂未支持服务端渲染
|
|
75
|
-
entry: 'index.html', //html入库文件,相对于当前包路径
|
|
76
|
-
viteConfigFile: resolve(import.meta.dirname, '../../view/admin/vite.config.ts'),
|
|
77
|
-
staticFileKey: 'viewAdmin',
|
|
78
|
-
hmrPort: 23679,
|
|
79
|
-
},
|
|
80
|
-
index: {
|
|
81
|
-
//相对于rootDir的前端包路径
|
|
82
|
-
entryServer: 'src/entry-server.ts',
|
|
83
|
-
entry: 'index.html', //html入库文件,相对于当前包路径
|
|
84
|
-
viteConfigFile: resolve(import.meta.dirname, '../../view/index/vite.config.ts'),
|
|
85
|
-
staticFileKey: 'viewIndex',
|
|
86
|
-
hmrPort: 23680,
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
redis: {
|
|
91
|
-
clients: {
|
|
92
|
-
cache: {
|
|
93
|
-
host: process.env.REDIS_HOST,
|
|
94
|
-
port: process.env.REDIS_PORT,
|
|
95
|
-
password: process.env.REDIS_PASS,
|
|
96
|
-
db: 0,
|
|
97
|
-
},
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
cacheManager: {
|
|
101
|
-
//缓存配置
|
|
102
|
-
clients: {
|
|
103
|
-
admin: {
|
|
104
|
-
store: createRedisStore('cache'),
|
|
105
|
-
},
|
|
106
|
-
index: {
|
|
107
|
-
store: createRedisStore('cache'),
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
},
|
|
111
|
-
admin: {
|
|
112
|
-
login: {
|
|
113
|
-
secret: 'desec2ec3=ase$&e1#edad#$%%', //token加密平台标识
|
|
114
|
-
expiresIn: 3600000 * 6, //token过期时间ms
|
|
115
|
-
renewal: 60000 * 10, //续期时间ms
|
|
116
|
-
cacheKey: 'admin', //token使用的缓存key对应cacheManager.clients
|
|
117
|
-
},
|
|
118
|
-
auth: {
|
|
119
|
-
noLoginUrl: [`/api/admin/login/login`, `/api/admin/login/captcha`, new RegExp('/api/admin/file/get/.+')] as Array<string | RegExp>, //无需登录地址
|
|
120
|
-
},
|
|
121
|
-
},
|
|
122
|
-
index: {
|
|
123
|
-
login: {
|
|
124
|
-
secret: 'desndex=ase$&e1#edad#$%%', //token加密平台标识
|
|
125
|
-
expiresIn: 3600000 * 6, //token过期时间ms
|
|
126
|
-
renewal: 60000 * 10, //续期时间ms
|
|
127
|
-
cacheKey: 'index', //token使用的缓存key对应cacheManager.clients
|
|
128
|
-
},
|
|
129
|
-
},
|
|
130
|
-
busboy: {
|
|
131
|
-
mode: 'stream',
|
|
132
|
-
// 扩展名白名单
|
|
133
|
-
whitelist: uploadWhiteList,
|
|
134
|
-
limits: {
|
|
135
|
-
fileSize: 500 * 1024 * 1024, //上传限制 单位为byte
|
|
136
|
-
},
|
|
137
|
-
tmpdir: resolve(import.meta.dirname, '../../uploadFile/tmp'),
|
|
138
|
-
upDir: resolve(import.meta.dirname, '../../uploadFile/'),
|
|
139
|
-
cleanTimeout: 5 * 60 * 1000,
|
|
140
|
-
},
|
|
141
|
-
midwayLogger: {
|
|
142
|
-
default: {
|
|
143
|
-
transports: {
|
|
144
|
-
file: {
|
|
145
|
-
dir: resolve(import.meta.dirname, '../../logs'),
|
|
146
|
-
},
|
|
147
|
-
error: {
|
|
148
|
-
dir: resolve(import.meta.dirname, '../../logs'),
|
|
149
|
-
},
|
|
150
|
-
},
|
|
151
|
-
},
|
|
152
|
-
// ...
|
|
153
|
-
},
|
|
154
|
-
} as MidwayConfig;
|
|
1
|
+
import { uploadWhiteList } from '@midwayjs/busboy';
|
|
2
|
+
import { createRedisStore } from '@midwayjs/cache-manager';
|
|
3
|
+
import { MidwayConfig } from '@midwayjs/core';
|
|
4
|
+
import { TranslateOptions } from '@midwayjs/i18n';
|
|
5
|
+
import { resolve } from 'path';
|
|
6
|
+
import { formatText } from '../helper/utils.js';
|
|
7
|
+
import database from './database.js';
|
|
8
|
+
//配置文件避免出现@/等alisa,path引用
|
|
9
|
+
export default {
|
|
10
|
+
// use for cookie sign key, should change to your own and keep security
|
|
11
|
+
keys: '1714030878233_897',
|
|
12
|
+
koa: {
|
|
13
|
+
port: +process.env.SERVER_PORT,
|
|
14
|
+
},
|
|
15
|
+
debug: true,
|
|
16
|
+
validate: {
|
|
17
|
+
validationOptions: {
|
|
18
|
+
allowUnknown: false, // 全局生效 允许未定义的字段
|
|
19
|
+
convert: true, // 当为true时,尝试将值转换为所需的类型(例如,将字符串转换为数字.
|
|
20
|
+
stripUnknown: true, // 全局生效,移除多余的字段
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
i18n: {
|
|
24
|
+
// 默认语言 "zh-cn"
|
|
25
|
+
defaultLocale: 'zh-cn',
|
|
26
|
+
// used to alter the behaviour of missing keys
|
|
27
|
+
missingKeyFn: function (locale, value) {
|
|
28
|
+
return value;
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
// 把你的翻译文本放到这里
|
|
32
|
+
localeTable: {
|
|
33
|
+
'zh-cn': {
|
|
34
|
+
validate: {
|
|
35
|
+
'string.mobile': '{{#label}} 必须是一个正确的手机号',
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
'en': {
|
|
39
|
+
default: await import('../locales/en.json', { with: { type: 'json' } }),
|
|
40
|
+
validate: await import('@midwayjs/validate/locales/en_US.json', { with: { type: 'json' } }),
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
missingKeyHandler: (message: string, options?: TranslateOptions) => (options?.args ? formatText(message, options.args) : message),
|
|
45
|
+
},
|
|
46
|
+
sequelize: await database(),
|
|
47
|
+
view: {
|
|
48
|
+
//midwayjs 视图配置 说明参考 https://midwayjs.org/docs/extensions/render
|
|
49
|
+
defaultViewEngine: 'viteView',
|
|
50
|
+
},
|
|
51
|
+
// ...
|
|
52
|
+
staticFile: {
|
|
53
|
+
dirs: {
|
|
54
|
+
default: {
|
|
55
|
+
prefix: '/',
|
|
56
|
+
dir: 'public',
|
|
57
|
+
},
|
|
58
|
+
viewAdmin: {
|
|
59
|
+
prefix: '/html/admin/',
|
|
60
|
+
dir: 'view/admin/dist',
|
|
61
|
+
},
|
|
62
|
+
viewIndex: {
|
|
63
|
+
prefix: '/html/index/',
|
|
64
|
+
dir: 'view/index/dist',
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
viteView: {
|
|
69
|
+
//midway-vite-view 配置配置详细说明见下方
|
|
70
|
+
rootDir: 'view',
|
|
71
|
+
views: {
|
|
72
|
+
admin: {
|
|
73
|
+
//相对于rootDir的前端包路径
|
|
74
|
+
// entryServer: 'admin/src/entry-server.ts',//admin暂未支持服务端渲染
|
|
75
|
+
entry: 'index.html', //html入库文件,相对于当前包路径
|
|
76
|
+
viteConfigFile: resolve(import.meta.dirname, '../../view/admin/vite.config.ts'),
|
|
77
|
+
staticFileKey: 'viewAdmin',
|
|
78
|
+
hmrPort: 23679,
|
|
79
|
+
},
|
|
80
|
+
index: {
|
|
81
|
+
//相对于rootDir的前端包路径
|
|
82
|
+
entryServer: 'src/entry-server.ts',
|
|
83
|
+
entry: 'index.html', //html入库文件,相对于当前包路径
|
|
84
|
+
viteConfigFile: resolve(import.meta.dirname, '../../view/index/vite.config.ts'),
|
|
85
|
+
staticFileKey: 'viewIndex',
|
|
86
|
+
hmrPort: 23680,
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
redis: {
|
|
91
|
+
clients: {
|
|
92
|
+
cache: {
|
|
93
|
+
host: process.env.REDIS_HOST,
|
|
94
|
+
port: process.env.REDIS_PORT,
|
|
95
|
+
password: process.env.REDIS_PASS,
|
|
96
|
+
db: 0,
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
cacheManager: {
|
|
101
|
+
//缓存配置
|
|
102
|
+
clients: {
|
|
103
|
+
admin: {
|
|
104
|
+
store: createRedisStore('cache'),
|
|
105
|
+
},
|
|
106
|
+
index: {
|
|
107
|
+
store: createRedisStore('cache'),
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
admin: {
|
|
112
|
+
login: {
|
|
113
|
+
secret: 'desec2ec3=ase$&e1#edad#$%%', //token加密平台标识
|
|
114
|
+
expiresIn: 3600000 * 6, //token过期时间ms
|
|
115
|
+
renewal: 60000 * 10, //续期时间ms
|
|
116
|
+
cacheKey: 'admin', //token使用的缓存key对应cacheManager.clients
|
|
117
|
+
},
|
|
118
|
+
auth: {
|
|
119
|
+
noLoginUrl: [`/api/admin/login/login`, `/api/admin/login/captcha`, new RegExp('/api/admin/file/get/.+')] as Array<string | RegExp>, //无需登录地址
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
index: {
|
|
123
|
+
login: {
|
|
124
|
+
secret: 'desndex=ase$&e1#edad#$%%', //token加密平台标识
|
|
125
|
+
expiresIn: 3600000 * 6, //token过期时间ms
|
|
126
|
+
renewal: 60000 * 10, //续期时间ms
|
|
127
|
+
cacheKey: 'index', //token使用的缓存key对应cacheManager.clients
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
busboy: {
|
|
131
|
+
mode: 'stream',
|
|
132
|
+
// 扩展名白名单
|
|
133
|
+
whitelist: uploadWhiteList,
|
|
134
|
+
limits: {
|
|
135
|
+
fileSize: 500 * 1024 * 1024, //上传限制 单位为byte
|
|
136
|
+
},
|
|
137
|
+
tmpdir: resolve(import.meta.dirname, '../../uploadFile/tmp'),
|
|
138
|
+
upDir: resolve(import.meta.dirname, '../../uploadFile/'),
|
|
139
|
+
cleanTimeout: 5 * 60 * 1000,
|
|
140
|
+
},
|
|
141
|
+
midwayLogger: {
|
|
142
|
+
default: {
|
|
143
|
+
transports: {
|
|
144
|
+
file: {
|
|
145
|
+
dir: resolve(import.meta.dirname, '../../logs'),
|
|
146
|
+
},
|
|
147
|
+
error: {
|
|
148
|
+
dir: resolve(import.meta.dirname, '../../logs'),
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
// ...
|
|
153
|
+
},
|
|
154
|
+
} as MidwayConfig;
|