aiWeb.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template>
  2. <div v-if="visible" class="aiweb-modal-overlay" @click.self="closeModal">
  3. <div class="aiweb-modal">
  4. <div class="aiweb-modal-header">
  5. <span class="aiweb-modal-title">{{ lang.ssWebEditor }}</span>
  6. <button class="aiweb-modal-close" @click="closeModal">
  7. <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
  8. <path d="M18 6L6 18"></path>
  9. <path d="M6 6l12 12"></path>
  10. </svg>
  11. </button>
  12. </div>
  13. <div class="aiweb-modal-body">
  14. <iframe :src="iframeUrl" frameborder="0" class="aiweb-iframe" ref="iframeRef"></iframe>
  15. </div>
  16. <div class="aiweb-modal-footer">
  17. <button class="aiweb-btn aiweb-btn-close" @click="closeModal">{{ lang.ssClose }}</button>
  18. <button class="aiweb-btn aiweb-btn-confirm" @click="handleConfirm" :disabled="isLoading">
  19. {{ isLoading ? lang.ssCreating : lang.ssConfirmAdd }}
  20. </button>
  21. </div>
  22. </div>
  23. </div>
  24. </template>
  25. <script lang="ts" setup>
  26. import { computed, ref } from 'vue'
  27. import { lang } from '@/main'
  28. const props = defineProps<{
  29. visible: boolean
  30. webId: string
  31. isLoading: boolean
  32. }>()
  33. const emit = defineEmits<{
  34. (e: 'close'): void
  35. (e: 'add', webCode: string): void
  36. }>()
  37. const iframeUrl = computed(() => {
  38. let url = 'https://beta.app.cocorobo.cn'
  39. if (window.location.href.includes('beta')) {
  40. url = 'https://beta.app.cocorobo.cn'
  41. }
  42. else if (lang.lang === 'cn') {
  43. url = 'https://app.cocorobo.cn'
  44. }
  45. else if (lang.lang === 'hk') {
  46. url = 'https://app.cocorobo.hk'
  47. }
  48. else if (lang.lang === 'en') {
  49. url = 'https://app.cocorobo.com'
  50. }
  51. if (!props.webId) return ''
  52. return `${url}/#/web?id=${props.webId}&create=false&isPPT=true`
  53. })
  54. const closeModal = () => {
  55. emit('close')
  56. }
  57. const iframeRef = ref<HTMLIFrameElement>()
  58. const handleConfirm = () => {
  59. const webCode = iframeRef.value?.contentWindow?.ReturnWebCode() as string || ''
  60. console.log(webCode)
  61. if (!webCode) return
  62. console.log('确定按钮被点击')
  63. emit('add', webCode)
  64. }
  65. </script>
  66. <style lang="scss" scoped>
  67. .aiweb-modal-overlay {
  68. position: fixed;
  69. top: 0;
  70. left: 0;
  71. right: 0;
  72. bottom: 0;
  73. background-color: rgba(0, 0, 0, 0.5);
  74. display: flex;
  75. align-items: center;
  76. justify-content: center;
  77. z-index: 1000;
  78. }
  79. .aiweb-modal {
  80. width: 90%;
  81. max-width: 1200px;
  82. height: 90vh;
  83. background-color: #fff;
  84. border-radius: 8px;
  85. overflow: hidden;
  86. box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  87. }
  88. .aiweb-modal-header {
  89. display: flex;
  90. justify-content: space-between;
  91. align-items: center;
  92. padding: 16px 20px;
  93. border-bottom: 1px solid #eee;
  94. background-color: #f8f9fa;
  95. }
  96. .aiweb-modal-title {
  97. font-size: 16px;
  98. font-weight: 600;
  99. color: #333;
  100. }
  101. .aiweb-modal-close {
  102. background: none;
  103. border: none;
  104. cursor: pointer;
  105. padding: 8px;
  106. color: #666;
  107. transition: color 0.2s;
  108. &:hover {
  109. color: #333;
  110. }
  111. svg {
  112. width: 20px;
  113. height: 20px;
  114. }
  115. }
  116. .aiweb-modal-body {
  117. height: calc(100% - 140px);
  118. }
  119. .aiweb-modal-footer {
  120. display: flex;
  121. justify-content: flex-end;
  122. gap: 12px;
  123. padding: 16px 20px;
  124. border-top: 1px solid #eee;
  125. background-color: #f8f9fa;
  126. }
  127. .aiweb-btn {
  128. padding: 8px 20px;
  129. border-radius: 4px;
  130. font-size: 14px;
  131. font-weight: 500;
  132. cursor: pointer;
  133. transition: all 0.2s;
  134. border: 1px solid transparent;
  135. }
  136. .aiweb-btn-close {
  137. background-color: #fff;
  138. border-color: #d9d9d9;
  139. color: #666;
  140. &:hover {
  141. background-color: #f5f5f5;
  142. border-color: #bfbfbf;
  143. }
  144. }
  145. .aiweb-btn-confirm {
  146. background-color: #1890ff;
  147. border-color: #1890ff;
  148. color: #fff;
  149. &:hover {
  150. background-color: #40a9ff;
  151. border-color: #40a9ff;
  152. }
  153. }
  154. .aiweb-iframe {
  155. width: 100%;
  156. height: 100%;
  157. }
  158. </style>