修复配置也会错乱的bug

This commit is contained in:
xu_yanfeng 2025-01-27 21:00:51 +08:00
parent 36680bbf3d
commit eff88ea20c
4 changed files with 17 additions and 24 deletions

View File

@ -39,6 +39,9 @@ chrome.runtime.onMessage.addListener((request: PluginEvent, sender: any, sendRes
} }
}); });
chrome.tabs.onActivated.addListener(({ tabId, windowId }) => {}); chrome.tabs.onActivated.addListener(({ tabId, windowId }) => {});
chrome.tabs.onRemoved.addListener((tabId, removeInfo) => {
//
});
chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => { chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
// 页面发生刷新,通知重新生成数据 // 页面发生刷新,通知重新生成数据
if (changeInfo.status === "complete") { if (changeInfo.status === "complete") {

View File

@ -101,16 +101,6 @@ export default defineComponent({
chrome.scripting.executeScript({ files: ["js/execute.js"], target: { tabId: tabID } }, (results: chrome.scripting.InjectionResult[]) => {}); chrome.scripting.executeScript({ files: ["js/execute.js"], target: { tabId: tabID } }, (results: chrome.scripting.InjectionResult[]) => {});
} }
function _inspectedCode() {
let injectCode = "";
chrome.devtools.inspectedWindow.eval(injectCode, (result, isException) => {
if (isException) {
console.error(isException);
} else {
console.log(`执行结果:${result}`);
}
});
}
const funcEnableSchedule = (b: boolean) => { const funcEnableSchedule = (b: boolean) => {
if (b) { if (b) {
timer.create(); timer.create();

View File

@ -34,25 +34,32 @@ export const appStore = defineStore("app", () => {
const config = ref<ConfigData>(new ConfigData()); const config = ref<ConfigData>(new ConfigData());
const frameID = ref<number>(0); const frameID = ref<number>(0);
const pageShow = ref<boolean>(false); const pageShow = ref<boolean>(false);
function readConfigFile(file: string) {
const data = profile.load(file) as ConfigData;
config.value.refreshType = data.refreshType || RefreshType.Manual;
config.value.refreshTime = data.refreshTime || 500;
config.value.expandTest = !!data.expandTest;
config.value.refreshHirarchy = !!data.refreshHirarchy;
config.value.refreshInspector = !!data.refreshInspector;
}
return { return {
frameID, frameID,
pageShow, pageShow,
config, config,
init() { init() {
profile.init(new ConfigData(), pluginConfig);
if (chrome.devtools) { if (chrome.devtools) {
window.addEventListener(PanelMsg.Show, () => { window.addEventListener(PanelMsg.Show, () => {
pageShow.value = true; pageShow.value = true;
}); });
chrome.devtools.inspectedWindow.eval("window.location.href", (url: string, ex: chrome.devtools.inspectedWindow.EvaluationExceptionInfo) => {
readConfigFile(url);
});
} else { } else {
pageShow.value = true; pageShow.value = true;
readConfigFile(`${pluginConfig.manifest.name}.json`);
} }
profile.init(new ConfigData(), pluginConfig);
const data = profile.load(`${pluginConfig.manifest.name}.json`) as ConfigData;
config.value.refreshType = data.refreshType || RefreshType.Manual;
config.value.refreshTime = data.refreshTime || 500;
config.value.expandTest = !!data.expandTest;
config.value.refreshHirarchy = !!data.refreshHirarchy;
config.value.refreshInspector = !!data.refreshInspector;
}, },
save() { save() {
const cfg = toRaw(config.value); const cfg = toRaw(config.value);

View File

@ -22,13 +22,6 @@ export default defineComponent({
}, },
}, },
setup(props, context) { setup(props, context) {
function _evalCode(code: string) {
if (chrome && chrome.devtools) {
chrome.devtools.inspectedWindow.eval(code);
} else {
console.log(code);
}
}
watch( watch(
() => props.data, () => props.data,
(newValue: NodeInfoData, oldValue: NodeInfoData) => { (newValue: NodeInfoData, oldValue: NodeInfoData) => {