Files
classhelper-island-refactor…/scripts/fix02.mjs
T
ClassIsland Prompt Kit 22c1784bab feat: ClassIsland / ClassHelper 灵动岛提示词套件
- 重构版主提示词(14 parts,面向 ClassHelper 灵动岛重构)
- ClassIsland 全量规格提示词(20 parts,含分卷与逐章版本)
- 投喂指南、分卷、逐节文件
- 调研记录、一致性基线、生成与质检脚本
2026-11-12 21:59:58 +08:00

22 lines
5.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { readFileSync, writeFileSync } from 'node:fs';
const p = 'parts/02-tech-stack.md';
let t = readFileSync(p, 'utf8');
const oldBullets = `- \`width/height\` 使用"固定包围盒":取所有形态(胶囊/展开/紧急/叫人)中最大者 + 阴影留白 \`ISLAND_SHADOW_PAD = 10\`,**开合过程中窗口尺寸不变**,形变全部发生在渲染层画布内。依据:\`repos/ClassHelper-master/packages/shared/src/constants.ts:344-351\`、\`src/main/island.ts:72-112\`。
- 窗口标志:\`frame:false\`、\`transparent:true\`、\`resizable:false\`、\`movable:false\`、\`minimizable:false\`、\`maximizable:false\`、\`fullscreenable:false\`、\`skipTaskbar:true\`、\`hasShadow:false\`、\`focusable:true\`、\`alwaysOnTop:true\`、\`type:'toolbar'\`。依据:\`src/main/island.ts:480-504\`。
- \`webPreferences\`:\`preload\` 指向 \`dist/preload/island.js\`、\`contextIsolation:true\`、\`nodeIntegration:false\`、\`sandbox:true\`、\`backgroundThrottling:false\`。依据:\`:505-511\`。
- 创建后必须:\`setAlwaysOnTop(appearance.alwaysOnTop,'screen-saver')\`、\`setVisibleOnAllWorkspaces(true,{visibleOnFullScreen:true})\`、\`setWindowOpenHandler(()=>({action:'deny'}))\`、\`will-navigate\` 白名单校验、默认 \`setIgnoreMouseEvents(true,{forward:true})\`、**禁止** \`setBackgroundMaterial()\`。依据:\`:514-527\`。
- 定位:默认顶部居中,6 个停靠位(\`top-center/top-left/top-right/bottom-center/bottom-left/bottom-right\`),左右边距仅左/右停靠生效(\`marginX\` 默认 8、\`marginY\` 默认 8)。依据:\`constants.ts:285-321\`。`;
const newBullets = `- \`width/height\` 使用"固定包围盒 + 窗内形变",**以第 4 部分 4.3 为唯一实现口径**:\`winW = 目标屏幕宽(DIP)\`,\`winH = contentMaxHeight + 2 × safePadding\`(\`safePadding ≥ 20\`,其中包含阴影/光晕余量,参考 ClassHelper 的 \`ISLAND_SHADOW_PAD = 10\` 双侧口径);窗口在开合、行增删与提醒展开过程中尺寸不变,形变全部发生在渲染层画布内,只有显示器/DPI 变化、行数超出上限、编辑模式进出、偏移/缩放/停靠设置变化时才 \`setBounds\` 且节流 ≥100ms。依据:\`repos/ClassHelper-master/packages/desktop-client/src/main/island.ts:72-112,480-512\`(固定包围盒思想)与第 4 部分 4.3(ClassIsland 全屏宽窗口适配)。
- 窗口标志:\`frame:false\`、\`transparent:true\`、\`resizable:false\`、\`movable:false\`、\`minimizable:false\`、\`maximizable:false\`、\`fullscreenable:false\`、\`skipTaskbar:true\`、\`hasShadow:false\`、\`focusable:false\`、\`alwaysOnTop:true\`、\`type:'toolbar'\`。依据:\`src/main/island.ts:480-504\`;其中 \`focusable\` 必须为 \`false\`(ClassIsland 主窗口不抢焦点,见 04 §4.2)。
- \`webPreferences\`:\`preload\` 指向 \`dist/preload/island.js\`、\`contextIsolation:true\`、\`nodeIntegration:false\`、\`sandbox:true\`、\`backgroundThrottling:false\`。依据:\`:505-511\`。
- 创建后必须:\`setAlwaysOnTop(appearance.alwaysOnTop,'screen-saver')\`、\`setVisibleOnAllWorkspaces(true,{visibleOnFullScreen:true})\`、\`setWindowOpenHandler(()=>({action:'deny'}))\`、\`will-navigate\` 白名单校验、默认 \`setIgnoreMouseEvents(true,{forward:true})\`、**禁止** \`setBackgroundMaterial()\`。依据:\`:514-527\`。
- 定位:按 ClassIsland 的 6 个停靠位(\`WindowDockingLocation\`:0 左上 / 1 中上 / 2 右上 / 3 左下 / 4 中下 / 5 右下)+ \`WindowDockingOffsetX/Y\`(默认 0)+ \`WindowDockingMonitorIndex\`(默认 0);ClassHelper 的 \`top-center\` 等 6 个枚举与 \`marginX/marginY=8\` 只作参考,**不得**替代 ClassIsland 的停靠与偏移语义。依据:\`repos/ClassIsland/ClassIsland/Models/Settings.cs:1810-1833\`。`;
if (!t.includes(oldBullets)) throw new Error('未找到 2.7 岛窗口段落');
t = t.replace(oldBullets, newBullets);
const oldSettings = `**设置窗口**必须采用 ClassHelper 主窗口参数作为基线(\`width 1242\`、\`height 582\`、\`minWidth 1000\`、\`minHeight 540\`、\`center:true\`、\`autoHideMenuBar:true\`、\`backgroundColor\` 随主题 \`#161719\`/\`#f3f3f3\`),并补上 \`preload: dist/preload/index.js\`、\`contextIsolation:true\`、\`nodeIntegration:false\`、\`sandbox:true\`、\`backgroundThrottling:false\`。依据:\`src/main/index.ts:63-88\`。`;
const newSettings = `**设置窗口**必须采用 **ClassIsland 的尺寸(第 10 部分为唯一口径)**:\`width 1240\`、\`height 550\`、\`minWidth 560\`、\`frame:false\`(Windows 11 21H2+ 可用 Mica,否则退回纯色背景)、\`center:true\`、\`minHeight 550\`,并补上 \`preload: dist/preload/index.js\`、\`contextIsolation:true\`、\`nodeIntegration:false\`、\`sandbox:true\`、\`backgroundThrottling:false\`。依据:\`repos/ClassIsland/ClassIsland/Views/SettingsWindowNew.axaml\`(第 10 部分 10.1)与 \`src/main/index.ts:63-88\`(窗口骨架参考)。`;
if (!t.includes(oldSettings)) throw new Error('未找到设置窗口段落');
t = t.replace(oldSettings, newSettings);
writeFileSync(p, t, 'utf8');
console.log('02 §2.7 patched');