fix(sites): add saas sites env (#1385)

This commit is contained in:
gimmyhehe 2024-02-07 11:45:42 +08:00 committed by GitHub
parent d051bea3a0
commit e97eb93323
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 9 additions and 25 deletions

View File

@ -5,4 +5,5 @@ VITE_TINY_THEME='saas'
# 官网应用类型pc / mobile / mobile-first
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_PLAYGROUND_URL=/vue-saas-playground
VITE_PLAYGROUND_URL=/vue-saas-playground
VITE_PLAYGROUND_VERIOSN=${playgroudVersion}

View File

@ -6,4 +6,5 @@ VITE_TINY_THEME='saas'
VITE_APP_MODE='pc'
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}

View File

@ -6,4 +6,5 @@ VITE_TINY_THEME='saas'
VITE_APP_MODE='pc'
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}

View File

@ -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 cdnHost = localStorage.getItem('setting-cdn')
const getRuntime = (version) => {
if (isSaas) {
return import.meta.env.VITE_APP_BUILD_BASE_URL
}
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 useVersion = import.meta.env.VITE_PLAYGROUND_VERIOSN || version
return `${cdnHost}/@opentiny/vue@${useVersion}/runtime/`
}
const createImportMap = (version) => {
@ -67,10 +52,9 @@ const createImportMap = (version) => {
}
if (isSaas) {
imports['@opentiny/vue-icon'] = `${getRuntime(version)}tiny-vue-icon-saas.mjs`
imports[`@opentiny/vue-design-saas`] = `${getRuntime(version)}tiny-vue-design-saas.js`
}
return {
imports: changeImportSuffix(imports, version)
imports
}
}
@ -78,9 +62,6 @@ const getTinyTheme = (version) => {
if (isMobileFirst) {
return `${getRuntime(version)}tailwind.css`
}
if (isSaas) {
return `${getRuntime(version)}index.css`
}
let theme = tinyTheme
if (!['smb', 'default', 'aurora', 'saas'].includes(theme)) {
theme = 'default'