Skip to content

Commit 1afb7ee

Browse files
gimmyhehezzcr
authored andcommitted
docs(playground): playground only supply latest 3 version
1 parent dce3b6e commit 1afb7ee

File tree

1 file changed

+51
-32
lines changed

1 file changed

+51
-32
lines changed

examples/sites/playground/App.vue

Lines changed: 51 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
1-
<script setup>
1+
<script setup lang="jsx">
22
import { onMounted, reactive, nextTick } from 'vue'
33
import { Repl, useStore, File } from '@opentiny/vue-repl'
44
import '@opentiny/vue-repl/dist/style.css'
55
66
import Editor from '@vue/repl/codemirror-editor'
7-
import {
8-
ButtonGroup as TinyButtonGroup,
9-
Select as TinySelect,
10-
Option as TinyOption,
11-
Switch as TinySwitch,
12-
Notify
13-
} from '@opentiny/vue'
7+
import { TinyButtonGroup, TinyButton, TinySelect, TinyOption, TinySwitch, Notify } from '@opentiny/vue'
148
import { staticDemoPath, getWebdocPath } from '@/views/components/cmp-config'
159
import { fetchDemosFile } from '@/tools/utils'
1610
import logoUrl from './assets/opentiny-logo.svg?url'
1711
import GitHub from './icons/Github.vue'
1812
import Share from './icons/Share.vue'
1913
20-
const VERSION = 'tiny-vue-version-3.16'
14+
const VERSION = 'tiny-vue-version-3.19'
15+
const NOTIFY = 'tiny-vue-playground-notify'
2116
const LAYOUT = 'playground-layout'
2217
const LAYOUT_REVERSE = 'playground-layout-reverse'
2318
@@ -28,40 +23,57 @@ const isMobileFirst = tinyMode === 'mobile-first'
2823
const isSaas = tinyTheme === 'saas'
2924
const isPreview = searchObj.get('openMode') === 'preview' // 是否多端弹窗预览
3025
31-
const versions = ['3.19', '3.18', '3.17', '3.16', '3.15', '3.14', '3.13', '3.12', '3.11', '3.10', '3.9', '3.8']
32-
const latestVersion = isPreview ? versions[0] : localStorage.getItem(VERSION) || versions[0]
26+
const versions = ['3.19', '3.18', '3.17']
27+
const getVersion = () => {
28+
if (isPreview) {
29+
return versions[0]
30+
}
31+
if (versions.includes(localStorage.getItem(VERSION))) {
32+
localStorage.getItem(VERSION)
33+
}
34+
return versions[0]
35+
}
36+
const latestVersion = getVersion()
3337
const cdnHost = localStorage.getItem('setting-cdn')
3438
3539
const versionDelimiter = cdnHost.includes('npmmirror') ? '/' : '@'
3640
const fileDelimiter = cdnHost.includes('npmmirror') ? 'files/' : ''
3741
38-
const isOldVersion = (version) => {
39-
const minorVersion = version?.split('.')?.[1]
40-
return minorVersion && minorVersion < 16
41-
}
42-
43-
// 3.16.0版本之前的runtime还没有抽离单独的包
44-
const getRuntime = (version) => {
45-
if (isOldVersion(version)) {
46-
return `${cdnHost}/@opentiny/vue${versionDelimiter}${version}/${fileDelimiter}runtime/`
42+
let notify
43+
const showNotify = () => {
44+
if (localStorage.getItem(NOTIFY) !== 'true' && !notify) {
45+
const muteNotify = () => {
46+
notify.close()
47+
localStorage.setItem(NOTIFY, true)
48+
}
49+
notify = Notify({
50+
type: 'info',
51+
title: '温馨提示:',
52+
message: () => (
53+
<div>
54+
<div>演练场仅保留最新的三个版本可选。</div>
55+
<div style="text-align: right;margin-top: 12px;">
56+
<TinyButton onClick={muteNotify} type={'primary'}>
57+
不再提示
58+
</TinyButton>
59+
</div>
60+
</div>
61+
),
62+
duration: -1,
63+
position: 'top-right',
64+
verticalOffset: 200
65+
})
4766
}
48-
return `${cdnHost}/@opentiny/vue-runtime${versionDelimiter}${version}/${fileDelimiter}dist3/`
4967
}
5068
51-
// 3.16.0版本之前的runtime没有tiny-vue-pc.mjs文件
52-
const getPcRuntime = (version) => {
53-
if (isOldVersion(version)) {
54-
return `${getRuntime(version)}tiny-vue.mjs`
55-
}
56-
return `${getRuntime(version)}tiny-vue-pc.mjs`
57-
}
69+
const getRuntime = (version) => `${cdnHost}/@opentiny/vue-runtime${versionDelimiter}${version}/${fileDelimiter}dist3/`
5870
5971
const createImportMap = (version) => {
6072
const imports = {
6173
'vue': `${cdnHost}/vue${versionDelimiter}3.4.27/${fileDelimiter}dist/vue.runtime.esm-browser.js`,
6274
'echarts': `${cdnHost}/echarts${versionDelimiter}5.4.1/${fileDelimiter}dist/echarts.esm.js`,
6375
'@vue/compiler-sfc': `${cdnHost}/@vue/compiler-sfc${versionDelimiter}3.4.27/${fileDelimiter}dist/compiler-sfc.esm-browser.js`,
64-
'@opentiny/vue': getPcRuntime(version),
76+
'@opentiny/vue': `${getRuntime(version)}tiny-vue-pc.mjs`,
6577
'@opentiny/vue-icon': `${getRuntime(version)}tiny-vue-icon.mjs`,
6678
'@opentiny/vue-locale': `${getRuntime(version)}tiny-vue-locale.mjs`,
6779
'@opentiny/vue-common': `${getRuntime(version)}tiny-vue-common.mjs`,
@@ -72,8 +84,9 @@ const createImportMap = (version) => {
7284
'sortablejs': `${cdnHost}/sortablejs${versionDelimiter}1.15.0/${fileDelimiter}modular/sortable.esm.js`
7385
}
7486
if (['aurora', 'saas'].includes(tinyTheme)) {
75-
imports[`@opentiny/vue-design-${tinyTheme}`] =
76-
`${cdnHost}/@opentiny/vue-design-${tinyTheme}${versionDelimiter}${version}/${fileDelimiter}index.js`
87+
imports[
88+
`@opentiny/vue-design-${tinyTheme}`
89+
] = `${cdnHost}/@opentiny/vue-design-${tinyTheme}${versionDelimiter}${version}/${fileDelimiter}index.js`
7790
}
7891
if (isSaas) {
7992
imports['@opentiny/vue-icon'] = `${getRuntime(version)}tiny-vue-icon-saas.mjs`
@@ -291,7 +304,13 @@ function share() {
291304
</span>
292305
<span class="ml20">
293306
OpenTiny Vue 版本:
294-
<tiny-select v-model="state.selectVersion" @change="selectVersion" style="width: 150px" :disabled="isPreview">
307+
<tiny-select
308+
v-model="state.selectVersion"
309+
style="width: 150px"
310+
:disabled="isPreview"
311+
@change="selectVersion"
312+
@click="showNotify"
313+
>
295314
<tiny-option v-for="item in state.versions" :key="item.value" :label="item.value" :value="item.value">
296315
</tiny-option>
297316
</tiny-select>

0 commit comments

Comments
 (0)