Procházet zdrojové kódy

feat: always show manual query board

SamLee před 2 týdny
rodič
revize
bf7f73fbaf

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 0 - 0
app/frontend/dist/assets/index-BZxaJqWu.js


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 0 - 0
app/frontend/dist/assets/index-C9UG2pZh.css


+ 2 - 2
app/frontend/dist/index.html

@@ -4,8 +4,8 @@
     <meta charset="UTF-8" />
     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
     <title>创作知识</title>
-    <script type="module" crossorigin src="/app/assets/index-7M9nmW_J.js"></script>
-    <link rel="stylesheet" crossorigin href="/app/assets/index-Dox3rE61.css">
+    <script type="module" crossorigin src="/app/assets/index-BZxaJqWu.js"></script>
+    <link rel="stylesheet" crossorigin href="/app/assets/index-C9UG2pZh.css">
   </head>
   <body>
     <div id="root"></div>

+ 14 - 6
app/frontend/src/features/query-board/QueryBoardPage.jsx

@@ -25,13 +25,13 @@ function selectedQueryPayload(queryText, latest) {
 
 function manualFamilyFromBoard(board) {
   const rows = (board?.queries || []).filter((row) => row.family_key === 'manual')
-  if (!rows.length) return null
   return {
     key: 'manual',
-    axes: ['手动 Query'],
+    label: '手动 Query',
+    axes: [],
     items: rows.map((row, index) => ({
       query: row.query_text,
-      parts: { '手动 Query': '手动 Query' },
+      parts: {},
       keep: true,
       reason: row.filter_reason || '',
       sort_order: row.sort_order ?? index,
@@ -57,7 +57,7 @@ export default function QueryBoardPage() {
   const families = useMemo(() => {
     const base = preview?.families || []
     const manual = manualFamilyFromBoard(board)
-    return manual ? [...base, manual] : base
+    return [...base, manual]
   }, [board, preview])
   const family = families.find((row) => row.key === activeKey) || families[0] || { axes: [], items: [] }
   const familyItems = family.items || []
@@ -79,7 +79,10 @@ export default function QueryBoardPage() {
   }, [families, activeKey])
 
   useEffect(() => {
-    if (!familyItems.length) return
+    if (!familyItems.length) {
+      if (selectedQuery) setSelectedQuery(null)
+      return
+    }
     if (selectedQuery && familyItems.some((item) => item.query === selectedQuery.query)) {
       const latest = latestByQuery.get(selectedQuery.query)
       const next = selectedQueryPayload(selectedQuery.query, latest)
@@ -111,7 +114,7 @@ export default function QueryBoardPage() {
               type="button"
               onClick={() => setActiveKey(row.key)}
             >
-              <span className="fbtn-pre">{row.axes?.[0] || row.key}</span>
+              <span className="fbtn-pre">{row.label || row.axes?.[0] || row.key}</span>
               <span className="fbtn-suf">{(row.axes || []).slice(1).join(' × ')}</span>
             </button>
           ))}
@@ -144,6 +147,11 @@ export default function QueryBoardPage() {
           familyRunCount={familyRunCount}
           totalRunCount={totalRunCount}
           totalItemCount={totalItemCount}
+          emptyMessage={
+            family.key === 'manual'
+              ? '暂无手动 Query,点击右上角手动输入或上传 JSON 创建。'
+              : undefined
+          }
         />
         <SearchResultColumn
           selected={selectedQuery}

+ 28 - 23
app/frontend/src/features/query-board/QueryColumn.jsx

@@ -51,6 +51,7 @@ export default function QueryColumn({
   familyRunCount,
   totalRunCount,
   totalItemCount,
+  emptyMessage,
 }) {
   const height = useListHeight()
   const itemData = useMemo(() => ({
@@ -72,29 +73,33 @@ export default function QueryColumn({
           <span className="gn">{familyRunCount}/{familyItems.length}</span>
         </span>
       </div>
-      <FixedSizeList
-        className="axlist virtual-query-list"
-        height={height}
-        itemCount={familyItems.length}
-        itemData={itemData}
-        itemKey={(index, data) => `${data.familyItems[index]?.query}-${index}`}
-        itemSize={32}
-        width="100%"
-      >
-        {({ index, style, data }) => {
-          const item = data.familyItems[index]
-          const latest = data.latestByQuery.get(item.query)
-          return (
-            <QueryRow
-              item={item}
-              latest={latest}
-              selected={data.selectedQuery?.query_id === latest?.query_id}
-              onSelect={data.onSelect}
-              style={style}
-            />
-          )
-        }}
-      </FixedSizeList>
+      {familyItems.length ? (
+        <FixedSizeList
+          className="axlist virtual-query-list"
+          height={height}
+          itemCount={familyItems.length}
+          itemData={itemData}
+          itemKey={(index, data) => `${data.familyItems[index]?.query}-${index}`}
+          itemSize={32}
+          width="100%"
+        >
+          {({ index, style, data }) => {
+            const item = data.familyItems[index]
+            const latest = data.latestByQuery.get(item.query)
+            return (
+              <QueryRow
+                item={item}
+                latest={latest}
+                selected={data.selectedQuery?.query_id === latest?.query_id}
+                onSelect={data.onSelect}
+                style={style}
+              />
+            )
+          }}
+        </FixedSizeList>
+      ) : (
+        <div className="query-column-empty">{emptyMessage || '暂无 Query'}</div>
+      )}
     </div>
   )
 }

+ 2 - 2
app/frontend/src/features/query-board/SearchResultColumn.jsx

@@ -1,12 +1,12 @@
 import { flatDetailItems, isFinalKnowledge, itemBrief, itemMediaUrl } from './model.js'
 
 export default function SearchResultColumn({ selected, detail, loading, error, onKnowledgeClick }) {
-  const items = [...flatDetailItems(detail)].sort((a, b) => {
+  const items = selected ? [...flatDetailItems(detail)].sort((a, b) => {
     const ak = isFinalKnowledge(a) ? 0 : 1
     const bk = isFinalKnowledge(b) ? 0 : 1
     if (ak !== bk) return ak - bk
     return (a.platform || '').localeCompare(b.platform || '') || (a.title || '').localeCompare(b.title || '')
-  })
+  }) : []
   return (
     <div className="axcol qresult-col">
       <div className="axhd qresult-hd">

+ 8 - 1
app/frontend/src/styles/query-board.css

@@ -29,7 +29,7 @@
 }
 
 .dashboard-page .cdemo.manual-cdemo {
-  grid-template-columns: 180px minmax(420px, 560px) minmax(520px, 1fr);
+  grid-template-columns: minmax(420px, 560px) minmax(520px, 1fr);
 }
 
 .manual-modal-mask {
@@ -229,3 +229,10 @@
   text-overflow: ellipsis;
   white-space: nowrap;
 }
+
+.query-column-empty {
+  padding: 18px 16px;
+  color: #86909c;
+  font-size: 13px;
+  line-height: 1.6;
+}

Některé soubory nejsou zobrazeny, neboť je v těchto rozdílových datech změněno mnoho souborů