feat(publish): add baijiahao and jianshu desktop adapters
Wires up Baijiahao (百家号) and Jianshu (简书) as first-class desktop publish targets, with risk-control prompts surfaced in the runtime controller and a normalized error message in publish records. Adds external-link buttons in the publish management table, an asset format conversion endpoint for cover image compatibility, and reorders publish-status display priority so failures take precedence over partial successes. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,7 @@ import { hostname } from "node:os";
|
||||
import { readFileSync, writeFileSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
|
||||
import { shell } from "electron";
|
||||
import { BrowserWindow, app, ipcMain, nativeTheme } from "electron/main";
|
||||
import type {
|
||||
BrowserWindow as ElectronBrowserWindow,
|
||||
@@ -269,6 +270,15 @@ function safeHandle<Args extends unknown[], Result>(
|
||||
});
|
||||
}
|
||||
|
||||
function isSafeExternalUrl(url: string): boolean {
|
||||
try {
|
||||
const parsed = new URL(url);
|
||||
return parsed.protocol === "http:" || parsed.protocol === "https:";
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function registerBridgeHandlers(): void {
|
||||
ipcMain.handle("desktop:ping", () => "pong");
|
||||
ipcMain.handle("desktop:device-info", () => ({
|
||||
@@ -309,6 +319,13 @@ function registerBridgeHandlers(): void {
|
||||
safeHandle("desktop:retry-publish-task", async (_event, taskId: string) => {
|
||||
return retryDesktopPublishTask(taskId);
|
||||
});
|
||||
safeHandle("desktop:open-external-url", async (_event, url: string) => {
|
||||
if (!isSafeExternalUrl(url)) {
|
||||
throw new Error("unsupported_external_url");
|
||||
}
|
||||
await shell.openExternal(url);
|
||||
return null;
|
||||
});
|
||||
ipcMain.handle(
|
||||
"desktop:runtime-session-sync",
|
||||
(_event, session: DesktopRuntimeSessionSyncRequest | null) => {
|
||||
|
||||
Reference in New Issue
Block a user