Add product wordcloud board links
This commit is contained in:
@@ -3,6 +3,7 @@ import type { FormEvent } from 'react';
|
||||
import AppSettingsWindow, { type ThemeMode } from '../components/AppSettingsWindow';
|
||||
import { apiUrl, ensureOk } from '../lib/api';
|
||||
import { IconArchive, IconGrid, IconHelp, IconLock, IconRefresh, IconTrash } from '../components/Icons';
|
||||
import { wordCloudBoardUrl, type WordCloudBoardRoute } from '../lib/wordcloudBoard';
|
||||
import {
|
||||
deleteProduct,
|
||||
getProduct,
|
||||
@@ -21,6 +22,12 @@ interface ProductArchivePageProps {
|
||||
|
||||
const TOKEN_KEY = 'wordcloud-orders-token';
|
||||
|
||||
const wordCloudBoardActions: Array<{ label: string; route: WordCloudBoardRoute }> = [
|
||||
{ label: '个人查找', route: 'cloud' },
|
||||
{ label: '现场大屏', route: 'screen' },
|
||||
{ label: '手机控制', route: 'control' },
|
||||
];
|
||||
|
||||
function statusClass(status: ProductStatus): string {
|
||||
if (status === 'active') return 'product-status-archived';
|
||||
if (status === 'pending_cleanup' || status === 'failed_cleanup') return 'product-status-pending-cleanup';
|
||||
@@ -57,6 +64,12 @@ function formatDateTime(value: string): string {
|
||||
});
|
||||
}
|
||||
|
||||
function hasWordCloudArchive(detail: ProductDetail): boolean {
|
||||
return detail.versions.some(version =>
|
||||
version.wordcloud_archives.some(archive => archive.source_job_id.trim().length > 0),
|
||||
);
|
||||
}
|
||||
|
||||
function AuthenticatedImage({
|
||||
token,
|
||||
imageUrl,
|
||||
@@ -257,6 +270,9 @@ export default function ProductArchivePage({
|
||||
: null;
|
||||
const previewUrl = previewImage?.image_url || '';
|
||||
const latestVersion = detail?.versions[detail.versions.length - 1] || null;
|
||||
const canOpenWordCloudBoard = detail !== null
|
||||
&& selected?.status === 'active'
|
||||
&& hasWordCloudArchive(detail);
|
||||
|
||||
return (
|
||||
<div className="orders-page product-archive-page">
|
||||
@@ -426,6 +442,32 @@ export default function ProductArchivePage({
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<section className="product-archive-board-links" aria-labelledby="wordcloud-board-title">
|
||||
<h3 id="wordcloud-board-title">词云互动</h3>
|
||||
<div className="product-archive-board-actions">
|
||||
{wordCloudBoardActions.map(action => (
|
||||
canOpenWordCloudBoard ? (
|
||||
<a
|
||||
className="btn btn-secondary btn-sm"
|
||||
href={wordCloudBoardUrl(action.route, detail.product_id)}
|
||||
key={action.route}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
{action.label}
|
||||
</a>
|
||||
) : (
|
||||
<button className="btn btn-secondary btn-sm" disabled key={action.route} type="button">
|
||||
{action.label}
|
||||
</button>
|
||||
)
|
||||
))}
|
||||
</div>
|
||||
{!canOpenWordCloudBoard && (
|
||||
<p className="product-archive-board-note">暂无可用词云归档</p>
|
||||
)}
|
||||
</section>
|
||||
|
||||
<div className="product-archive-timeline">
|
||||
<h3>版本时间线</h3>
|
||||
{detail.versions.length === 0 && <p>暂无设计版本。</p>}
|
||||
|
||||
Reference in New Issue
Block a user