wenliming 2 gadi atpakaļ
vecāks
revīzija
edb54e4d95
1 mainītis faili ar 12 papildinājumiem un 0 dzēšanām
  1. 12 0
      src/view/iframe/publish/tool-box/child/editor.vue

+ 12 - 0
src/view/iframe/publish/tool-box/child/editor.vue

@@ -79,6 +79,8 @@ const emits = defineEmits(["changeShowCom"]);
 
 const searchHandler = async () => {
   let siteTitle = '', favicon = '';
+  let timer = null;
+
   
   if(!siteUrl.value) {
     return;
@@ -92,6 +94,11 @@ const searchHandler = async () => {
     return;
   } 
   const loadingHide = message.loading('loading...', 0);
+  timer = setTimeout(() => {
+    loadingHide();
+    message.error('Page loading failed');
+  }, 1000 * 15);
+
   let siteRes = await axios.get(siteUrl.value);
 
   if(siteRes) {
@@ -126,6 +133,7 @@ const searchHandler = async () => {
   let params = { convertUrl: siteUrl.value, originUrl: siteUrl.value, appId: '', currentApp };
 
   loadingHide();
+  clearTimeout(timer);
 
   if(convertRes && convertRes.code == 0) {
     let {convertUrl} = convertRes.data || {};
@@ -137,6 +145,10 @@ const searchHandler = async () => {
 const getTitleByHtmlStr = (str) => {
   let index1 = str.indexOf('<title>') + 7;
   let index2 = str.indexOf('</title>');
+  if(index2 < 0) {
+    return '';
+  }
+
   return str.substring(index1, index2) || '';
 };