Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(sites): add 3.14 version playground #1470

Merged
merged 1 commit into from
Mar 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 3 additions & 19 deletions examples/sites/playground/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import logoUrl from './assets/opentiny-logo.svg?url'
import GitHub from './icons/Github.vue'
import Share from './icons/Share.vue'

const VERSION = 'tiny-vue-version-3.13'
const VERSION = 'tiny-vue-version-3.14'
const LAYOUT = 'playground-layout'
const LAYOUT_REVERSE = 'playground-layout-reverse'

Expand All @@ -28,27 +28,14 @@ const isMobileFirst = tinyMode === 'mobile-first'
const isSaas = tinyTheme === 'saas'
const isPreview = searchObj.get('openMode') === 'preview' // 是否多端弹窗预览

const versions = ['3.13', '3.12', '3.11', '3.10', '3.9', '3.8']
const versions = ['3.14', '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) => {
const useVersion = import.meta.env.VITE_PLAYGROUND_VERIOSN || version
return `${cdnHost}/@opentiny/vue@${useVersion}/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 imports = {
'@opentiny/vue': `${getRuntime(version)}tiny-vue.mjs`,
Expand All @@ -67,17 +54,14 @@ const createImportMap = (version) => {
imports['@opentiny/vue-icon'] = `${getRuntime(version)}tiny-vue-icon-saas.mjs`
}
return {
imports: changeImportSuffix(imports, version)
imports
}
}

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'
Expand Down
Loading