清理冗余代码:删除未使用变量、types.ts 改为 .d.ts、测试路径改引 dist/

- 删除未使用的 getActiveEnv 解构、sender 参数改为 _sender
- types.ts 重命名为 types.d.ts,消除无用的 dist/types.js 产物
- 测试文件引用路径从根目录改为 dist/
This commit is contained in:
陈银军
2026-09-17 01:44:53 +08:00
committed by chenxuan
parent 9725520018
commit 9ccc9253d3
12 changed files with 13 additions and 14 deletions
+1 -1
View File
@@ -114,7 +114,7 @@ chrome.storage.onChanged.addListener(async (changes, areaName) => {
console.warn("[AutoLogin] 持久化失败:", err);
}
});
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
chrome.runtime.onMessage.addListener((message, _sender, sendResponse) => {
(async () => {
try {
switch (message.action) {
+1 -1
View File
@@ -501,7 +501,7 @@ function showEnvPicker(configs) {
document.body.appendChild(overlay);
envPickerEl = overlay;
}
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
chrome.runtime.onMessage.addListener((message, _sender, sendResponse) => {
if (message.action === "manualFill" && message.config) {
resetDomainAttempts(message.config.envId, message.config.domain);
const filled = fillForm(message.config, true);
+1 -1
View File
@@ -260,7 +260,7 @@ document.addEventListener("DOMContentLoaded", () => {
el.addEventListener("change", saveDraft);
});
// 环境数据层(EnvStore)
const { loadEnvironments, saveEnvironments, getActiveEnv, setActiveEnv, createEnvironment, renameEnvironment, deleteEnvironment, loadConfigs, saveConfigs, loadAllConfigs, genId, genCfgId, } = EnvStore;
const { loadEnvironments, saveEnvironments, setActiveEnv, createEnvironment, renameEnvironment, deleteEnvironment, loadConfigs, saveConfigs, loadAllConfigs, genId, genCfgId, } = EnvStore;
// isDomainMatch 由 utils.js 提供(全局函数)
const DRAFT_KEY = "formDraft";
function saveDraft() {
-1
View File
@@ -1 +0,0 @@
export {};
+1 -1
View File
@@ -112,7 +112,7 @@ chrome.storage.onChanged.addListener(async (changes, areaName) => {
});
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
chrome.runtime.onMessage.addListener((message, _sender, sendResponse) => {
(async () => {
try {
switch (message.action) {
+1 -1
View File
@@ -561,7 +561,7 @@ function showEnvPicker(configs: Config[]): void {
}
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
chrome.runtime.onMessage.addListener((message, _sender, sendResponse) => {
if (message.action === "manualFill" && message.config) {
resetDomainAttempts(message.config.envId, message.config.domain);
const filled = fillForm(message.config, true);
+1 -1
View File
@@ -280,7 +280,7 @@ document.addEventListener("DOMContentLoaded", () => {
const {
loadEnvironments,
saveEnvironments,
getActiveEnv,
setActiveEnv,
createEnvironment,
renameEnvironment,
View File
+2 -2
View File
@@ -27,8 +27,8 @@ function createMemoryStorage() {
function loadCryptoStore(storage) {
global.chrome = { storage };
delete require.cache[require.resolve("../crypto-store.js")];
return require("../crypto-store.js");
delete require.cache[require.resolve("../dist/crypto-store.js")];
return require("../dist/crypto-store.js");
}
describe("crypto-store - 基础加解密", () => {
+2 -2
View File
@@ -35,7 +35,7 @@ function createMockDoc(elements) {
// 加载 content.js 到 vm 沙箱,返回沙箱上下文
function loadContentJs(mockDoc) {
const code = fs.readFileSync(path.join(__dirname, "..", "content.js"), "utf8");
const code = fs.readFileSync(path.join(__dirname, "..", "dist", "content.js"), "utf8");
const sandbox = {
URL: globalThis.URL,
window: { location: { href: "https://example.com/login" } },
@@ -62,7 +62,7 @@ function loadContentJs(mockDoc) {
sandbox.globalThis = sandbox;
vm.createContext(sandbox);
// 先加载 utils.js
const utilsCode = fs.readFileSync(path.join(__dirname, "..", "utils.js"), "utf8");
const utilsCode = fs.readFileSync(path.join(__dirname, "..", "dist", "utils.js"), "utf8");
vm.runInContext(utilsCode, sandbox);
vm.runInContext(code, sandbox);
return sandbox;
+2 -2
View File
@@ -33,8 +33,8 @@ function createMemoryStorage() {
function loadEnvStore(storage) {
global.chrome = { storage };
delete require.cache[require.resolve("../env-store.js")];
return require("../env-store.js");
delete require.cache[require.resolve("../dist/env-store.js")];
return require("../dist/env-store.js");
}
describe("env-store - 读写 session", () => {
+1 -1
View File
@@ -4,7 +4,7 @@
const { describe, it } = require("node:test");
const assert = require("node:assert/strict");
const { isDomainMatch, escapeHtml } = require("../utils.js");
const { isDomainMatch, escapeHtml } = require("../dist/utils.js");
describe("isDomainMatch - 纯 hostname 匹配", () => {
it("精确域名匹配", () => {