mirror of
https://github.com/element-plus/element-plus.git
synced 2024-11-21 01:02:59 +08:00
feat(docs): support playground sync theme (#16735)
* feat(docs): support playground sync theme * fix: dark mode error
This commit is contained in:
parent
7db060b7fb
commit
39763fcfe0
@ -1,4 +1,5 @@
|
||||
import { utoa } from '../utils'
|
||||
import { isDark } from './dark'
|
||||
|
||||
const MAIN_FILE_NAME = 'App.vue'
|
||||
|
||||
@ -10,11 +11,19 @@ export const usePlayground = (source: string) => {
|
||||
|
||||
const encoded = utoa(JSON.stringify(originCode))
|
||||
const isPreview = location.host.startsWith('preview')
|
||||
let link = `https://element-plus.run/#${encoded}`
|
||||
let link = `https://element-plus.run/`
|
||||
if (isPreview) {
|
||||
const pr = location.host.split('-', 2)[1]
|
||||
link = `https://element-plus.run/?pr=${pr}#${encoded}`
|
||||
link = `${link}?pr=${pr}`
|
||||
}
|
||||
if (isDark.value) {
|
||||
if (isPreview) {
|
||||
link += '&theme=dark'
|
||||
} else {
|
||||
link = `${link}?theme=dark`
|
||||
}
|
||||
}
|
||||
link += `#${encoded}`
|
||||
return {
|
||||
encoded,
|
||||
link,
|
||||
|
Loading…
Reference in New Issue
Block a user