use-playground.ts 361 B

1234567891011121314151617
  1. import { utoa } from '../utils'
  2. const MAIN_FILE_NAME = 'App.vue'
  3. export const usePlayground = (source: string) => {
  4. const code = decodeURIComponent(source)
  5. const originCode = {
  6. [MAIN_FILE_NAME]: code,
  7. }
  8. const encoded = utoa(JSON.stringify(originCode))
  9. const link = `https://element-plus.run/#${encoded}`
  10. return {
  11. encoded,
  12. link,
  13. }
  14. }