forked from opentiny/tiny-vue
fix(sites): add saas sites env (#1385)
This commit is contained in:
parent
d051bea3a0
commit
e97eb93323
|
@ -6,3 +6,4 @@ VITE_TINY_THEME='saas'
|
||||||
VITE_APP_MODE='pc'
|
VITE_APP_MODE='pc'
|
||||||
VITE_APP_BUILD_BASE_URL=https://test-static-resource.obs.cn-north-7.ulanqab.huawei.com/tiny-vue-saas/${staticReleaseVersion}/
|
VITE_APP_BUILD_BASE_URL=https://test-static-resource.obs.cn-north-7.ulanqab.huawei.com/tiny-vue-saas/${staticReleaseVersion}/
|
||||||
VITE_PLAYGROUND_URL=/vue-saas-playground
|
VITE_PLAYGROUND_URL=/vue-saas-playground
|
||||||
|
VITE_PLAYGROUND_VERIOSN=${playgroudVersion}
|
|
@ -7,3 +7,4 @@ VITE_APP_MODE='pc'
|
||||||
|
|
||||||
VITE_APP_BUILD_BASE_URL=https://res.hc-cdn.com/tiny-vue-saas/${staticReleaseVersion}/
|
VITE_APP_BUILD_BASE_URL=https://res.hc-cdn.com/tiny-vue-saas/${staticReleaseVersion}/
|
||||||
VITE_PLAYGROUND_URL=/vue-saas-playground
|
VITE_PLAYGROUND_URL=/vue-saas-playground
|
||||||
|
VITE_PLAYGROUND_VERIOSN=${playgroudVersion}
|
|
@ -7,3 +7,4 @@ VITE_APP_MODE='pc'
|
||||||
|
|
||||||
VITE_APP_BUILD_BASE_URL=https://res.hc-cdn.com/tiny-vue-saas/${staticReleaseVersion}/
|
VITE_APP_BUILD_BASE_URL=https://res.hc-cdn.com/tiny-vue-saas/${staticReleaseVersion}/
|
||||||
VITE_PLAYGROUND_URL=/vue-saas-playground
|
VITE_PLAYGROUND_URL=/vue-saas-playground
|
||||||
|
VITE_PLAYGROUND_VERIOSN=${playgroudVersion}
|
|
@ -32,23 +32,8 @@ const versions = ['3.13', '3.12', '3.11', '3.10', '3.9', '3.8']
|
||||||
const latestVersion = isPreview ? versions[0] : localStorage.getItem(VERSION) || versions[0]
|
const latestVersion = isPreview ? versions[0] : localStorage.getItem(VERSION) || versions[0]
|
||||||
const cdnHost = localStorage.getItem('setting-cdn')
|
const cdnHost = localStorage.getItem('setting-cdn')
|
||||||
const getRuntime = (version) => {
|
const getRuntime = (version) => {
|
||||||
if (isSaas) {
|
const useVersion = import.meta.env.VITE_PLAYGROUND_VERIOSN || version
|
||||||
return import.meta.env.VITE_APP_BUILD_BASE_URL
|
return `${cdnHost}/@opentiny/vue@${useVersion}/runtime/`
|
||||||
}
|
|
||||||
return `${cdnHost}/@opentiny/vue@${version}/runtime/`
|
|
||||||
}
|
|
||||||
|
|
||||||
const changeImportSuffix = (imports, verison) => {
|
|
||||||
const newImports = {}
|
|
||||||
Object.keys(imports).forEach((key) => {
|
|
||||||
const url = imports[key]
|
|
||||||
if (url.startsWith(getRuntime(verison))) {
|
|
||||||
newImports[key] = url.replace('.mjs', '.js')
|
|
||||||
} else {
|
|
||||||
newImports[key] = url
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return newImports
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const createImportMap = (version) => {
|
const createImportMap = (version) => {
|
||||||
|
@ -67,10 +52,9 @@ const createImportMap = (version) => {
|
||||||
}
|
}
|
||||||
if (isSaas) {
|
if (isSaas) {
|
||||||
imports['@opentiny/vue-icon'] = `${getRuntime(version)}tiny-vue-icon-saas.mjs`
|
imports['@opentiny/vue-icon'] = `${getRuntime(version)}tiny-vue-icon-saas.mjs`
|
||||||
imports[`@opentiny/vue-design-saas`] = `${getRuntime(version)}tiny-vue-design-saas.js`
|
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
imports: changeImportSuffix(imports, version)
|
imports
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,9 +62,6 @@ const getTinyTheme = (version) => {
|
||||||
if (isMobileFirst) {
|
if (isMobileFirst) {
|
||||||
return `${getRuntime(version)}tailwind.css`
|
return `${getRuntime(version)}tailwind.css`
|
||||||
}
|
}
|
||||||
if (isSaas) {
|
|
||||||
return `${getRuntime(version)}index.css`
|
|
||||||
}
|
|
||||||
let theme = tinyTheme
|
let theme = tinyTheme
|
||||||
if (!['smb', 'default', 'aurora', 'saas'].includes(theme)) {
|
if (!['smb', 'default', 'aurora', 'saas'].includes(theme)) {
|
||||||
theme = 'default'
|
theme = 'default'
|
||||||
|
|
Loading…
Reference in New Issue