refactor(webui): use native link actions and remove website previews (#6391)
* refactor(webui): remove website previews and custom link menus * docs(webui): focus guide on product-specific usage
This commit is contained in:
1 parent
bc5c58d239
commit
08ca3b4525
42 files changed
+179
-1493
No files matched your search
@@ -1,7 +1,6 @@
|
||||
import { useState } from "react";
|
||||
|
||||
import { FilePreviewPanelView, type FilePreviewPanelState } from "@/components/FilePreviewPanelView";
|
||||
import { WebPreviewPanelView } from "@/components/WebPreviewPanelView";
|
||||
import { SessionInfoPopoverView } from "@/components/thread/SessionInfoPopoverView";
|
||||
import { SubagentThreadView } from "@/components/thread/SubagentThreadView";
|
||||
import type { AutomationUpdatePayload, SessionAutomationJob, UIMessage } from "@/lib/types";
|
||||
@@ -31,26 +30,6 @@ function FilePreview() {
|
||||
</div>;
|
||||
}
|
||||
|
||||
const localDocument = '<!doctype html><html lang="zh-CN"><meta charset="utf-8"><style>body{font-family:system-ui;padding:32px;color:#252525}h1{font-size:24px}p{line-height:1.7}code{background:#f2f2f2;padding:4px 8px;border-radius:6px}</style><h1>网页预览</h1><p>这段内容来自当前示例的本地文档。</p><p>点击顶部 <code>刷新</code> 按钮,重新显示文档;打开信息按钮查看隔离说明。</p></html>';
|
||||
|
||||
function WebsitePreview() {
|
||||
const { t } = useGalleryTranslation();
|
||||
const [mode, setMode] = useState<"available" | "native" | "unsupported" | "sameOrigin" | "mixedContent" | "invalid">("available");
|
||||
const [revision, setRevision] = useState(0);
|
||||
const url = mode === "invalid" ? null : new URL(mode === "sameOrigin" ? window.location.href : "https://example.com/preview");
|
||||
return <div className="space-y-4">
|
||||
<StatePicker label={t("previews.webPreview.state")} value={mode} options={["available", "native", "unsupported", "sameOrigin", "mixedContent", "invalid"]} onChange={setMode} />
|
||||
<div className="flex h-80 flex-col overflow-hidden rounded-control border">
|
||||
<WebPreviewPanelView url={url} restriction={mode === "available" ? null : mode} loopback={mode === "sameOrigin"}
|
||||
onRefresh={() => setRevision((value) => value + 1)}>
|
||||
<iframe key={revision} title={t("previews.webPreview.frame")} sandbox="" referrerPolicy="no-referrer" srcDoc={localDocument}
|
||||
className="min-h-0 w-full flex-1 border-0 bg-white" />
|
||||
</WebPreviewPanelView>
|
||||
</div>
|
||||
<p role="status" className="text-xs text-muted-foreground">{t("previews.webPreview.refreshes", { amount: revision })}</p>
|
||||
</div>;
|
||||
}
|
||||
|
||||
function exampleJobs(now: number): SessionAutomationJob[] {
|
||||
return [
|
||||
{ id: "gallery-daily-summary", name: "项目摘要", enabled: true, schedule: { kind: "every", every_ms: 3_600_000 },
|
||||
@@ -125,9 +104,6 @@ export const contentExamples: ComponentExample[] = [
|
||||
{ title: "previews.filePreview.title", files: ["webui/src/components/FilePreviewPanelView.tsx"], Preview: FilePreview,
|
||||
description: "previews.filePreview.description", options: "previews.filePreview.options",
|
||||
code: '<FilePreviewPanelView path={path} state={previewState} imageOpen={imageOpen} onImageOpenChange={setImageOpen} onImageError={reportImageError} />' },
|
||||
{ title: "previews.webPreview.title", files: ["webui/src/components/WebPreviewPanelView.tsx"], Preview: WebsitePreview,
|
||||
description: "previews.webPreview.description", options: "previews.webPreview.options",
|
||||
code: '<WebPreviewPanelView url={url} restriction={restriction} loopback={loopback} onRefresh={refresh}>{frame}</WebPreviewPanelView>' },
|
||||
{ title: "previews.session.title", files: ["webui/src/components/thread/SessionInfoPopoverView.tsx"], Preview: SessionPreview,
|
||||
description: "previews.session.description", options: "previews.session.options",
|
||||
code: '<SessionInfoPopoverView title={title} jobs={jobs} loading={loading} loadFailed={failed} now={now} onAction={act} onEdit={edit} onOpenCalendar={openCalendar} />' },
|
||||
|
||||
@@ -61,16 +61,6 @@
|
||||
"scope": "File scope",
|
||||
"hint": "Right-click for the copy menu, or focus the file and press Shift+F10."
|
||||
},
|
||||
"webLinks": {
|
||||
"title": "Web links · Link menu",
|
||||
"description": "Open the real link menu to select message links and copy addresses.",
|
||||
"options": "WebLink accepts link attributes. useMessageWebLinks collects rendered message links. MessageLinksMenu takes entries and back/close callbacks; expanded controls width. All example links point to local Gallery resources.",
|
||||
"width": "Link menu width",
|
||||
"message": "View the <gallery>component Gallery</gallery> and <brand>brand image</brand>.",
|
||||
"close": "Close link menu",
|
||||
"open": "View message links",
|
||||
"hint": "Right-click a link to copy its address. The message menu collects links from the rendered message."
|
||||
},
|
||||
"workbench": {
|
||||
"title": "PaneWorkbench · Multiple panes",
|
||||
"description": "Switch layouts, activate or add panes, and adjust their position and size.",
|
||||
@@ -235,14 +225,6 @@
|
||||
"options": "state supplies a display snapshot; path determines the file type and name. Image open and error callbacks update the preview.",
|
||||
"state": "File preview state"
|
||||
},
|
||||
"webPreview": {
|
||||
"title": "WebPreviewPanelView · Web content",
|
||||
"description": "Explore the web title bar, isolation notes and restrictions; refresh a local document.",
|
||||
"options": "The runtime chooses restriction before supplying content. children provides content; onRefresh requests a refresh. This iframe uses local srcDoc.",
|
||||
"state": "Web preview state",
|
||||
"frame": "Local example webpage",
|
||||
"refreshes": "Refreshes: {{amount}}"
|
||||
},
|
||||
"session": {
|
||||
"title": "SessionInfoPopoverView · Session automations",
|
||||
"description": "View, edit, disable and delete jobs, with loading and error states.",
|
||||
|
||||
@@ -61,16 +61,6 @@
|
||||
"scope": "Ámbito del archivo",
|
||||
"hint": "Haz clic derecho para abrir el menú de copia, o enfoca el archivo y pulsa Mayús+F10."
|
||||
},
|
||||
"webLinks": {
|
||||
"title": "Web links · Menú de enlaces",
|
||||
"description": "Abre el menú real de enlaces para elegir enlaces del mensaje y copiar direcciones.",
|
||||
"options": "WebLink recibe atributos de enlace. useMessageWebLinks recoge los enlaces renderizados. MessageLinksMenu recibe entradas y funciones de volver y cerrar; expanded controla el ancho. Todos los enlaces apuntan a recursos locales de la galería.",
|
||||
"width": "Ancho del menú de enlaces",
|
||||
"message": "Consulta la <gallery>galería de componentes</gallery> y la <brand>imagen de marca</brand>.",
|
||||
"close": "Cerrar menú de enlaces",
|
||||
"open": "Ver enlaces del mensaje",
|
||||
"hint": "Haz clic derecho en un enlace para copiar su dirección. El menú recoge los enlaces del mensaje renderizado."
|
||||
},
|
||||
"workbench": {
|
||||
"title": "PaneWorkbench · Paneles múltiples",
|
||||
"description": "Cambia la disposición, activa o añade paneles y ajusta su posición y tamaño.",
|
||||
@@ -235,14 +225,6 @@
|
||||
"options": "state aporta la instantánea visual; path determina el tipo y nombre del archivo. Las funciones de apertura y error de imagen actualizan la vista previa.",
|
||||
"state": "Estado de la vista previa del archivo"
|
||||
},
|
||||
"webPreview": {
|
||||
"title": "WebPreviewPanelView · Contenido web",
|
||||
"description": "Explora la barra de título, el aislamiento y las restricciones; actualiza un documento local.",
|
||||
"options": "El entorno de ejecución elige restriction antes de aportar el contenido. children lo contiene y onRefresh solicita una actualización. Este iframe usa un srcDoc local.",
|
||||
"state": "Estado de la vista previa web",
|
||||
"frame": "Página web local de ejemplo",
|
||||
"refreshes": "Actualizaciones: {{amount}}"
|
||||
},
|
||||
"session": {
|
||||
"title": "SessionInfoPopoverView · Automatizaciones de sesión",
|
||||
"description": "Consulta, edita, desactiva y elimina tareas con estados de carga y error.",
|
||||
|
||||
@@ -61,16 +61,6 @@
|
||||
"scope": "Emplacement du fichier",
|
||||
"hint": "Ouvrez le menu de copie par clic droit, ou placez le focus sur le fichier et appuyez sur Maj+F10."
|
||||
},
|
||||
"webLinks": {
|
||||
"title": "Web links · Menu des liens",
|
||||
"description": "Ouvrez le véritable menu des liens pour sélectionner un lien et copier son adresse.",
|
||||
"options": "WebLink reçoit les attributs du lien. useMessageWebLinks collecte les liens affichés. MessageLinksMenu reçoit les entrées et les rappels de retour et de fermeture ; expanded contrôle la largeur. Les liens pointent vers des ressources locales de la galerie.",
|
||||
"width": "Largeur du menu des liens",
|
||||
"message": "Consultez la <gallery>galerie de composants</gallery> et l’<brand>image de marque</brand>.",
|
||||
"close": "Fermer le menu des liens",
|
||||
"open": "Voir les liens du message",
|
||||
"hint": "Un clic droit permet de copier l’adresse d’un lien. Le menu collecte les liens du message affiché."
|
||||
},
|
||||
"workbench": {
|
||||
"title": "PaneWorkbench · Volets multiples",
|
||||
"description": "Changez la disposition, activez ou ajoutez des volets et ajustez leur position et leur taille.",
|
||||
@@ -235,14 +225,6 @@
|
||||
"options": "state fournit l’état d’affichage ; path détermine le type et le nom du fichier. Les rappels d’ouverture et d’erreur d’image actualisent l’aperçu.",
|
||||
"state": "État de l’aperçu du fichier"
|
||||
},
|
||||
"webPreview": {
|
||||
"title": "WebPreviewPanelView · Contenu web",
|
||||
"description": "Explorez le titre, l’isolation et les restrictions ; actualisez un document local.",
|
||||
"options": "Le runtime choisit restriction avant de fournir le contenu. children fournit le contenu ; onRefresh demande une actualisation. Cet iframe utilise un srcDoc local.",
|
||||
"state": "État de l’aperçu web",
|
||||
"frame": "Page web d’exemple locale",
|
||||
"refreshes": "Actualisations : {{amount}}"
|
||||
},
|
||||
"session": {
|
||||
"title": "SessionInfoPopoverView · Automatisations de session",
|
||||
"description": "Consultez, modifiez, désactivez et supprimez des tâches, avec chargement et erreurs.",
|
||||
|
||||
@@ -61,16 +61,6 @@
|
||||
"scope": "Cakupan berkas",
|
||||
"hint": "Klik kanan untuk membuka menu salin, atau fokuskan berkas lalu tekan Shift+F10."
|
||||
},
|
||||
"webLinks": {
|
||||
"title": "Web links · Menu tautan",
|
||||
"description": "Buka menu tautan asli untuk memilih tautan pesan dan menyalin alamatnya.",
|
||||
"options": "WebLink menerima atribut tautan. useMessageWebLinks mengumpulkan tautan yang dirender. MessageLinksMenu menerima entri serta callback kembali dan tutup; expanded mengatur lebar. Semua tautan menuju sumber daya galeri lokal.",
|
||||
"width": "Lebar menu tautan",
|
||||
"message": "Lihat <gallery>galeri komponen</gallery> dan <brand>gambar merek</brand>.",
|
||||
"close": "Tutup menu tautan",
|
||||
"open": "Lihat tautan pesan",
|
||||
"hint": "Klik kanan tautan untuk menyalin alamatnya. Menu mengumpulkan tautan dari pesan yang dirender."
|
||||
},
|
||||
"workbench": {
|
||||
"title": "PaneWorkbench · Beberapa panel",
|
||||
"description": "Ganti tata letak, aktifkan atau tambahkan panel, lalu atur posisi dan ukurannya.",
|
||||
@@ -235,14 +225,6 @@
|
||||
"options": "state menyediakan snapshot tampilan; path menentukan jenis dan nama berkas. Callback pembukaan dan kesalahan gambar memperbarui pratinjau.",
|
||||
"state": "Status pratinjau berkas"
|
||||
},
|
||||
"webPreview": {
|
||||
"title": "WebPreviewPanelView · Konten web",
|
||||
"description": "Jelajahi bilah judul, keterangan isolasi, dan pembatasan; segarkan dokumen lokal.",
|
||||
"options": "Runtime menentukan restriction sebelum menyediakan konten. children menyediakan konten; onRefresh meminta penyegaran. iframe ini memakai srcDoc lokal.",
|
||||
"state": "Status pratinjau web",
|
||||
"frame": "Halaman web contoh lokal",
|
||||
"refreshes": "Penyegaran: {{amount}}"
|
||||
},
|
||||
"session": {
|
||||
"title": "SessionInfoPopoverView · Otomatisasi sesi",
|
||||
"description": "Lihat, edit, nonaktifkan, dan hapus tugas dengan status pemuatan dan kesalahan.",
|
||||
|
||||
@@ -61,16 +61,6 @@
|
||||
"scope": "ファイルの範囲",
|
||||
"hint": "右クリックでコピーメニューを開くか、ファイルにフォーカスして Shift+F10 を押してください。"
|
||||
},
|
||||
"webLinks": {
|
||||
"title": "Web links · リンクメニュー",
|
||||
"description": "実際のリンクメニューでメッセージのリンクを選び、アドレスをコピーできます。",
|
||||
"options": "WebLink はリンク属性を受け取ります。useMessageWebLinks は表示済みのリンクを収集します。MessageLinksMenu は項目と戻る・閉じるコールバックを受け取り、expanded が幅を制御します。リンク先はすべてローカルのギャラリー素材です。",
|
||||
"width": "リンクメニューの幅",
|
||||
"message": "<gallery>コンポーネントギャラリー</gallery>と<brand>ブランド画像</brand>を表示します。",
|
||||
"close": "リンクメニューを閉じる",
|
||||
"open": "メッセージのリンクを見る",
|
||||
"hint": "リンクを右クリックするとアドレスをコピーできます。メニューは表示済みメッセージからリンクを収集します。"
|
||||
},
|
||||
"workbench": {
|
||||
"title": "PaneWorkbench · 複数ペイン",
|
||||
"description": "レイアウトの切り替え、ペインの選択・追加、移動やサイズ変更を試せます。",
|
||||
@@ -235,14 +225,6 @@
|
||||
"options": "state は表示状態を提供し、path はファイルの種類と名前を決定します。画像の表示・エラーコールバックがプレビューを更新します。",
|
||||
"state": "ファイルプレビューの状態"
|
||||
},
|
||||
"webPreview": {
|
||||
"title": "WebPreviewPanelView · ウェブ内容",
|
||||
"description": "タイトルバー、隔離の説明、各種制限を確認し、ローカル文書を更新できます。",
|
||||
"options": "ランタイムが restriction を決めてから内容を渡します。children が内容を提供し、onRefresh が更新を要求します。この iframe はローカルの srcDoc を使います。",
|
||||
"state": "ウェブプレビューの状態",
|
||||
"frame": "ローカルのサンプルページ",
|
||||
"refreshes": "更新回数:{{amount}}"
|
||||
},
|
||||
"session": {
|
||||
"title": "SessionInfoPopoverView · セッションの自動化",
|
||||
"description": "タスクの表示、編集、無効化、削除と読み込み・エラー状態を試せます。",
|
||||
|
||||
@@ -61,16 +61,6 @@
|
||||
"scope": "파일 범위",
|
||||
"hint": "오른쪽 클릭으로 복사 메뉴를 열거나 파일에 초점을 두고 Shift+F10을 누르세요."
|
||||
},
|
||||
"webLinks": {
|
||||
"title": "Web links · 링크 메뉴",
|
||||
"description": "실제 링크 메뉴에서 메시지의 링크를 선택하고 주소를 복사합니다.",
|
||||
"options": "WebLink는 링크 속성을 받습니다. useMessageWebLinks는 렌더링된 링크를 수집합니다. MessageLinksMenu는 항목과 뒤로 가기·닫기 콜백을 받고 expanded로 너비를 정합니다. 예제 링크는 모두 로컬 갤러리 리소스로 연결됩니다.",
|
||||
"width": "링크 메뉴 너비",
|
||||
"message": "<gallery>컴포넌트 갤러리</gallery>와 <brand>브랜드 이미지</brand>를 확인하세요.",
|
||||
"close": "링크 메뉴 닫기",
|
||||
"open": "메시지 링크 보기",
|
||||
"hint": "링크를 오른쪽 클릭하면 주소를 복사할 수 있습니다. 메시지 메뉴는 실제 표시된 링크를 수집합니다."
|
||||
},
|
||||
"workbench": {
|
||||
"title": "PaneWorkbench · 여러 창",
|
||||
"description": "레이아웃을 바꾸고 창을 선택하거나 추가하며 위치와 크기를 조절합니다.",
|
||||
@@ -235,14 +225,6 @@
|
||||
"options": "state가 표시 스냅샷을 제공하고 path가 파일 형식과 이름을 정합니다. 이미지 열기와 오류 콜백이 미리보기를 갱신합니다.",
|
||||
"state": "파일 미리보기 상태"
|
||||
},
|
||||
"webPreview": {
|
||||
"title": "WebPreviewPanelView · 웹 콘텐츠",
|
||||
"description": "웹 제목 표시줄, 격리 안내, 제한을 확인하고 로컬 문서를 새로 고칩니다.",
|
||||
"options": "런타임이 restriction을 정한 후 내용을 전달합니다. children이 내용을 제공하고 onRefresh가 새로고침을 요청합니다. 이 iframe은 로컬 srcDoc을 사용합니다.",
|
||||
"state": "웹 미리보기 상태",
|
||||
"frame": "로컬 예제 웹페이지",
|
||||
"refreshes": "새로고침 횟수: {{amount}}"
|
||||
},
|
||||
"session": {
|
||||
"title": "SessionInfoPopoverView · 세션 자동화",
|
||||
"description": "작업 조회, 편집, 비활성화, 삭제와 로딩·오류 상태를 시험합니다.",
|
||||
|
||||
@@ -61,16 +61,6 @@
|
||||
"scope": "Escopo do arquivo",
|
||||
"hint": "Clique com o botão direito para abrir o menu de cópia, ou foque o arquivo e pressione Shift+F10."
|
||||
},
|
||||
"webLinks": {
|
||||
"title": "Web links · Menu de links",
|
||||
"description": "Abra o menu real de links para selecionar links da mensagem e copiar endereços.",
|
||||
"options": "WebLink recebe atributos de link. useMessageWebLinks coleta os links renderizados. MessageLinksMenu recebe entradas e callbacks de voltar e fechar; expanded controla a largura. Todos os links apontam para recursos locais da galeria.",
|
||||
"width": "Largura do menu de links",
|
||||
"message": "Veja a <gallery>galeria de componentes</gallery> e a <brand>imagem de marca</brand>.",
|
||||
"close": "Fechar menu de links",
|
||||
"open": "Ver links da mensagem",
|
||||
"hint": "Clique com o botão direito em um link para copiar o endereço. O menu coleta os links da mensagem renderizada."
|
||||
},
|
||||
"workbench": {
|
||||
"title": "PaneWorkbench · Múltiplos painéis",
|
||||
"description": "Mude o layout, ative ou adicione painéis e ajuste a posição e o tamanho.",
|
||||
@@ -235,14 +225,6 @@
|
||||
"options": "state fornece o estado visual; path determina o tipo e o nome do arquivo. Os callbacks de abertura e erro de imagem atualizam a prévia.",
|
||||
"state": "Estado da prévia do arquivo"
|
||||
},
|
||||
"webPreview": {
|
||||
"title": "WebPreviewPanelView · Conteúdo web",
|
||||
"description": "Explore a barra de título, o isolamento e as restrições; atualize um documento local.",
|
||||
"options": "O runtime escolhe restriction antes de fornecer o conteúdo. children fornece o conteúdo; onRefresh solicita a atualização. Este iframe usa um srcDoc local.",
|
||||
"state": "Estado da prévia web",
|
||||
"frame": "Página web local de exemplo",
|
||||
"refreshes": "Atualizações: {{amount}}"
|
||||
},
|
||||
"session": {
|
||||
"title": "SessionInfoPopoverView · Automações da sessão",
|
||||
"description": "Veja, edite, desative e exclua tarefas com estados de carregamento e erro.",
|
||||
|
||||
@@ -61,16 +61,6 @@
|
||||
"scope": "Phạm vi tệp",
|
||||
"hint": "Nhấp chuột phải để mở menu sao chép, hoặc đưa tiêu điểm vào tệp rồi nhấn Shift+F10."
|
||||
},
|
||||
"webLinks": {
|
||||
"title": "Web links · Menu liên kết",
|
||||
"description": "Mở menu liên kết thực để chọn liên kết trong tin nhắn và sao chép địa chỉ.",
|
||||
"options": "WebLink nhận thuộc tính liên kết. useMessageWebLinks thu thập liên kết đã hiển thị. MessageLinksMenu nhận các mục và hàm gọi lại để quay lại, đóng; expanded điều khiển chiều rộng. Mọi liên kết đều trỏ đến tài nguyên thư viện cục bộ.",
|
||||
"width": "Chiều rộng menu liên kết",
|
||||
"message": "Xem <gallery>thư viện thành phần</gallery> và <brand>ảnh thương hiệu</brand>.",
|
||||
"close": "Đóng menu liên kết",
|
||||
"open": "Xem liên kết trong tin nhắn",
|
||||
"hint": "Nhấp chuột phải vào liên kết để sao chép địa chỉ. Menu thu thập liên kết từ tin nhắn đã hiển thị."
|
||||
},
|
||||
"workbench": {
|
||||
"title": "PaneWorkbench · Nhiều ngăn",
|
||||
"description": "Đổi bố cục, kích hoạt hoặc thêm ngăn, điều chỉnh vị trí và kích thước.",
|
||||
@@ -235,14 +225,6 @@
|
||||
"options": "state cung cấp trạng thái hiển thị; path xác định loại và tên tệp. Hàm gọi lại mở ảnh và lỗi ảnh cập nhật bản xem trước.",
|
||||
"state": "Trạng thái xem trước tệp"
|
||||
},
|
||||
"webPreview": {
|
||||
"title": "WebPreviewPanelView · Nội dung web",
|
||||
"description": "Khám phá thanh tiêu đề, thông tin cách ly và giới hạn; làm mới tài liệu cục bộ.",
|
||||
"options": "Runtime chọn restriction trước khi cung cấp nội dung. children cung cấp nội dung; onRefresh yêu cầu làm mới. iframe này dùng srcDoc cục bộ.",
|
||||
"state": "Trạng thái xem trước web",
|
||||
"frame": "Trang web ví dụ cục bộ",
|
||||
"refreshes": "Số lần làm mới: {{amount}}"
|
||||
},
|
||||
"session": {
|
||||
"title": "SessionInfoPopoverView · Tác vụ tự động của phiên",
|
||||
"description": "Xem, sửa, tắt và xóa tác vụ với trạng thái đang tải và lỗi.",
|
||||
|
||||
@@ -61,16 +61,6 @@
|
||||
"scope": "文件范围",
|
||||
"hint": "右键打开复制菜单,也可聚焦文件后按 Shift+F10。"
|
||||
},
|
||||
"webLinks": {
|
||||
"title": "Web links · 链接菜单",
|
||||
"description": "选择消息链接并复制地址。",
|
||||
"options": "WebLink 接收链接属性;useMessageWebLinks 收集实际渲染的消息链接。MessageLinksMenu 接收条目、返回与关闭回调,expanded 控制宽度。示例链接均指向本地画廊资源。",
|
||||
"width": "链接菜单宽度",
|
||||
"message": "查看<gallery>组件画廊</gallery>和<brand>品牌图片</brand>。",
|
||||
"close": "关闭链接菜单",
|
||||
"open": "查看消息链接",
|
||||
"hint": "右键链接可复制地址;消息菜单从实际渲染的链接中收集条目。"
|
||||
},
|
||||
"workbench": {
|
||||
"title": "PaneWorkbench · 多窗格",
|
||||
"description": "切换布局、激活或添加窗格并调整尺寸。",
|
||||
@@ -235,14 +225,6 @@
|
||||
"options": "state 为显示快照;path 决定文件类型和名称;图片打开与失败回调更新当前预览。",
|
||||
"state": "文件预览状态"
|
||||
},
|
||||
"webPreview": {
|
||||
"title": "WebPreviewPanelView · 网页内容",
|
||||
"description": "查看隔离与限制提示,试用刷新本地文档。",
|
||||
"options": "运行时先决定 restriction,再提供内容。children 接收内容,onRefresh 请求刷新;此示例的 iframe 使用本地 srcDoc。",
|
||||
"state": "网页预览状态",
|
||||
"frame": "本地示例网页",
|
||||
"refreshes": "刷新次数:{{amount}}"
|
||||
},
|
||||
"session": {
|
||||
"title": "SessionInfoPopoverView · 会话任务",
|
||||
"description": "查看、编辑、停用和删除会话任务。",
|
||||
|
||||
@@ -61,16 +61,6 @@
|
||||
"scope": "檔案範圍",
|
||||
"hint": "按右鍵開啟複製選單,或聚焦檔案後按 Shift+F10。"
|
||||
},
|
||||
"webLinks": {
|
||||
"title": "Web links · 連結選單",
|
||||
"description": "選擇訊息連結並複製網址。",
|
||||
"options": "WebLink 接收連結屬性;useMessageWebLinks 收集實際呈現的訊息連結。MessageLinksMenu 接收項目、返回與關閉回呼,expanded 控制寬度。範例連結皆指向本機元件庫資源。",
|
||||
"width": "連結選單寬度",
|
||||
"message": "查看<gallery>元件庫</gallery>與<brand>品牌圖片</brand>。",
|
||||
"close": "關閉連結選單",
|
||||
"open": "查看訊息連結",
|
||||
"hint": "在連結上按右鍵可複製網址;訊息選單從實際呈現的連結收集項目。"
|
||||
},
|
||||
"workbench": {
|
||||
"title": "PaneWorkbench · 多窗格",
|
||||
"description": "切換版面、啟用或新增窗格並調整尺寸。",
|
||||
@@ -235,14 +225,6 @@
|
||||
"options": "state 為顯示快照;path 決定檔案類型與名稱;圖片開啟與失敗回呼更新目前預覽。",
|
||||
"state": "檔案預覽狀態"
|
||||
},
|
||||
"webPreview": {
|
||||
"title": "WebPreviewPanelView · 網頁內容",
|
||||
"description": "查看隔離與限制提示,試用重新整理。",
|
||||
"options": "執行階段先決定 restriction,再提供內容。children 接收內容,onRefresh 請求重新整理;此範例的 iframe 使用本機 srcDoc。",
|
||||
"state": "網頁預覽狀態",
|
||||
"frame": "本機範例網頁",
|
||||
"refreshes": "重新整理次數:{{amount}}"
|
||||
},
|
||||
"session": {
|
||||
"title": "SessionInfoPopoverView · 對話任務",
|
||||
"description": "查看、編輯、停用與刪除對話任務。",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useRef, useState, type ReactNode } from "react";
|
||||
import { useState, type ReactNode } from "react";
|
||||
import { createPortal } from "react-dom";
|
||||
import { Trans, useTranslation } from "react-i18next";
|
||||
|
||||
@@ -7,13 +7,11 @@ import type { CapabilityMentionSegment } from "@/lib/composer-mention-text";
|
||||
import { DeleteConfirm } from "@/components/DeleteConfirm";
|
||||
import { FileActions } from "@/components/FileActions";
|
||||
import { InlineTokenHighlight, INLINE_TOKEN_HIGHLIGHT_COLOR } from "@/components/InlineTokenHighlight";
|
||||
import { MessageLinksMenu, useMessageWebLinks } from "@/components/MessageLinksMenu";
|
||||
import { RenameDialog } from "@/components/RenameDialog";
|
||||
import { SessionHandleLabel } from "@/components/SessionHandleLabel";
|
||||
import { SlashCommandText } from "@/components/SlashCommandText";
|
||||
import { StartupShell } from "@/components/StartupShell";
|
||||
import { UserMessageText } from "@/components/UserMessageText";
|
||||
import { WebLink } from "@/components/WebLink";
|
||||
import * as ProductIcons from "@/components/icons/product-icons";
|
||||
import { HostCompatibilityDialog } from "@/components/remote/HostCompatibilityDialog";
|
||||
import { HostConnectionStatus } from "@/components/remote/HostConnectionStatus";
|
||||
@@ -174,28 +172,6 @@ function FileActionsPreview() {
|
||||
</>;
|
||||
}
|
||||
|
||||
function WebLinksPreview() {
|
||||
const { t } = useGalleryTranslation();
|
||||
const [open, setOpen] = useState(false);
|
||||
const [display, setDisplay] = useState<"compact" | "expanded">("compact");
|
||||
const message = useRef<HTMLDivElement>(null);
|
||||
const links = useMessageWebLinks(message, open);
|
||||
return <div className="space-y-4">
|
||||
<StatePicker label={t("previews.webLinks.width")} value={display} options={["compact", "expanded"]} onChange={setDisplay} />
|
||||
<div ref={message} className="text-sm leading-7"><p data-assistant-selectable>
|
||||
<Trans t={t} i18nKey="previews.webLinks.message" components={{
|
||||
gallery: <WebLink href={`${window.location.origin}/gallery.html`} className="underline underline-offset-4" />,
|
||||
brand: <WebLink href={`${window.location.origin}/brand/nanobot_icon_512.png`} className="underline underline-offset-4" />,
|
||||
}} />
|
||||
</p></div>
|
||||
<Button variant="outline" onClick={() => setOpen((value) => !value)}>{t(open ? "previews.webLinks.close" : "previews.webLinks.open")}</Button>
|
||||
{open && links.length > 0 ? <div className="rounded-control border p-1">
|
||||
<MessageLinksMenu links={links} onBack={() => setOpen(false)} onClose={() => setOpen(false)} expanded={display === "expanded"} />
|
||||
</div> : null}
|
||||
<p className="text-xs text-muted-foreground">{t("previews.webLinks.hint")}</p>
|
||||
</div>;
|
||||
}
|
||||
|
||||
const initialPanes: WorkbenchPane[] = [
|
||||
{ key: "pane-1", title: "组件设计" }, { key: "pane-2", title: "实现" }, { key: "pane-3", title: "验证" },
|
||||
];
|
||||
@@ -289,9 +265,6 @@ export const shellExamples: ComponentExample[] = [
|
||||
{ title: "previews.fileActions.title", files: ["FileActions"], Preview: FileActionsPreview,
|
||||
description: "previews.fileActions.description", options: "previews.fileActions.options",
|
||||
code: '<FileActions path="src/app.tsx" metadata={{ path: "D:/workspace/src/app.tsx", relative_path: "src/app.tsx" }}><Button>app.tsx</Button></FileActions>' },
|
||||
{ title: "previews.webLinks.title", files: ["WebLink", "MessageLinksMenu"], Preview: WebLinksPreview,
|
||||
description: "previews.webLinks.description", options: "previews.webLinks.options",
|
||||
code: '<WebLink href={url}>组件画廊</WebLink>\nconst links = useMessageWebLinks(messageRef, open);\n<MessageLinksMenu links={links} onBack={close} onClose={close} expanded />' },
|
||||
{ title: "previews.workbench.title", files: ["workbench/PaneWorkbench"], Preview: WorkbenchPreview,
|
||||
description: "previews.workbench.description", options: "previews.workbench.options",
|
||||
code: '<PaneWorkbench panes={panes} activePaneKey={active} layout={layout} showLayoutControl onActivatePane={setActive} onAddPane={addPane} onLayoutChange={setLayout} onPaneOrderChange={reorder} renderPane={renderPane} />' },
|
||||
|
||||
Reference in new issue
Block a user