From 7921edd71ec2e52194a396aa22b53a3e3fe3efe1 Mon Sep 17 00:00:00 2001
From: Gmaker689 <1711322114@qq.com>
Date: Mon, 25 May 2026 20:15:06 +0800
Subject: [PATCH 1/3] =?UTF-8?q?fix:=20=E4=BB=BB=E5=8A=A1=E8=AF=A6=E6=83=85?=
=?UTF-8?q?=E9=A1=B5=20JWT=20=E9=89=B4=E6=9D=83=E5=A4=B1=E8=B4=A5=E5=AF=BC?=
=?UTF-8?q?=E8=87=B4=E5=9B=9E=E9=80=80=E7=99=BB=E5=BD=95=E9=A1=B5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- TaskListPanel 用 React Router 替代原生 ,避免整页刷新
- auth store 初始化时同步读取 token 设置 isAuthenticated,避免 useEffect 异步执行前 ProtectedRoute 误判未登录
---
frontend/src/components/TaskListPanel.tsx | 12 ++++++++----
frontend/src/stores/auth.ts | 2 +-
2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/frontend/src/components/TaskListPanel.tsx b/frontend/src/components/TaskListPanel.tsx
index 61f55f4..ad0d90a 100644
--- a/frontend/src/components/TaskListPanel.tsx
+++ b/frontend/src/components/TaskListPanel.tsx
@@ -1,5 +1,5 @@
import { useEffect, useState, useCallback } from 'react'
-import { useParams } from 'react-router-dom'
+import { Link, useParams } from 'react-router-dom'
import { getTasks } from '../api/project'
import type { Task } from '../api/types'
import StatusBadge from './StatusBadge'
@@ -67,9 +67,9 @@ export default function TaskListPanel() {
) : (
tasks.map(task => (
- {
+ if (task.status !== 'completed') e.preventDefault()
+ }}
onMouseEnter={e => {
if (task.status === 'completed')
(e.currentTarget as HTMLElement).style.background = 'var(--accent-dim)'
@@ -115,7 +119,7 @@ export default function TaskListPanel() {
)}
-
+
))
)}
diff --git a/frontend/src/stores/auth.ts b/frontend/src/stores/auth.ts
index 6a34804..7a9fb92 100755
--- a/frontend/src/stores/auth.ts
+++ b/frontend/src/stores/auth.ts
@@ -22,7 +22,7 @@ interface AuthState {
export const useAuthStore = create((set) => ({
user: null,
- isAuthenticated: false,
+ isAuthenticated: getToken() !== null,
loading: false,
error: null,
From acef46063c3eedddcaccde67b9572704548945d9 Mon Sep 17 00:00:00 2001
From: Gmaker689 <1711322114@qq.com>
Date: Mon, 25 May 2026 20:19:09 +0800
Subject: [PATCH 2/3] =?UTF-8?q?fix:=20=E4=BB=BB=E5=8A=A1=E4=BE=A7=E8=BE=B9?=
=?UTF-8?q?=E6=A0=8F=E7=82=B9=E5=87=BB=E8=AF=A6=E6=83=85=E5=90=8E"?=
=?UTF-8?q?=E4=BB=BB=E5=8A=A1=E4=B8=8D=E5=AD=98=E5=9C=A8"=E9=97=AE?=
=?UTF-8?q?=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
GetTasks 返回的 TaskResponse.ID 使用了数据库自增 ID (t.ID) 而非 ExternalID,
导致前端用错误 ID 调用 GetTask 接口时 external_id 查询不到记录。
改为返回 t.ExternalID 与实际查询字段一致。
---
backend/internal/service/project.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/backend/internal/service/project.go b/backend/internal/service/project.go
index 14138f3..30fde5a 100644
--- a/backend/internal/service/project.go
+++ b/backend/internal/service/project.go
@@ -198,7 +198,7 @@ func (s *ProjectService) GetTasks(ctx context.Context, userID uint, projectID ui
response := make([]model.TaskResponse, len(tasks))
for i, t := range tasks {
response[i] = model.TaskResponse{
- ID: fmt.Sprintf("%d", t.ID),
+ ID: t.ExternalID,
ProjectID: fmt.Sprintf("%d", t.ProjectID),
Prompt: t.Prompt,
AssetType: t.AssetType,
From 8372e299c17d9b098f57d299d4b3da87ded0ddbd Mon Sep 17 00:00:00 2001
From: wonder
Date: Mon, 25 May 2026 20:26:31 +0800
Subject: [PATCH 3/3] =?UTF-8?q?fix:=20=E8=BE=93=E5=87=BA=E6=A0=BC=E5=BC=8F?=
=?UTF-8?q?=E6=A0=B9=E6=8D=AE=E7=B4=A0=E6=9D=90=E7=B1=BB=E5=9E=8B=E8=87=AA?=
=?UTF-8?q?=E5=8A=A8=E8=AE=BE=E7=BD=AE=E9=BB=98=E8=AE=A4=E5=80=BC?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
精灵/动画默认精灵表,背景/UI默认单帧,用户仍可手动切换。
---
frontend/src/stores/task.ts | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/frontend/src/stores/task.ts b/frontend/src/stores/task.ts
index a156691..244a7a2 100755
--- a/frontend/src/stores/task.ts
+++ b/frontend/src/stores/task.ts
@@ -28,6 +28,13 @@ interface TaskState {
reset: () => void
}
+const DEFAULT_FORMAT: Record = {
+ sprite: 'spritesheet',
+ background: 'individual',
+ ui: 'individual',
+ animation: 'spritesheet',
+}
+
const DEFAULT_PARAMS: TaskParams = {
resolution: 1024,
format: 'spritesheet',
@@ -44,7 +51,12 @@ export const useTaskStore = create((set, get) => ({
setPrompt: (text) => set({ prompt: text, optimizedPrompt: null }),
- setAssetType: (type) => set({ assetType: type, optimizedPrompt: null }),
+ setAssetType: (type) =>
+ set({
+ assetType: type,
+ params: { ...get().params, format: DEFAULT_FORMAT[type] },
+ optimizedPrompt: null,
+ }),
toggleTaskStyle: (key, value) =>
set(state => {