mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-11-09 13:53:38 +08:00
feat:新增全局默认参数配置
This commit is contained in:
25
src/config/index.ts
Normal file
25
src/config/index.ts
Normal 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 }
|
||||
Reference in New Issue
Block a user