第一次提交
This commit is contained in:
46
core/config/defaultConfig.js
Executable file
46
core/config/defaultConfig.js
Executable file
@@ -0,0 +1,46 @@
|
||||
// ** 本文件是config.js的默认数据 (请勿修改本文件中的内容)
|
||||
// ** 如需修改配置请移步到根目录的config.js文件
|
||||
export default {
|
||||
|
||||
// 系统名称
|
||||
name: "WebSoftApp",
|
||||
|
||||
/**
|
||||
* 后端api地址 (必填; 斜杠/结尾; 请确保能访问)
|
||||
* 例如: https://www.你的域名.com/index.php?s=/api/
|
||||
*/
|
||||
apiUrl: "https://open.gxwebsoft.com/api",
|
||||
|
||||
/**
|
||||
* 商城ID (必填)
|
||||
* 可在超管后台-商城列表中查看
|
||||
*/
|
||||
storeId: 10001,
|
||||
|
||||
// 租户ID
|
||||
tenantId: 10048,
|
||||
|
||||
/**
|
||||
* 是否启用商城设置缓存
|
||||
* 将减少用户端重复请求; 正式运营时请设为true, 开启后商城设置同步前端需10分钟缓存
|
||||
*/
|
||||
enabledSettingCache: true,
|
||||
|
||||
/**
|
||||
* 是否开启APP端的微信分享功能
|
||||
* 如果开启, 需配置manifest.json中 APP模块配置 -> Share(分享) -> 微信分享
|
||||
*/
|
||||
enabledAppShareWeixin: false,
|
||||
|
||||
/**
|
||||
* 是否启用H5端多开
|
||||
* 启用后将通过获取子域名中的ID作为storeId; 例如域名是 "shop10001.baidu.com", 那么storeId就是10001
|
||||
*/
|
||||
enabledH5Multi: false,
|
||||
|
||||
/**
|
||||
* 获取子域名ID的正则
|
||||
*/
|
||||
domainIdRegex: /shop[\-]?(\d+)\./
|
||||
|
||||
}
|
||||
54
core/config/index.js
Executable file
54
core/config/index.js
Executable file
@@ -0,0 +1,54 @@
|
||||
import config from '@/config.js'
|
||||
import defaultConfig from './defaultConfig.js'
|
||||
|
||||
// 合并用户配置和默认配置
|
||||
const options = Object.assign({}, defaultConfig, config)
|
||||
|
||||
/**
|
||||
* 配置文件工具类
|
||||
* @module Config
|
||||
* mix: 如需在项目中获取配置项, 请使用本工具类的方法, 不要直接import根目录的config.js
|
||||
*/
|
||||
export default {
|
||||
|
||||
/**
|
||||
* 获取全部配置
|
||||
*/
|
||||
all() {
|
||||
return options
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取指定配置
|
||||
* @param {string} key
|
||||
* @param {mixed} def
|
||||
*/
|
||||
get(key, def = undefined) {
|
||||
if (options.hasOwnProperty(key)) {
|
||||
return options[key]
|
||||
}
|
||||
console.error(`检测到不存在的配置项: ${key}`)
|
||||
return def
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取当前商城ID
|
||||
*/
|
||||
getStoreId() {
|
||||
|
||||
// #ifdef H5
|
||||
// 判断是否启用H5端多开
|
||||
// 启用后将通过获取子域名中的ID作为storeId
|
||||
if (this.get('enabledH5Multi')) {
|
||||
const domain = window.location.hostname
|
||||
const regex = this.get('domainIdRegex')
|
||||
if (domain.match(regex)) {
|
||||
const storeId = regex.exec(domain)[1].trim()
|
||||
return storeId
|
||||
}
|
||||
}
|
||||
// #endif
|
||||
return this.get('storeId')
|
||||
},
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user