refactor(launcher): open mod documentation on wto-project.net
Replace the local offline HTML mod docs viewer in the launcher Mods page with a direct link to https://wto-project.net/mod-docs, remove the unused mods:openDocs IPC path and resource entry, and drop build-mod-docs-html.ts from Windows packaging while keeping bundled mod templates intact. Root typecheck, launcher typecheck, and electron-vite build passed.
This commit is contained in:
1 parent
742094ea1e
commit
02fe867cf1
7 files changed
+4
-439
No files matched your search
@@ -24,7 +24,6 @@ import {
|
||||
exportModPreset,
|
||||
getModsState,
|
||||
importModPreset,
|
||||
openModDocs,
|
||||
openModsFolder,
|
||||
saveModPreset,
|
||||
setModEnabled,
|
||||
@@ -224,7 +223,6 @@ 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,20 +118,6 @@ 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,8 +19,6 @@ 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 {
|
||||
@@ -37,7 +35,6 @@ 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.
|
||||
@@ -47,7 +44,6 @@ export function bundledResourcePaths(): ResourcePaths {
|
||||
networkHookLibrary: join(repository, 'build', 'native', 'wto_ws.dll'),
|
||||
appIcon: join(repository, 'apps', 'launcher', 'resources', 'icon.ico'),
|
||||
modTemplates: join(repository, 'mod-dev-docs', 'templates'),
|
||||
modDocs: join(repository, 'build', 'mod-dev-docs'),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@ import { Sheet } from '../../components/Sheet.tsx';
|
||||
import { ipcInvoke } from '../../ipc.ts';
|
||||
import type { ModsSection } from '../../shell/navigation.ts';
|
||||
|
||||
const MOD_DOCS_URL = 'https://wto-project.net/mod-docs';
|
||||
|
||||
interface Props {
|
||||
readonly copy: InstallRecord;
|
||||
readonly section: ModsSection;
|
||||
@@ -255,9 +257,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)}>
|
||||
<a className="button" href={MOD_DOCS_URL} target="_blank" rel="noreferrer">
|
||||
{t('mods.openDocs')}
|
||||
</button>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
{state.discoveryErrors.length > 0 && (
|
||||
|
||||
@@ -303,10 +303,6 @@ 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