first commit
This commit is contained in:
12 files changed
+931
No files matched your search
@@ -0,0 +1,22 @@
|
||||
import { operate } from './service.js';
|
||||
import { transact } from './db.js';
|
||||
|
||||
chrome.runtime.onMessage.addListener((message, sender, respond) => {
|
||||
if (message?.app !== 'dww11-v3') return;
|
||||
operate(message.route, message.body, sender).then(data => respond({ ok: true, data }), error => respond({ ok: false, error: error.message || '操作失败' }));
|
||||
return true;
|
||||
});
|
||||
chrome.action.onClicked.addListener(() => chrome.runtime.openOptionsPage());
|
||||
|
||||
function park(reason) {
|
||||
return transact((accounts, state) => {
|
||||
if (state.flow) { state.flow.paused = true; state.flow.tabId = null; state.flow.documentId = null; state.flow.reason = reason; }
|
||||
}).catch(error => console.error('无法保存流程暂停状态', error.name));
|
||||
}
|
||||
chrome.runtime.onStartup.addListener(() => park('浏览器已重启,点击“继续未完成流程”恢复。'));
|
||||
chrome.runtime.onInstalled.addListener(() => park('扩展已启动或更新,刷新网站后点击继续。'));
|
||||
chrome.tabs.onRemoved.addListener(tabId => {
|
||||
transact((accounts, state) => {
|
||||
if (state.flow?.tabId === tabId) { state.flow.paused = true; state.flow.tabId = null; state.flow.documentId = null; state.flow.reason = '原标签页已关闭,点击继续恢复。'; }
|
||||
}).catch(error => console.error('保存标签关闭状态失败', error.name));
|
||||
});
|
||||
Reference in new issue
Block a user