dept.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // import { getCurrentInstance } from 'vue'
  2. let installed = false
  3. // await loadStyle()
  4. await loadUnoCss()
  5. await loadKanKanThemeChalkStyle()
  6. await loadSDKDep()
  7. await loadSDK()
  8. export function setupDept() {
  9. if (installed) return
  10. // const instance = getCurrentInstance()
  11. // const __sdk = (window.__sdk = new window.KanKan({
  12. // num: 'KJ-t-wOXfx2SDFy',
  13. // // server: 'https://test.4dkankan.com',
  14. // server: '/demoServer',
  15. // }))
  16. // instance.appContext.app.provide('__sdk', __sdk)
  17. // instance.appContext.app.use(ElementPlus)
  18. installed = true
  19. }
  20. export function loadStyle() {
  21. return new Promise((resolve, reject) => {
  22. const link = document.createElement('link')
  23. link.rel = 'stylesheet'
  24. link.href = '#STYLE#'
  25. link.addEventListener('load', resolve)
  26. link.addEventListener('error', reject)
  27. document.body.append(link)
  28. })
  29. }
  30. export function loadSDKDep() {
  31. return new Promise((resolve, reject) => {
  32. const script = document.createElement('script')
  33. script.src = '//4dkk.4dage.com/v4-test/www/sdk/kankan-sdk-deps.js?v=4.6.0-alpha.10'
  34. script.addEventListener('load', resolve)
  35. script.addEventListener('error', reject)
  36. document.body.append(script)
  37. })
  38. }
  39. export function loadSDK() {
  40. return new Promise((resolve, reject) => {
  41. const script = document.createElement('script')
  42. script.src = '//4dkk.4dage.com/v4-test/www/sdk/kankan-sdk.js?v=4.6.0-alpha.10'
  43. script.addEventListener('load', resolve)
  44. script.addEventListener('error', reject)
  45. document.body.append(script)
  46. })
  47. }
  48. export function loadKanKanThemeChalkStyle() {
  49. return new Promise((resolve, reject) => {
  50. const link = document.createElement('link')
  51. link.rel = 'stylesheet'
  52. link.href = 'https://4dkk.4dage.com/npm_test/kankan-components/theme-chalk/index.css'
  53. link.addEventListener('load', resolve)
  54. link.addEventListener('error', reject)
  55. document.body.append(link)
  56. })
  57. }
  58. export function loadUnoCss() {
  59. return new Promise((resolve, reject) => {
  60. const link = document.createElement('link')
  61. link.rel = 'stylesheet'
  62. link.href = 'https://cdn.jsdelivr.net/npm/@unocss/reset/tailwind.min.css'
  63. link.addEventListener('load', resolve)
  64. link.addEventListener('error', reject)
  65. document.body.append(link)
  66. const script = document.createElement('script')
  67. script.src = 'https://cdn.jsdelivr.net/npm/@unocss/runtime/mini.global.js'
  68. script.addEventListener('load', resolve)
  69. script.addEventListener('error', reject)
  70. document.body.append(script)
  71. })
  72. }