diff --git a/examples/sites/env/.env.innersaas b/examples/sites/env/.env.innersaas index 909bc999c..22303db3c 100644 --- a/examples/sites/env/.env.innersaas +++ b/examples/sites/env/.env.innersaas @@ -5,4 +5,4 @@ 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-playground \ No newline at end of file +VITE_PLAYGROUND_URL=/vue-saas-playground \ No newline at end of file diff --git a/examples/sites/playground/App.vue b/examples/sites/playground/App.vue index 2a5395941..822df9137 100644 --- a/examples/sites/playground/App.vue +++ b/examples/sites/playground/App.vue @@ -4,16 +4,26 @@ import { Repl, useStore, File } from '@opentiny/vue-repl' import '@opentiny/vue-repl/dist/style.css' import Editor from '@vue/repl/codemirror-editor' -import { ButtonGroup as TinyButtonGroup, Select as TinySelect, Option as TinyOption, Notify } from '@opentiny/vue' +import { + ButtonGroup as TinyButtonGroup, + Select as TinySelect, + Option as TinyOption, + Switch as TinySwitch, + Notify +} from '@opentiny/vue' import { staticDemoPath, getWebdocPath } from '@/views/components/cmpConfig' import { fetchDemosFile } from '@/tools/utils' 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' +const LAYOUT = 'playground-layout' +const LAYOUT_REVERSE = 'playground-layout-reverse' + const versions = ['3.11', '3.10', '3.9', '3.8'] -const latestVersion = versions[0] -const cdnHost = window.localStorage.getItem('setting-cdn') +const latestVersion = localStorage.getItem(VERSION) || versions[0] +const cdnHost = localStorage.getItem('setting-cdn') const getRuntime = (version) => `${cdnHost}/@opentiny/vue@${version}/runtime/` const searchObj = new URLSearchParams(location.search) @@ -74,9 +84,11 @@ const store = new useStore({ } }) +// repl 属性 const state = reactive({ - // repl 属性 - layout: 'horizon', + layout: localStorage.getItem(LAYOUT) || 'horizon', + // 默认为反转,所以需要判断是否为'false'后取反 + layoutReverse: !(localStorage.getItem(LAYOUT_REVERSE) === 'false'), layoutOptions: [ { value: 'horizon', text: '水平' }, { value: 'vertical', text: '垂直' } @@ -120,6 +132,11 @@ function setTinyDesign() { } } +function selectVersion(version) { + versionChange(version) + localStorage.setItem(VERSION, version) +} + function versionChange(version) { const importMap = createImportMap(version) store.state.files['import-map.json'] = new File('', JSON.stringify(importMap)) @@ -138,6 +155,14 @@ function versionChange(version) { }) } +function changeLayout(layout) { + localStorage.setItem(LAYOUT, layout) +} + +function changeReserve(isReserve) { + localStorage.setItem(LAYOUT_REVERSE, isReserve) +} + function getDemoName(name, apiMode) { return name.replace(/\.vue$/, `${apiMode === 'Options' ? '' : '-composition-api'}.vue`) } @@ -215,11 +240,19 @@ function share() {