|
@@ -60,6 +60,9 @@ const props = defineProps({
|
|
|
|
|
|
let siteUrl = ref('');
|
|
|
|
|
|
+let selectAppGuideData = {};
|
|
|
+let openWindowList = [];
|
|
|
+
|
|
|
let historyList = reactive([
|
|
|
// {
|
|
|
// "apps": [
|
|
@@ -87,6 +90,9 @@ const emits = defineEmits(["changeShowCom"]);
|
|
|
|
|
|
const searchHandler = async () => {
|
|
|
siteUrl.value = siteUrl.value.trim();
|
|
|
+ let siteTitle = '';
|
|
|
+ let favicon = '';
|
|
|
+
|
|
|
if(!checkURL(siteUrl.value)) {
|
|
|
//提示
|
|
|
return;
|
|
@@ -99,7 +105,16 @@ const searchHandler = async () => {
|
|
|
// 提示
|
|
|
return;
|
|
|
}
|
|
|
- }
|
|
|
+ if(siteRes.data) {
|
|
|
+ let arr = siteRes.data.match(/<title>(\S*)<\/title>/);
|
|
|
+ if(arr && arr.length > 1) {
|
|
|
+ siteTitle = arr[1];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ favicon = new URL(siteUrl.value).origin + '/favicon.ico';
|
|
|
+ }
|
|
|
+
|
|
|
+ console.log(siteTitle, favicon, 'site')
|
|
|
|
|
|
let convertRes = await convertUrl({params: {originUrl: siteUrl.value}});
|
|
|
let params = { convertUrl: siteUrl.value, originUrl: siteUrl.value, appId: '' };
|
|
@@ -120,11 +135,38 @@ const clickAppHandler = (params) => {
|
|
|
emits('changeShowCom', { convertUrl: defaultUrl, originUrl: defaultUrl, appId, linkImagePath })
|
|
|
break;
|
|
|
case 2:
|
|
|
-
|
|
|
+ openWindow(params);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+const openWindow = (params) => {
|
|
|
+ openWindowList = [];
|
|
|
+ selectAppGuideData = {};
|
|
|
+
|
|
|
+ let windowWith = window.innerWidth - 500;
|
|
|
+ let guideUrl = chrome.runtime.getURL('/iframe/tool-box-guide.html');
|
|
|
+ chrome.windows.create({
|
|
|
+ width: windowWith,
|
|
|
+ type: 'popup',
|
|
|
+ url: params.defaultUrl
|
|
|
+ }, function (window) {
|
|
|
+ openWindowList.push(window);
|
|
|
+ })
|
|
|
+ chrome.windows.create({
|
|
|
+ width: 500,
|
|
|
+ type: 'popup',
|
|
|
+ url: guideUrl,
|
|
|
+ left: windowWith
|
|
|
+ }, function (window) {
|
|
|
+ openWindowList.push(window);
|
|
|
+ })
|
|
|
+
|
|
|
+ if(params.guideData) {
|
|
|
+ selectAppGuideData = JSON.parse(params.guideData);
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
const getAppList = () => {
|
|
|
getAllPostEditorAppData({params: {}}).then(res => {
|
|
|
if(res.code == 0) {
|
|
@@ -133,8 +175,31 @@ const getAppList = () => {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+const onRuntimeMsg = () => {
|
|
|
+ chrome.runtime.onMessage.addListener((req, sender, sendResponse) => {
|
|
|
+ sendResponse('ok')
|
|
|
+ switch (req.actionType) {
|
|
|
+ case 'CONTENT_GET_GUIDE_DATA':
|
|
|
+ chrome.runtime.sendMessage({
|
|
|
+ actionType: "CONTENT_EDIT_SEND_GUIDE_DATA",
|
|
|
+ data: {
|
|
|
+ guideData: selectAppGuideData,
|
|
|
+ windowData: openWindowList
|
|
|
+ }
|
|
|
+ },(response) => {});
|
|
|
+ break;
|
|
|
+ case 'CONTENT_GUIDE_APPLY_APP':
|
|
|
+ siteUrl.value = req.data.siteUrl;
|
|
|
+ searchHandler();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
onMounted(() => {
|
|
|
getAppList();
|
|
|
+ onRuntimeMsg();
|
|
|
})
|
|
|
</script>
|
|
|
|