feat:新增全局默认参数配置

This commit is contained in:
张益铭
2021-03-23 17:43:53 +08:00
parent 01c8619124
commit 0ee38c24c8
7 changed files with 68 additions and 12 deletions

25
src/config/index.ts Normal file
View File

@@ -0,0 +1,25 @@
let config: object = {}
const setConfig = (cfg?: any) => {
config = Object.assign(config, cfg)
}
const getConfig = (key?: string) => {
if (typeof key === "string") {
const arr = key.split(".")
if (arr && arr.length) {
let data = config
arr.forEach(v => {
if (data && typeof data[v] !== "undefined") {
data = data[v]
} else {
data = null
}
})
return data
}
}
return config
}
export { getConfig, setConfig }