diff --git a/README.md b/README.md index 8032139..5695d3c 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ This template should help get you started developing with Vue 3 in WXT. ## TODO +* 统计大小 * darkmode * 支持保存到 tiddlywiki * 支持保存到 github diff --git a/components.d.ts b/components.d.ts index be79465..eacf1b8 100644 --- a/components.d.ts +++ b/components.d.ts @@ -7,6 +7,7 @@ export {} declare module 'vue' { export interface GlobalComponents { + ElBacktop: typeof import('element-plus/es')['ElBacktop'] ElButton: typeof import('element-plus/es')['ElButton'] ElIcon: typeof import('element-plus/es')['ElIcon'] ElInput: typeof import('element-plus/es')['ElInput'] diff --git a/entrypoints/background.ts b/entrypoints/background.ts index d08761f..a5a23e2 100644 --- a/entrypoints/background.ts +++ b/entrypoints/background.ts @@ -1,45 +1,10 @@ -import { isProbablyReaderable, Readability } from '@mozilla/readability'; - -/* export default defineBackground(() => { - function sendArticle() { - const documentClone = document.cloneNode(true) as Document; - const reader = new Readability(documentClone); - const article = reader.parse(); - - // TODO: 路由变化似乎不会更新 - chrome.runtime.sendMessage(article); - // console.log(new Date(), article); - // browser.storage.local.set({ - // article, - // }); - } - - setInterval(() => { - const documentClone = document.cloneNode(true) as Document; - const reader = new Readability(documentClone); - const article = reader.parse(); - - chrome.runtime.sendMessage({ - message: article, - }); - console.log('background'); - }, 1000); - - browser.runtime.onInstalled.addListener(async (reason) => { - // const url = browser.runtime.getURL('welcome/welcome.html'); - // await browser.tabs.create({ url }); - }); -}); */ - export default defineBackground(() => { console.log('Hello background!', { id: browser.runtime.id }); browser.runtime.onInstalled.addListener(async ({ reason }) => { - // Also fired on update and browser_update if (reason !== 'install') return; await browser.tabs.create({ - // @ts-expect-error url: browser.runtime.getURL('/welcome.html'), active: true, }); diff --git a/entrypoints/popup/Popup.vue b/entrypoints/popup/Popup.vue index d592964..b2611f4 100644 --- a/entrypoints/popup/Popup.vue +++ b/entrypoints/popup/Popup.vue @@ -18,31 +18,23 @@ const link = ref('') const faviconUrl = ref('') const title = ref('') -function getArticle() { - chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) { - const tab = tabs[0] - link.value = tab.url!; - faviconUrl.value = tab.favIconUrl! - // @ts-ignore - chrome.tabs.sendMessage(tab.id, '', async function (response: IArticle) { - html.value = response.content - title.value = response.title - md.value = await html2md(response.content); - }) - +chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) { + const tab = tabs[0] + link.value = tab.url!; + faviconUrl.value = tab.favIconUrl! + // @ts-ignore + chrome.tabs.sendMessage(tab.id, '', async function (response: IArticle) { + html.value = response.content + md.value = await html2md(html.value); + title.value = response.title }) -} -getArticle() +}) watch(md, async () => { - // ElMessage({ - // message: '修改成功' - // }) html.value = (await md2html(md.value)) }) -