Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
oeyoews committed Mar 22, 2024
1 parent 72d982e commit 7b757f5
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 68 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ This template should help get you started developing with Vue 3 in WXT.

## TODO

* 统计大小
* darkmode
* 支持保存到 tiddlywiki
* 支持保存到 github
Expand Down
1 change: 1 addition & 0 deletions components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down
35 changes: 0 additions & 35 deletions entrypoints/background.ts
Original file line number Diff line number Diff line change
@@ -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,
});
Expand Down
57 changes: 24 additions & 33 deletions entrypoints/popup/Popup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,55 +18,46 @@ 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))
})
</script>

<template>
<div class="app">
<!-- version -->
<div class="sticky top-0 backdrop-blur-sm mb-2">
<div class="flex justify-end">
<ElButton>
Home
</ElButton>
<el-button @click="saveMarkdown(md, title!)">
<el-icon>

<ElBacktop :right="100" :bottom="100" />
<ElButton @click="saveMarkdown(md, title!)">
<ElIcon>
<FaRegularSave />
</el-icon>
</el-button>
</ElIcon>
</ElButton>
</div>
</div>
<el-tabs type="border-card">
<ElTabs type="border-card">

<el-tab-pane>
<ElTabPane>
<template #label>
<el-icon>
<ElIcon>
<FaFileTextO />
</el-icon>
</ElIcon>
</template>
<div v-if="title">
<div class="flex items-center justify-center gap-2">
Expand All @@ -82,10 +73,10 @@ watch(md, async () => {
<div v-html="html"></div>
</article>
</div>
<div v-else>
<!-- <div v-else>
<h2>暂无内容</h2>
</div>
</el-tab-pane>
</div> -->
</ElTabPane>

<ElTabPane>
<template #label>
Expand All @@ -98,7 +89,7 @@ watch(md, async () => {
</ElTabPane>


</el-tabs>
</ElTabs>

</div>
</template>
Expand Down

0 comments on commit 7b757f5

Please sign in to comment.