Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuyunling committed Dec 4, 2019
1 parent f7edba7 commit 060477e
Show file tree
Hide file tree
Showing 12 changed files with 11,020 additions and 27 deletions.
2 changes: 2 additions & 0 deletions app/controller/home.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ function validate() {
const oldAsyncFunc = descriptor.value;
descriptor.value = async function(ctx: Context) {
console.info('validate in', propertyKey, ctx.app.config.HOME);
console.info('validate in', propertyKey, ctx.app.config.logger.aaaa); // 这个关联不了
console.info('validate in', propertyKey, ctx.app.config.test2.aa); // 这个可以关联
await oldAsyncFunc.call(this, ctx);
};
};
Expand Down
60 changes: 45 additions & 15 deletions config/config.default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,27 @@

import { EggAppConfig, PowerPartial } from 'egg';

export interface BizConfig {
sourceUrl: string;
news: {
pageSize: number;
serverUrl: string;
};
logger: {
level?: 'info' | 'all';
aaaa: boolean
};
test: string,
test2: {
aa: boolean
}
local: {
msg: number
}
}

export default function(appInfo: EggAppConfig) {
const config = {} as PowerPartial<EggAppConfig>;
const config = {} as PowerPartial<EggAppConfig> & BizConfig;

config.keys = appInfo.name + '123123';

Expand Down Expand Up @@ -31,20 +50,31 @@ export default function(appInfo: EggAppConfig) {
db: 0,
},
};
config.test = 'xxxx'
config.test2 = {
aa: true
}
config.logger = {
level: undefined,
aaaa: true
}
config.local = {
msg: 111
}
return config
// const bizConfig = {
// local: {
// msg: 'local',
// },

const bizConfig = {
local: {
msg: 'local',
},
// uuid: {
// name: 'ebuuid',
// maxAge: 1000 * 60 * 60 * 24 * 365 * 10,
// },
// };

uuid: {
name: 'ebuuid',
maxAge: 1000 * 60 * 60 * 24 * 365 * 10,
},
};

return {
...config as {},
...bizConfig,
};
// return {
// ...config as {},
// ...bizConfig,
// };
}
Loading

0 comments on commit 060477e

Please sign in to comment.