App.vue 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <template>
  2. <magic-editor :config="defaultConfig"/>
  3. </template>
  4. <script setup>
  5. let defaultConfig = {};
  6. try {
  7. if (parent && parent.MAGIC_EDITOR_CONFIG) {
  8. defaultConfig = {...parent.MAGIC_EDITOR_CONFIG};
  9. }
  10. } catch (ignored) { }
  11. if (window.MAGIC_EDITOR_CONFIG) {
  12. defaultConfig = {...defaultConfig, ...window.MAGIC_EDITOR_CONFIG}
  13. }
  14. defaultConfig.baseURL = import.meta.env.MODE === 'development' ? 'http://127.0.0.1:9999/magic/web' : './';
  15. defaultConfig.serverURL = import.meta.env.MODE === 'development' ? 'http://127.0.0.1:9999/' : './';
  16. defaultConfig.inJar = true;
  17. const getQueryString = name => {
  18. var r = window.location.search.substr(1).match(new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i'));
  19. return r && unescape(r[2])
  20. }
  21. const headerName = getQueryString('headerName')
  22. const headerValue = getQueryString('headerValue')
  23. if(headerName && headerValue){
  24. defaultConfig.request = defaultConfig.request || {}
  25. defaultConfig.request.beforeSend = cfg => {
  26. cfg.headers[headerName] = headerValue
  27. return cfg
  28. }
  29. }
  30. </script>
  31. <style>
  32. html,body,#app{
  33. width: 100%;
  34. height: 100%;
  35. margin:0 !important;
  36. }
  37. </style>