docs(mods): add standalone mod-dev-docs handbook and launcher quick-open button
This commit is contained in:
1 parent
5983e3f3e2
commit
aa952e7cca
26 files changed
+1619
-145
No files matched your search
@@ -24,6 +24,7 @@ import {
|
||||
exportModPreset,
|
||||
getModsState,
|
||||
importModPreset,
|
||||
openModDocs,
|
||||
openModsFolder,
|
||||
saveModPreset,
|
||||
setModEnabled,
|
||||
@@ -223,6 +224,7 @@ export function registerIpcHandlers(): void {
|
||||
return importModPreset(copyId, BrowserWindow.fromWebContents(sender));
|
||||
});
|
||||
handle('mods:openFolder', () => openModsFolder());
|
||||
handle('mods:openDocs', (input) => openModDocs(input?.language));
|
||||
handle('mods:setFolder', async ({ copyId, path }) => {
|
||||
requireModsWritable();
|
||||
const state = await setModsFolder(copyId, path);
|
||||
|
||||
@@ -118,6 +118,20 @@ export async function openModsFolder(): Promise<void> {
|
||||
if (failure) console.warn('[mods] opening the mods folder failed:', modsDir, failure);
|
||||
}
|
||||
|
||||
export async function openModDocs(language?: string): Promise<void> {
|
||||
const docsRoot = resourcePaths().modDocs;
|
||||
const preferred = language && language.toLowerCase().startsWith('zh') ? 'zh-CN.html' : 'en.html';
|
||||
const fallback = preferred === 'zh-CN.html' ? 'en.html' : 'zh-CN.html';
|
||||
const target = (await pathExists(join(docsRoot, preferred)))
|
||||
? join(docsRoot, preferred)
|
||||
: join(docsRoot, fallback);
|
||||
if (!(await pathExists(target))) {
|
||||
throw new AppError('folder_unreadable', { path: docsRoot });
|
||||
}
|
||||
const failure = await shell.openPath(target);
|
||||
if (failure) console.warn('[mods] opening the mod docs failed:', target, failure);
|
||||
}
|
||||
|
||||
export async function getModsState(copyId: string): Promise<ModsStateView> {
|
||||
const copy = await requireCopy(copyId);
|
||||
return buildModsStateView(copy);
|
||||
|
||||
@@ -19,6 +19,8 @@ export interface ResourcePaths {
|
||||
readonly appIcon: string;
|
||||
/** Bundled example mod templates seeded into an empty mods folder on first use. */
|
||||
readonly modTemplates: string;
|
||||
/** Offline HTML mod development handbook (zh-CN.html and en.html). */
|
||||
readonly modDocs: string;
|
||||
}
|
||||
|
||||
export function resourcePaths(): ResourcePaths {
|
||||
@@ -35,6 +37,7 @@ export function bundledResourcePaths(): ResourcePaths {
|
||||
networkHookLibrary: join(process.resourcesPath, 'native', 'wto_ws.dll'),
|
||||
appIcon: join(process.resourcesPath, 'icon.ico'),
|
||||
modTemplates: join(process.resourcesPath, 'mod-templates'),
|
||||
modDocs: join(process.resourcesPath, 'mod-dev-docs'),
|
||||
};
|
||||
}
|
||||
// The app path is apps/launcher; the repository is two levels up.
|
||||
@@ -44,6 +47,7 @@ export function bundledResourcePaths(): ResourcePaths {
|
||||
networkHookLibrary: join(repository, 'build', 'native', 'wto_ws.dll'),
|
||||
appIcon: join(repository, 'apps', 'launcher', 'resources', 'icon.ico'),
|
||||
modTemplates: join(repository, 'dev-docs', 'templates', 'mods'),
|
||||
modDocs: join(repository, 'build', 'mod-dev-docs'),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -702,6 +702,7 @@
|
||||
"autoSorted": "Reordered mods based on dependencies and load-order hints.",
|
||||
"refresh": "Refresh",
|
||||
"openFolder": "Open mods folder",
|
||||
"openDocs": "Mod docs",
|
||||
"discoveryErrorsTitle": "{{count}} mod folder(s) could not be loaded:",
|
||||
"blockingIssuesTitle": "{{count}} blocking mod error(s) prevent launching:",
|
||||
"issuesTitle": "{{count}} mod notice(s) or overlap(s):",
|
||||
|
||||
@@ -702,6 +702,7 @@
|
||||
"autoSorted": "已按前置与排序建议重新排列模组顺序。",
|
||||
"refresh": "刷新",
|
||||
"openFolder": "打开模组目录",
|
||||
"openDocs": "开发文档",
|
||||
"discoveryErrorsTitle": "有 {{count}} 个模组目录读取失败:",
|
||||
"blockingIssuesTitle": "存在 {{count}} 项阻塞性模组错误(处理前无法启动):",
|
||||
"issuesTitle": "检测到 {{count}} 项模组提示或冲突:",
|
||||
|
||||
@@ -255,6 +255,9 @@ export function ModsPage({ copy, section, readOnly, onError }: Props) {
|
||||
<button type="button" className="button" onClick={() => ipcInvoke('mods:openFolder').catch(onError)}>
|
||||
{t('mods.openFolder')}
|
||||
</button>
|
||||
<button type="button" className="button" onClick={() => ipcInvoke('mods:openDocs', { language: i18n.language }).catch(onError)}>
|
||||
{t('mods.openDocs')}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{state.discoveryErrors.length > 0 && (
|
||||
|
||||
@@ -303,6 +303,10 @@ export const ipcContract = {
|
||||
input: z.void(),
|
||||
output: z.void(),
|
||||
},
|
||||
'mods:openDocs': {
|
||||
input: z.object({ language: z.string().optional() }).optional(),
|
||||
output: z.void(),
|
||||
},
|
||||
'mods:setFolder': {
|
||||
input: z.object({ copyId: CopyIdSchema, path: z.string().min(1).nullable() }),
|
||||
output: ModsStateViewSchema,
|
||||
|
||||
Reference in new issue
Block a user