|
@@ -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);
|