修复快照完整性:raw/llm_wiki 由 gitlink 转为普通目录(.git 备份为 .git.bak),新增 .gitignore 排除 __pycache__/pyc 与子仓库元数据

This commit is contained in:
AAsige
2026-08-07 04:42:28 +08:00
parent ee302f615c
commit c6ec760e71
443 changed files with 147453 additions and 142 deletions
+56
View File
@@ -0,0 +1,56 @@
importScripts("clipper-core.js");
const COMMAND_NAME = "clip-current-page";
let badgeTimer;
let clipInFlight = false;
async function setBadge(text, color, title, clearAfterMs = 0) {
clearTimeout(badgeTimer);
await chrome.action.setBadgeBackgroundColor({ color });
await chrome.action.setBadgeText({ text });
if (title) await chrome.action.setTitle({ title });
if (clearAfterMs > 0) {
badgeTimer = setTimeout(() => {
void chrome.action.setBadgeText({ text: "" });
void chrome.action.setTitle({ title: "LLM Wiki Clipper" });
}, clearAfterMs);
}
}
async function clipCurrentPage(commandTab) {
if (clipInFlight) {
await setBadge("…", "#4f46e5", "A page clip is already in progress");
return;
}
clipInFlight = true;
const core = globalThis.LLMWikiClipper;
try {
await setBadge("…", "#4f46e5", "Clipping current page...");
const settings = await core.loadSettings();
const connection = {
serverUrl: settings.serverUrl,
accessToken: settings.accessToken,
};
const { projects, baseUrl } = await core.loadProjects(connection);
connection.serverUrl = baseUrl;
const project = core.selectProject(projects, settings.preferredProjectPath);
if (!project) throw new Error("No LLM Wiki project is available");
const page = await core.extractActiveTab(commandTab);
const submitted = await core.submitClip(page, project.path, connection);
await chrome.storage.local.set({
serverUrl: submitted.baseUrl,
});
await setBadge("✓", "#059669", `Saved to ${project.name || "LLM Wiki"}`, 4000);
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.error("[LLM Wiki Clipper] shortcut failed:", error);
await setBadge("!", "#dc2626", `Clip failed: ${message}`, 7000);
} finally {
clipInFlight = false;
}
}
chrome.commands.onCommand.addListener((command, tab) => {
if (command === COMMAND_NAME) void clipCurrentPage(tab);
});