wenliming 2 лет назад
Родитель
Сommit
597132457f

+ 7 - 37
src/view/iframe/publish/tool-box/child/editor.vue

@@ -124,7 +124,6 @@ const searchHandler = async (_params) => {
     }
   }
 
-  let siteRes = await axios.get(siteUrl.value);
 
   let currentApp = {
     appId: '',
@@ -137,35 +136,19 @@ const searchHandler = async (_params) => {
     linkImagePath: '',
     name: '',
   }
+  let urlObj = new URL(siteUrl.value);
 
-  if (siteRes) {
-    if (siteRes.headers['content-type'].indexOf('text/html') < 0 || siteRes.request.status > 403) {
-      loadingHide();
-      message.error('Page loading failed');
-      return;
-    }
-    let urlObj = new URL(siteUrl.value);
-    if (siteRes.data) {
-      siteTitle = getTitleByHtmlStr(siteRes.data);
-      if (!siteTitle) {
-        siteTitle = urlObj.hostname;
-        currentApp.defaultTit = siteTitle;
-      }
-      currentApp.name = siteTitle;
-    }
-    favicon = urlObj.origin + '/favicon.ico';
-  }
-  currentApp.iconPath = favicon;
+  currentApp.iconPath = urlObj.origin + '/favicon.ico';
 
   if(_params) {
     currentApp = _params;
   }
-  
+
   let convertRes = await convertUrl({ params: { originUrl: siteUrl.value } });
-  let params = { convertUrl: siteUrl.value, 
-                  originUrl: siteUrl.value, 
-                  appId: currentApp.appId, 
-                  linkImagePath: currentApp.linkImagePath, 
+  let params = { convertUrl: siteUrl.value,
+                  originUrl: siteUrl.value,
+                  appId: currentApp.appId,
+                  linkImagePath: currentApp.linkImagePath,
                   currentApp };
 
   loadingHide();
@@ -178,19 +161,6 @@ const searchHandler = async (_params) => {
   emits('changeShowCom', params)
 }
 
-const getTitleByHtmlStr = (str = '') => {
-  let tag_start = '<title>'
-  let tag_end = '</title>'
-  let index1 = str.indexOf(tag_start) + tag_start.length;
-  let index2 = str.indexOf(tag_end);
-
-  if (index1 < tag_start.length || index2 < 0 || index2 < index1) {
-    return '';
-  }
-
-  return str.substring(index1, index2) || '';
-};
-
 const clickHistoryAppHandler =  debounce(function(params) {
   if (params.appId) {
     clickAppHandler(params, false);

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

@@ -77,6 +77,16 @@ let screenshotWebsiteData = reactive({
 let nftSettingDom = ref(null);
 let hasNft = ref(false);
 
+const defaultResourceInfo = {
+  isSet: false,
+  contentType: '',
+  statusCode: '',
+  title: '',
+  hasTitle: false,
+};
+
+let resourceInfo = reactive(defaultResourceInfo);
+
 const changeShowCom = (params) => {
     showCom.value = 'PREVIEW';
     previewData.convertUrl = params.convertUrl;
@@ -113,6 +123,44 @@ const changeShowCom = (params) => {
     emits("onPageChange", {page: showCom.value});
 }
 
+const getResourceInfo = ({url}) => {
+  axios.get(url).then(res => {
+
+  }).catch(err => {
+
+  })
+
+  // if (siteRes) {
+  //   if (siteRes.headers['content-type'].indexOf('text/html') < 0 || siteRes.request.status > 403) {
+  //     loadingHide();
+  //     message.error('Page loading failed');
+  //     return;
+  //   }
+  //   if (siteRes.data) {
+  //     siteTitle = getTitleByHtmlStr(siteRes.data);
+  //     currentApp.name = siteTitle;
+  //     if (!siteTitle) {
+  //       siteTitle = urlObj.hostname;
+  //       currentApp.defaultTit = siteTitle;
+  //     }
+  //   }
+  // }
+}
+
+const getTitleByHtmlStr = (str = '') => {
+  let tag_start = '<title>'
+  let tag_end = '</title>'
+  let index1 = str.indexOf(tag_start) + tag_start.length;
+  let index2 = str.indexOf(tag_end);
+
+  if (index1 < tag_start.length || index2 < 0 || index2 < index1) {
+    return '';
+  }
+
+  return str.substring(index1, index2) || '';
+};
+
+
 const publishFinish = (params) => {
     emits("toolBoxPublishFinish", params);
 }