初始化项目
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
// ** 本文件是config.js的默认数据 (请勿修改本文件中的内容)
|
||||
// ** 如需修改配置请移步到根目录的config.js文件
|
||||
export default {
|
||||
|
||||
// 系统名称
|
||||
name: "萤火商城2.0",
|
||||
|
||||
/**
|
||||
* 后端api地址 (必填; 斜杠/结尾; 请确保能访问)
|
||||
* 例如: https://www.你的域名.com/index.php?s=/api/
|
||||
*/
|
||||
apiUrl: "./index.php?s=/api/",
|
||||
|
||||
/**
|
||||
* 是否启用商城设置缓存
|
||||
* 正式运营时启用, 将减少用户端重复请求
|
||||
*/
|
||||
enabledSettingCache: false,
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import config from '@/config.js'
|
||||
import defaultConfig from './defaultConfig.js'
|
||||
|
||||
// 合并用户配置和默认配置
|
||||
const mergeConfig = Object.assign({}, defaultConfig, config)
|
||||
|
||||
/**
|
||||
* 配置文件工具类
|
||||
* mix: 如需在项目中获取配置项, 请使用本工具类的方法, 不要直接import根目录的config.js
|
||||
*/
|
||||
export default {
|
||||
// 获取全部配置
|
||||
all() {
|
||||
return mergeConfig
|
||||
},
|
||||
|
||||
// 获取指定配置
|
||||
get(key, def = undefined) {
|
||||
if (mergeConfig.hasOwnProperty(key)) {
|
||||
return mergeConfig[key]
|
||||
}
|
||||
console.error(`检测到不存在的配置项: ${key}`)
|
||||
return def
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user