瀏覽代碼

Merge branch 'dev_v1.1.4' of https://git.yishihui.com/DeNet/de-net into dev_v1.1.4

zhangwei 2 年之前
父節點
當前提交
e353564bfa

+ 3 - 0
src/assets/svg/icon-tool-app-history.svg

@@ -0,0 +1,3 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M11.9996 20.6663C16.7862 20.6663 20.6663 16.7862 20.6663 11.9996C20.6663 7.21301 16.7862 3.33294 11.9996 3.33294C7.21301 3.33294 3.33294 7.21301 3.33294 11.9996C3.33294 16.7862 7.21301 20.6663 11.9996 20.6663ZM11.9996 22.3996C6.25621 22.3996 1.59961 17.743 1.59961 11.9996C1.59961 6.25621 6.25621 1.59961 11.9996 1.59961C17.743 1.59961 22.3996 6.25621 22.3996 11.9996C22.3996 17.743 17.743 22.3996 11.9996 22.3996ZM12.8663 12.5101V7.66368C12.8663 7.19221 12.478 6.79961 11.9996 6.79961C11.5177 6.79961 11.1329 7.18614 11.1329 7.66368V12.8689C11.1322 12.9813 11.1537 13.0929 11.1963 13.197C11.2388 13.3011 11.3015 13.3958 11.3808 13.4755L13.8439 15.9386C13.9242 16.0185 14.0196 16.0817 14.1244 16.1246C14.2293 16.1676 14.3415 16.1894 14.4548 16.1888C14.5681 16.1882 14.6802 16.1653 14.7846 16.1213C14.889 16.0774 14.9837 16.0132 15.0633 15.9325C15.2247 15.7711 15.3159 15.5524 15.317 15.3241C15.3182 15.0958 15.2292 14.8762 15.0693 14.7131L12.8663 12.5101Z" fill="#AFB3B6"/>
+</svg>

+ 4 - 0
src/logic/content/twitter.js

