feat(publish): add tenant publish management with desktop deep-link
Expose tenant-authenticated publish task list and retry endpoints so the admin web can show desktop publish state without an Electron bridge, and register a `shengxintui://` deep-link so the page can hand off to the desktop client workbench. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -77,6 +77,7 @@ const enUS = {
|
||||
freeCreate: 'Free Create',
|
||||
imitation: 'Imitation Create',
|
||||
media: 'Media',
|
||||
publishManagement: 'Publish Management',
|
||||
brandManagement: 'Brand Management',
|
||||
tracking: 'Tracking',
|
||||
trackingDetail: 'Data Details',
|
||||
@@ -202,6 +203,11 @@ const enUS = {
|
||||
description:
|
||||
'Review desktop-managed media bindings, authorization state, and sync results in one place.',
|
||||
},
|
||||
publishManagement: {
|
||||
title: 'Publish Management',
|
||||
description:
|
||||
'Review desktop publish tasks, external links, account workbench entry points, and retry state.',
|
||||
},
|
||||
brands: {
|
||||
title: 'Brand Library',
|
||||
description: 'Manage keywords, question sets, and competitors around each brand.',
|
||||
|
||||
@@ -77,6 +77,7 @@ const zhCN = {
|
||||
freeCreate: "自由创作",
|
||||
imitation: "仿写创作",
|
||||
media: "媒体管理",
|
||||
publishManagement: "发文管理",
|
||||
brandManagement: "品牌管理",
|
||||
brands: "品牌词库",
|
||||
tracking: "数据追踪",
|
||||
@@ -195,6 +196,10 @@ const zhCN = {
|
||||
title: "媒体管理",
|
||||
description: "统一查看桌面端媒体账号绑定、授权状态与同步结果。",
|
||||
},
|
||||
publishManagement: {
|
||||
title: "发文管理",
|
||||
description: "查看桌面端发布任务、外链、账号工作台入口和重发状态。",
|
||||
},
|
||||
brands: {
|
||||
title: "品牌词库",
|
||||
description: "围绕品牌维护关键词、问题集和竞品信息。",
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
PictureOutlined,
|
||||
RadarChartOutlined,
|
||||
SearchOutlined,
|
||||
SendOutlined,
|
||||
} from '@ant-design/icons-vue'
|
||||
import { useQuery } from '@tanstack/vue-query'
|
||||
import { computed, type Component } from 'vue'
|
||||
@@ -130,6 +131,7 @@ const navSections = computed<NavSection[]>(() => {
|
||||
title: t('nav.contentManagement'),
|
||||
items: [
|
||||
{ key: '/media', label: t('nav.media'), icon: GlobalOutlined },
|
||||
{ key: '/publish-management', label: t('nav.publishManagement'), icon: SendOutlined },
|
||||
{ key: '/knowledge', label: t('nav.knowledge'), icon: BookOutlined },
|
||||
{ key: '/images', label: t('nav.images'), icon: PictureOutlined },
|
||||
],
|
||||
|
||||
@@ -69,6 +69,7 @@ import type {
|
||||
KolSubscriptionPromptCard,
|
||||
KolSubscriptionPromptSchema,
|
||||
KolWorkspaceCard,
|
||||
ListDesktopPublishTasksParams,
|
||||
LoginRequest,
|
||||
LoginResponse,
|
||||
MediaPlatform,
|
||||
@@ -114,6 +115,7 @@ import type {
|
||||
TemplateSaveDraftResponse,
|
||||
TemplateTitleTaskRequest,
|
||||
TemplateTitleTaskResultResponse,
|
||||
TenantPublishTaskListResponse,
|
||||
UpdateArticleRequest,
|
||||
UpdateKolPackageRequest,
|
||||
UpdateKolPromptRequest,
|
||||
@@ -1105,6 +1107,19 @@ export const publishJobsApi = {
|
||||
},
|
||||
}
|
||||
|
||||
export const publishTasksApi = {
|
||||
list(params: ListDesktopPublishTasksParams = {}) {
|
||||
return apiClient.get<TenantPublishTaskListResponse>('/api/tenant/publish-tasks', {
|
||||
params,
|
||||
})
|
||||
},
|
||||
retry(taskId: string) {
|
||||
return apiClient.post<CreatePublishJobResponse>(
|
||||
`/api/tenant/publish-tasks/${encodeURIComponent(taskId)}/retry`,
|
||||
)
|
||||
},
|
||||
}
|
||||
|
||||
export const complianceApi = {
|
||||
runtimeStatus() {
|
||||
return apiClient.get<ComplianceRuntimeStatus>('/api/tenant/compliance/runtime-status')
|
||||
|
||||
@@ -124,6 +124,16 @@ const router = createRouter({
|
||||
navKey: '/media',
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'publish-management',
|
||||
name: 'publish-management',
|
||||
component: () => import('@/views/PublishManagementView.vue'),
|
||||
meta: {
|
||||
titleKey: 'route.publishManagement.title',
|
||||
descriptionKey: 'route.publishManagement.description',
|
||||
navKey: '/publish-management',
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'brands',
|
||||
name: 'brands',
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -46,6 +46,10 @@ mac:
|
||||
electronLanguages:
|
||||
- en
|
||||
- zh_CN
|
||||
protocols:
|
||||
- name: Shengxintui URL
|
||||
schemes:
|
||||
- shengxintui
|
||||
extendInfo:
|
||||
NSCameraUsageDescription: 用于视频会议和录屏功能
|
||||
NSMicrophoneUsageDescription: 用于音频采集
|
||||
|
||||
@@ -76,6 +76,7 @@ if (process.platform === 'win32') {
|
||||
}
|
||||
|
||||
const isDevelopmentRuntime = !app.isPackaged
|
||||
const desktopDeepLinkScheme = 'shengxintui'
|
||||
|
||||
function silencePackagedConsole(): void {
|
||||
if (isDevelopmentRuntime) {
|
||||
@@ -119,6 +120,8 @@ let mainWindowCreatePromise: Promise<ElectronBrowserWindow> | null = null
|
||||
let loginWindowCreatePromise: Promise<ElectronBrowserWindow> | null = null
|
||||
let settingsWindowCreatePromise: Promise<ElectronBrowserWindow> | null = null
|
||||
let windowModeSwitchQueue: Promise<void> = Promise.resolve()
|
||||
let canHandleDesktopDeepLinks = false
|
||||
const pendingDesktopDeepLinks: string[] = []
|
||||
const forceCloseWindows = new WeakSet<ElectronBrowserWindow>()
|
||||
const appWindowModes = new WeakMap<ElectronBrowserWindow, RendererWindowMode>()
|
||||
|
||||
@@ -489,19 +492,19 @@ function queueWindowModeSwitch(
|
||||
}
|
||||
|
||||
async function openSettingsWindow(): Promise<void> {
|
||||
const window = await ensureSettingsWindow();
|
||||
const parent = settingsWindowParent();
|
||||
const window = await ensureSettingsWindow()
|
||||
const parent = settingsWindowParent()
|
||||
if (parent && window.getParentWindow() !== parent) {
|
||||
window.setParentWindow(parent);
|
||||
window.setParentWindow(parent)
|
||||
}
|
||||
await revealWindow(window);
|
||||
await revealWindow(window)
|
||||
}
|
||||
|
||||
function settingsWindowParent(): ElectronBrowserWindow | undefined {
|
||||
if (process.platform !== "win32") {
|
||||
return undefined;
|
||||
if (process.platform !== 'win32') {
|
||||
return undefined
|
||||
}
|
||||
return currentMainWindow() ?? undefined;
|
||||
return currentMainWindow() ?? undefined
|
||||
}
|
||||
|
||||
function rendererURL(): string | null {
|
||||
@@ -713,6 +716,79 @@ function isSafeExternalUrl(url: string): boolean {
|
||||
}
|
||||
}
|
||||
|
||||
function registerDesktopProtocolClient(): void {
|
||||
if (app.isDefaultProtocolClient(desktopDeepLinkScheme)) {
|
||||
return
|
||||
}
|
||||
|
||||
if (process.defaultApp && process.execPath) {
|
||||
app.setAsDefaultProtocolClient(desktopDeepLinkScheme, process.execPath, [
|
||||
process.argv[1] ?? '',
|
||||
])
|
||||
return
|
||||
}
|
||||
|
||||
app.setAsDefaultProtocolClient(desktopDeepLinkScheme)
|
||||
}
|
||||
|
||||
function extractDesktopDeepLink(argv: string[]): string | null {
|
||||
return argv.find((item) => item.startsWith(`${desktopDeepLinkScheme}://`)) ?? null
|
||||
}
|
||||
|
||||
function queueDesktopDeepLink(rawUrl: string | null | undefined): void {
|
||||
if (!rawUrl) {
|
||||
return
|
||||
}
|
||||
if (!canHandleDesktopDeepLinks) {
|
||||
pendingDesktopDeepLinks.push(rawUrl)
|
||||
return
|
||||
}
|
||||
handleDesktopDeepLink(rawUrl)
|
||||
}
|
||||
|
||||
function flushPendingDesktopDeepLinks(): void {
|
||||
canHandleDesktopDeepLinks = true
|
||||
const links = pendingDesktopDeepLinks.splice(0)
|
||||
for (const link of links) {
|
||||
handleDesktopDeepLink(link)
|
||||
}
|
||||
}
|
||||
|
||||
function handleDesktopDeepLink(rawUrl: string): void {
|
||||
let parsed: URL
|
||||
try {
|
||||
parsed = new URL(rawUrl)
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
if (parsed.protocol !== `${desktopDeepLinkScheme}:` || parsed.hostname !== 'desktop') {
|
||||
return
|
||||
}
|
||||
|
||||
if (
|
||||
parsed.pathname === '/workbench' ||
|
||||
parsed.searchParams.get('action') === 'open-publish-account-console'
|
||||
) {
|
||||
const account = {
|
||||
id: parsed.searchParams.get('account_id') ?? '',
|
||||
platform: parsed.searchParams.get('platform') ?? '',
|
||||
platformUid: parsed.searchParams.get('platform_uid') ?? '',
|
||||
displayName: parsed.searchParams.get('display_name') ?? '',
|
||||
}
|
||||
if (!account.id || !account.platform) {
|
||||
return
|
||||
}
|
||||
|
||||
void openPublishAccountConsole(account).catch((error) => {
|
||||
console.warn('[desktop-deeplink] open publish account console failed', {
|
||||
accountId: account.id,
|
||||
platform: account.platform,
|
||||
message: error instanceof Error ? error.message : String(error),
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function registerBridgeHandlers(): void {
|
||||
ipcMain.handle('desktop:ping', () => 'pong')
|
||||
ipcMain.handle('desktop:device-info', () => resolveDesktopDeviceInfo())
|
||||
@@ -830,8 +906,9 @@ function registerBridgeHandlers(): void {
|
||||
})
|
||||
}
|
||||
|
||||
const hasSingleInstanceLock = initSingleInstance(() => {
|
||||
const hasSingleInstanceLock = initSingleInstance((argv) => {
|
||||
revealActiveWindowSafely('single-instance')
|
||||
queueDesktopDeepLink(extractDesktopDeepLink(argv))
|
||||
})
|
||||
|
||||
if (!hasSingleInstanceLock) {
|
||||
@@ -842,6 +919,7 @@ if (!hasSingleInstanceLock) {
|
||||
.whenReady()
|
||||
.then(async () => {
|
||||
suppressNativeWindowMenu()
|
||||
registerDesktopProtocolClient()
|
||||
currentWindowMode = readPersistedWindowMode()
|
||||
initDesktopAppSettings()
|
||||
registerBridgeHandlers()
|
||||
@@ -864,6 +942,8 @@ if (!hasSingleInstanceLock) {
|
||||
revealActiveWindowSafely('tray')
|
||||
})
|
||||
startDesktopHealthIndicator(() => currentMainWindow())
|
||||
queueDesktopDeepLink(extractDesktopDeepLink(process.argv))
|
||||
flushPendingDesktopDeepLinks()
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('[desktop-main] app.whenReady failed', error)
|
||||
@@ -873,6 +953,12 @@ if (!hasSingleInstanceLock) {
|
||||
revealActiveWindowSafely('activate')
|
||||
})
|
||||
|
||||
app.on('open-url', (event, url) => {
|
||||
event.preventDefault()
|
||||
revealActiveWindowSafely('deep-link')
|
||||
queueDesktopDeepLink(url)
|
||||
})
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
if (getDesktopAppSettings().keepRunningInBackground) {
|
||||
return
|
||||
|
||||
@@ -2,7 +2,7 @@ import { app } from 'electron/main'
|
||||
|
||||
let initialized = false
|
||||
|
||||
export function initSingleInstance(onSecondInstance?: () => void): boolean {
|
||||
export function initSingleInstance(onSecondInstance?: (argv: string[]) => void): boolean {
|
||||
if (initialized) {
|
||||
return true
|
||||
}
|
||||
@@ -13,8 +13,8 @@ export function initSingleInstance(onSecondInstance?: () => void): boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
app.on('second-instance', () => {
|
||||
onSecondInstance?.()
|
||||
app.on('second-instance', (_event, argv) => {
|
||||
onSecondInstance?.(argv)
|
||||
})
|
||||
|
||||
return true
|
||||
|
||||
Reference in New Issue
Block a user