fix(playground): fix old version runtime not found close #1817 (#1818)

This commit is contained in:
gimmyhehe 2024-08-05 11:16:21 +08:00 committed by GitHub
parent 9e7008edef
commit a07eeffee7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 25 additions and 11 deletions

View File

@ -6,4 +6,3 @@ VITE_TINY_THEME='saas'
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_VERIOSN=${playgroudVersion}

View File

@ -7,4 +7,3 @@ 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_VERIOSN=${playgroudVersion}

View File

@ -7,4 +7,3 @@ 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_VERIOSN=${playgroudVersion}

View File

@ -35,9 +35,25 @@ const cdnHost = localStorage.getItem('setting-cdn')
const versionDelimiter = cdnHost.includes('npmmirror') ? '/' : '@'
const fileDelimiter = cdnHost.includes('npmmirror') ? 'files/' : ''
const isOldVersion = (version) => {
const minorVersion = version?.split('.')?.[1]
return minorVersion && minorVersion < 16
}
// 3.16.0runtime
const getRuntime = (version) => {
const useVersion = import.meta.env.VITE_PLAYGROUND_VERIOSN || version
return `${cdnHost}/@opentiny/vue-runtime${versionDelimiter}${useVersion}/${fileDelimiter}dist3/`
if (isOldVersion(version)) {
return `${cdnHost}/@opentiny/vue${versionDelimiter}${version}/${fileDelimiter}runtime/`
}
return `${cdnHost}/@opentiny/vue-runtime${versionDelimiter}${version}/${fileDelimiter}dist3/`
}
// 3.16.0runtimetiny-vue-pc.mjs
const getPcRuntime = (version) => {
if (isOldVersion(version)) {
return `${getRuntime(version)}tiny-vue.mjs`
}
return `${getRuntime(version)}tiny-vue-pc.mjs`
}
const createImportMap = (version) => {
@ -45,7 +61,7 @@ const createImportMap = (version) => {
'vue': `${cdnHost}/vue${versionDelimiter}3.4.27/${fileDelimiter}dist/vue.runtime.esm-browser.js`,
'echarts': `${cdnHost}/echarts${versionDelimiter}5.4.1/${fileDelimiter}dist/echarts.esm.js`,
'@vue/compiler-sfc': `${cdnHost}/@vue/compiler-sfc${versionDelimiter}3.4.27/${fileDelimiter}dist/compiler-sfc.esm-browser.js`,
'@opentiny/vue': `${getRuntime(version)}tiny-vue-pc.mjs`,
'@opentiny/vue': getPcRuntime(version),
'@opentiny/vue-icon': `${getRuntime(version)}tiny-vue-icon.mjs`,
'@opentiny/vue-locale': `${getRuntime(version)}tiny-vue-locale.mjs`,
'@opentiny/vue-common': `${getRuntime(version)}tiny-vue-common.mjs`,
@ -56,8 +72,9 @@ const createImportMap = (version) => {
'sortablejs': `${cdnHost}/sortablejs${versionDelimiter}1.15.0/${fileDelimiter}modular/sortable.esm.js`
}
if (['aurora', 'smb', 'saas'].includes(tinyTheme)) {
imports[`@opentiny/vue-design-${tinyTheme}`] =
`${cdnHost}/@opentiny/vue-design-${tinyTheme}${versionDelimiter}${version}/${fileDelimiter}index.js`
imports[
`@opentiny/vue-design-${tinyTheme}`
] = `${cdnHost}/@opentiny/vue-design-${tinyTheme}${versionDelimiter}${version}/${fileDelimiter}index.js`
}
if (isSaas) {
imports['@opentiny/vue-icon'] = `${getRuntime(version)}tiny-vue-icon-saas.mjs`