liyongli 4 tháng trước cách đây
mục cha
commit
11a7527fa6
2 tập tin đã thay đổi với 32 bổ sung1 xóa
  1. 1 0
      auto-imports.d.ts
  2. 31 1
      src/views/SitePage.vue

+ 1 - 0
auto-imports.d.ts

@@ -7,4 +7,5 @@
 export {}
 declare global {
   const ElMessage: typeof import('element-plus/es')['ElMessage']
+  const ElNotification: typeof import('element-plus/es')['ElNotification']
 }

+ 31 - 1
src/views/SitePage.vue

@@ -73,6 +73,15 @@
                 <el-button link type="primary" size="small">删除</el-button>
               </template>
             </el-popconfirm>
+            <el-button
+              v-if="scope.row.status !== 0"
+              @click="() => copyCode(scope.row.catalogId)"
+              link
+              type="primary"
+              size="small"
+            >
+              复制代码
+            </el-button>
           </div>
         </template>
       </el-table-column>
@@ -95,7 +104,7 @@
 import type { SiteList } from '@/types/Site'
 import type { CatalogTreeOri } from '@/types/Catalog'
 import { reactive, ref } from 'vue'
-import { ElMessage } from 'element-plus'
+import { ElMessage, ElNotification } from 'element-plus'
 import {
   getSiteList,
   deleteAsTree,
@@ -205,6 +214,27 @@ const publishAsTreeFunc = (id: number) => {
     })
 }
 
+const copyCode = (id: number) => {
+  try {
+    navigator.clipboard.writeText(`<script src="http://cxzx.smcic.net/ad/catalog/${id}.js" />`)
+    ElMessage({
+      message: '复制成功',
+      type: 'success',
+    })
+    ElNotification({
+      title: '代码(如复制失败可直接复制下文)',
+      message: `<script src="http://cxzx.smcic.net/ad/catalog/${id}.js" />`,
+      duration: 0,
+    })
+  } catch (error) {
+    console.log(error)
+    ElMessage({
+      message: '复制失败',
+      type: 'info',
+    })
+  }
+}
+
 const Add = (row: CatalogTreeOri, list: CatalogTreeOri[]) => {
   const sonItem: CatalogTreeOri = { isEdit: true, parentId: row.catalogId, mediaId: row.mediaId }
   for (let i = 0; i < list.length; i++) {