element-plus/docs/.vitepress/vitepress/composables/use-playground.ts
2022-02-11 11:33:43 +08:00

18 lines
361 B
TypeScript

import { utoa } from '../utils'
const MAIN_FILE_NAME = 'App.vue'
export const usePlayGround = (source: string) => {
const code = decodeURIComponent(source)
const originCode = {
[MAIN_FILE_NAME]: code,
}
const encoded = utoa(JSON.stringify(originCode))
const link = `https://element-plus.run/#${encoded}`
return {
encoded,
link,
}
}