create-aomex 0.0.22 → 0.0.24

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-aomex",
3
- "version": "0.0.22",
3
+ "version": "0.0.24",
4
4
  "repository": "git@github.com:aomex/create-aomex.git",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -31,26 +31,26 @@
31
31
  "bin": "dist/index.js",
32
32
  "packageManager": "pnpm@9.4.0",
33
33
  "dependencies": {
34
- "@aomex/console": "^3.2.3",
35
- "@aomex/core": "^3.2.3",
34
+ "@aomex/console": "^3.2.4",
35
+ "@aomex/core": "^3.2.4",
36
36
  "@inquirer/prompts": "^6.0.1",
37
37
  "lodash.kebabcase": "^4.1.1",
38
38
  "yargs-parser": "^21.1.1"
39
39
  },
40
40
  "devDependencies": {
41
- "@aomex/async-trace": "^3.2.3",
42
- "@aomex/cache": "^3.2.3",
43
- "@aomex/cache-redis-adapter": "^3.2.3",
44
- "@aomex/compress": "^3.2.3",
45
- "@aomex/cors": "^3.2.3",
46
- "@aomex/cron": "^3.2.3",
47
- "@aomex/etag": "^3.2.3",
48
- "@aomex/helmet": "^3.2.3",
49
- "@aomex/http-logger": "^3.2.3",
50
- "@aomex/openapi": "^3.2.3",
51
- "@aomex/response-time": "^3.2.3",
52
- "@aomex/swagger-ui": "^3.2.3",
53
- "@aomex/web": "^3.2.3",
41
+ "@aomex/async-trace": "^3.2.4",
42
+ "@aomex/cache": "^3.2.4",
43
+ "@aomex/cache-redis-adapter": "^3.2.4",
44
+ "@aomex/compress": "^3.2.4",
45
+ "@aomex/cors": "^3.2.4",
46
+ "@aomex/cron": "^3.2.4",
47
+ "@aomex/etag": "^3.2.4",
48
+ "@aomex/helmet": "^3.2.4",
49
+ "@aomex/http-logger": "^3.2.4",
50
+ "@aomex/openapi": "^3.2.4",
51
+ "@aomex/response-time": "^3.2.4",
52
+ "@aomex/swagger-ui": "^3.2.4",
53
+ "@aomex/web": "^3.2.4",
54
54
  "@prisma/client": "^5.17.0",
55
55
  "@types/lodash.kebabcase": "^4.1.9",
56
56
  "@types/node": "^20.14.12",
@@ -4,7 +4,7 @@ import { traceMiddleware } from '@aomex/async-trace';
4
4
  import { cache } from './services/cache.service';
5
5
 
6
6
  const app = new ConsoleApp({
7
- locale: 'zh_CN',
7
+ language: 'zh_CN',
8
8
  mount: [
9
9
  cron({
10
10
  commanders: './src/commanders',
@@ -1,9 +1,17 @@
1
1
  import { I18n } from '@aomex/core';
2
- import { locales } from './locales';
2
+ import { resources } from './locales';
3
3
 
4
4
  export const i18n = new I18n({
5
- locales,
5
+ resources,
6
6
  defaultLanguage: 'zh_CN',
7
+ languageAlias: {
8
+ 'zh': 'zh_CN',
9
+ 'zh-*': 'zh_CN',
10
+ 'zh_*': 'zh_CN',
11
+ 'en': 'en_US',
12
+ 'en-*': 'en_US',
13
+ 'en_*': 'en_US',
14
+ },
7
15
  });
8
16
 
9
17
  // 检查不同语言包的缺失字段(相对于默认语言)
@@ -1,7 +1,7 @@
1
1
  import { en } from './en-us';
2
2
  import { zh } from './zh-cn';
3
3
 
4
- export const locales = {
4
+ export const resources = {
5
5
  zh_CN: zh,
6
6
  en_US: en,
7
7
  };
@@ -8,10 +8,15 @@ import { responseTime } from '@aomex/response-time';
8
8
  import { traceMiddleware } from '@aomex/async-trace';
9
9
  import { swaggerUI } from '@aomex/swagger-ui';
10
10
  import { generateOpenapi } from '@aomex/openapi';
11
+ import { I18n, middleware } from '@aomex/core';
11
12
 
12
13
  export const app = new WebApp({
13
- locale: 'zh_CN',
14
+ language: 'zh_CN',
14
15
  mount: [
16
+ middleware.web((ctx, next) => {
17
+ // 动态选择i18n语言包
18
+ return I18n.provider(ctx.request.accept.language()[0] || 'zh_CN', next);
19
+ }),
15
20
  httpLogger(),
16
21
  responseTime,
17
22
  traceMiddleware('生命周期', async (_record) => {