@@ -233,6 +233,10 @@ function _publishTweetEvent(params, cb) {
 }
 
 function onClosePublishDialogHandle(dom, params) {
+    // 如果是 Tool box
+    if(params.postType == 3) {
+        return;
+    }
     dom.querySelector('div[role="group"]').addEventListener('click', function () {
         setTimeout(() => {
             let parent = document.querySelector('div[data-testid="confirmationSheetDialog"]');

+ 69 - 42
src/view/iframe/publish/tool-box/child/editor.vue

@@ -16,14 +16,17 @@
     </div>
     <div class="bottom">
       <div class="content">
-        <div class="cate-item history-wrapper" v-for="(item) in historyList" :key="item.cateId">
+        <div class="cate-item history-wrapper" v-if="historyList.length">
           <div class="cate">
-            <img :src="item.iconPath">
+            <img :src="require('@/assets/svg/icon-tool-app-history.svg')" />
           </div>
           <div class="app-list">
-            <div class="app" v-for="(app, idx) in item.apps" :key="idx">
+            <div class="app" v-for="(app, idx) in historyList" :key="idx"
+              @click="clickHistoryAppHandler(app)">
               <img :src="app.iconPath" alt="">
-              {{ app.name }}
+              <div class="name">
+                {{ app.name }}
+              </div>
             </div>
           </div>
         </div>
@@ -34,7 +37,9 @@
           <div class="app-list">
             <div class="app" v-for="(app, idx) in item.apps" :key="idx" @click="clickAppHandler(app)">
               <img :src="app.iconPath" alt="">
-              {{ app.name }}
+              <div class="name">
+                {{ app.name }}
+              </div>
             </div>
           </div>
         </div>
@@ -44,10 +49,11 @@
 </template>
 
 <script setup>
-import { ref, reactive, defineProps, defineEmits, onMounted } from "vue";
+import { ref, defineProps, defineEmits, onMounted } from "vue";
 import axios from 'axios';
 import { message } from "ant-design-vue";
 import { convertUrl, getAllPostEditorAppData } from "@/http/toolBoxApi";
+import { getChromeStorage } from "@/uilts/chromeExtension"
 import { checkURL } from "@/uilts/help"
 
 const props = defineProps({
@@ -63,35 +69,20 @@ let siteUrl = ref('');
 let selectAppGuideData = {};
 let openWindowList = [];
 
-let historyList = reactive([
-  // {
-  //   "apps": [
-  //     {
-  //       "appId": '',
-  //       "cateId": 0,
-  //       "createType": 0,
-  //       "defaultUrl": "string",
-  //       "guideData": "string",
-  //       "iconPath": "https://www.baidu.com/favicon.ico",
-  //       "interactType": 0,
-  //       "linkImagePath": "string",
-  //       "name": "history 1"
-  //     }
-  //   ],
-  //   "cateId": 0,
-  //   "iconPath": "https://www.baidu.com/favicon.ico",
-  //   "name": "history"
-  // },
-])
+let historyList = ref([])
 
 let appList = ref();
 
 const emits = defineEmits(["changeShowCom"]);
 
 const searchHandler = async () => {
+  let siteTitle = '', favicon = '';
+  
+  if(!siteUrl.value) {
+    return;
+  }
+
   siteUrl.value = siteUrl.value.trim();
-  let siteTitle = '';
-  let favicon = '';
 
   if(!checkURL(siteUrl.value)) {
     //提示
@@ -114,10 +105,20 @@ const searchHandler = async () => {
     favicon = new URL(siteUrl.value).origin + '/favicon.ico';
   } 
 
-  console.log(siteTitle, favicon, 'site')
+  let currentApp = {
+    appId: '',
+    cateId: '',
+    createType: '',
+    defaultUrl: siteUrl.value,
+    guideData: '',
+    iconPath: favicon,
+    interactType: '',
+    linkImagePath: "",
+    name: siteTitle,
+  }
 
   let convertRes = await convertUrl({params: {originUrl: siteUrl.value}});
-  let params = { convertUrl: siteUrl.value, originUrl: siteUrl.value, appId: '' };
+  let params = { convertUrl: siteUrl.value, originUrl: siteUrl.value, appId: '', currentApp };
 
   loadingHide();
 
@@ -128,11 +129,20 @@ const searchHandler = async () => {
   emits('changeShowCom', params)
 }
 
+const clickHistoryAppHandler = (params) => {
+  if(params.appId) {
+    clickAppHandler(params);
+  } else {
+    siteUrl.value = params.defaultUrl;
+    searchHandler();
+  }
+};
+
 const clickAppHandler = (params) => {
   let { createType, defaultUrl, appId, linkImagePath } = params;
   switch (createType) {
     case 1:
-      emits('changeShowCom', { convertUrl: defaultUrl, originUrl: defaultUrl, appId, linkImagePath })
+      emits('changeShowCom', { convertUrl: defaultUrl, originUrl: defaultUrl, appId, linkImagePath, currentApp: params })
       break;
     case 2:
       openWindow(params);
@@ -197,7 +207,13 @@ const onRuntimeMsg = () => {
   })
 }
 
+const getHistoryList = async () => {
+  let {list = []} = await getChromeStorage('toolBoxAppHistoryData') || {};
+  historyList.value = list;
+};
+
 onMounted(() => {
+  getHistoryList();
   getAppList();
   onRuntimeMsg();
 })
@@ -272,14 +288,14 @@ onMounted(() => {
       padding: 36px 30px 20px 50px;
       box-sizing: border-box;
 
-      .history-wrapper {
-        height: 110px !important;
-        overflow: hidden;
+      // .history-wrapper {
+      //   height: 110px !important;
+      //   overflow: hidden;
 
-        .app-list {
-          flex-wrap: nowrap !important;
-        }
-      }
+      //   .app-list {
+      //     flex-wrap: nowrap !important;
+      //   }
+      // }
 
       .cate-item {
         min-height: 110px;
@@ -310,11 +326,8 @@ onMounted(() => {
             flex-direction: column;
             justify-content: center;
             align-items: center;
-            width: 100px;
+            width: 110px;
             height: 110px;
-            font-weight: 500;
-            font-size: 12px;
-            color: #636363;
             cursor: pointer;
 
             img {
@@ -323,6 +336,20 @@ onMounted(() => {
               border-radius: 10px;
               margin-bottom: 10px;
             }
+
+            .name {
+              font-weight: 500;
+              font-size: 12px;
+              color: #636363;
+              width: 100%;
+              height: 15px;
+              text-overflow: ellipsis;
+              white-space: nowrap;
+              overflow: hidden;
+              text-align: center;
+              box-sizing: border-box;
+              padding: 0 5px;
+            }
           }
         }
       }

+ 24 - 2
src/view/iframe/publish/tool-box/child/preview.vue

@@ -62,7 +62,7 @@ import { ref, defineEmits, reactive, defineProps, onMounted, nextTick, onUnmount
 import { postPublish } from "@/http/publishApi";
 import installCard from '@/view/content/tool_box/index.vue'
 
-import { getChromeStorage } from "@/uilts/chromeExtension"
+import { getChromeStorage, setChromeStorage } from "@/uilts/chromeExtension"
 import { getUser } from "@/http/publishApi"
 
 let installStatus = ref(false);
@@ -142,7 +142,10 @@ const publishHandler = () => {
     if(submitIng.value) {
         return;
     }
-    let {convertUrl, originUrl, appId} = props.previewData;
+    let {convertUrl, originUrl, appId, currentApp} = props.previewData;
+
+    setHistoryData(currentApp);
+
     let postBizData = {
         convertUrl,
         originUrl,
@@ -157,6 +160,7 @@ const publishHandler = () => {
     };
 
     submitIng.value = true;
+    
     postPublish(data).then((res) => {
         submitIng.value = false;
         if (res.code == 0) {
@@ -170,6 +174,24 @@ const publishHandler = () => {
     });
 }
 
+const setHistoryData = async (params) => {
+    const maxLength = 9;
+    let {list = []} = await getChromeStorage('toolBoxAppHistoryData') || {};
+    if(list.length) {
+        list.unshift(params);
+        if(list.length > maxLength) {
+            list.length = maxLength;
+        }
+        setChromeStorage({ toolBoxAppHistoryData : JSON.stringify({
+            list: list
+        })}) 
+    } else {
+        setChromeStorage({ toolBoxAppHistoryData : JSON.stringify({
+            list: [params]
+        })})    
+    }
+};
+
 onMounted(() => {
     calcPreviewCanvasParams();
     getUserInfo((res) => {

+ 2 - 0
src/view/iframe/publish/tool-box/index.vue

@@ -42,6 +42,7 @@ let previewData = reactive({
     convertUrl: '',
     originUrl: '',
     appId: '',
+    currentApp: {}
 })
 
 const changeShowCom = (params) => {
@@ -50,6 +51,7 @@ const changeShowCom = (params) => {
     previewData.originUrl = params.originUrl;
     previewData.appId = params.appId
     previewData.linkImagePath = params.linkImagePath || '';
+    previewData.currentApp = params.currentApp || {};
 
     emits("onPageChange", {page: showCom.value});
 }