lv 2 weeks ago
parent
commit
f6d07b9fc3
1 changed files with 7 additions and 2 deletions
  1. 7 2
      src/App.tsx

+ 7 - 2
src/App.tsx

@@ -1,4 +1,4 @@
-import { useCallback, useEffect, useMemo, useRef, useState } from "react";
+import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
 import { invoke } from "@tauri-apps/api/core";
 import { listen, type UnlistenFn } from "@tauri-apps/api/event";
 import { getCurrentWindow } from "@tauri-apps/api/window";
@@ -125,6 +125,11 @@ function App() {
   const [activeId, setActiveId] = useState<string | null>(null);
   const activeIdRef = useRef(activeId);
   activeIdRef.current = activeId;
+  const activeTaskRef = useRef<Task | undefined>(undefined);
+
+  useLayoutEffect(() => {
+    activeTaskRef.current = activeId ? tasks.find(({ id }) => id == activeId) : undefined;
+  }, [activeId]);
 
   // 待处理任务(status=0)的真实列表,来自 sqlite
   const [tasks, setTasks] = useState<Task[]>([]);
@@ -954,7 +959,7 @@ function App() {
           <div className="w-full h-6 flex items-center px-2 text-gray-3">
 
             <div className="flex-1">任务:{activeId} {isWorking && <LoadingOutlined />}</div>
-            <div className="flex-1 overflow-hidden">{assets?.site_url}</div>
+            <div className="flex-1 overflow-hidden">{assets?.site_url || activeTaskRef.current?.url}</div>
             <div className="flex-1 overflow-hidden">{assets?.tags}</div>
             <div className="flex-1 text-right">{statusText}</div>
             <div className="bg-gray-6 rounded-full w-3 h-3 m-2" style={{ backgroundColor: statusColor }} />