feat(mobile-h5): export ENV_BANNER from APP_ENV
Add buildEnvBanner so the homepage can show a non-prod stripe without hardcoding environment labels. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
f5c999f633
commit
a47a7db7dc
2 files changed
+39
-1
No files matched your search
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* 微信公众平台须为对应环境配置 request / 业务域名(HTTPS)
|
||||
*/
|
||||
export const APP_ENV = 'prod' // 'local' | 'test' | 'prod'
|
||||
export const APP_ENV = 'local' // 'local' | 'test' | 'prod'
|
||||
|
||||
const ENV_PRESETS = {
|
||||
local: {
|
||||
@@ -53,3 +53,16 @@ export const MP_QRCODE_URL = '/static/mp-qrcode.png'
|
||||
|
||||
/** 绑定 H5 路径(相对 OA_H5_ORIGIN) */
|
||||
export const MP_BIND_H5_PATH = '/oa-mp-bind/'
|
||||
|
||||
/** 首页非生产环境色条描述(prod / 未知值不展示) */
|
||||
export function buildEnvBanner(appEnv) {
|
||||
if (appEnv === 'local') {
|
||||
return { show: true, label: '本地环境', tone: 'local' }
|
||||
}
|
||||
if (appEnv === 'test') {
|
||||
return { show: true, label: '测试环境', tone: 'test' }
|
||||
}
|
||||
return { show: false, label: '', tone: '' }
|
||||
}
|
||||
|
||||
export const ENV_BANNER = buildEnvBanner(APP_ENV)
|
||||
@@ -0,0 +1,25 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import { buildEnvBanner } from './config.js'
|
||||
|
||||
assert.deepEqual(buildEnvBanner('local'), {
|
||||
show: true,
|
||||
label: '本地环境',
|
||||
tone: 'local'
|
||||
})
|
||||
assert.deepEqual(buildEnvBanner('test'), {
|
||||
show: true,
|
||||
label: '测试环境',
|
||||
tone: 'test'
|
||||
})
|
||||
assert.deepEqual(buildEnvBanner('prod'), {
|
||||
show: false,
|
||||
label: '',
|
||||
tone: ''
|
||||
})
|
||||
assert.deepEqual(buildEnvBanner('unknown'), {
|
||||
show: false,
|
||||
label: '',
|
||||
tone: ''
|
||||
})
|
||||
|
||||
console.log('env-banner.test.js: ok')
|
||||
Reference in new issue
Block a user