feat(web): 前端 SPA 化 + 工具页任务面板统一与历史批量删除
- SPA 化:22 个 MPA html 入口与 *-main.ts 合并为 index.html + vue-router(URL 无 .html 后缀), 页面跳转全部 router-link,/new_web_source/xxx.html 旧路径归一为 /xxx - 任务面板统一:共享 TaskCenterPanel/TaskItemCard/TaskStatCards/HistoryTaskLayer, 16 个工具页右侧统一为统计卡 + 当前任务 + 历史任务弹层(任务ID/开始/结束/状态必展示) - 历史记录支持单条删除 + 批量勾选删除(确认框/全选/失败提示) - Java 7 模块(dedupe/convert/split/productrisk/shopmatch/pricetrack/deletebrand) history 接口补齐任务时间字段(VO+Service,复用 biz_file_task 列) - 图片工作台/API 层(brand/permission/user)既有未提交改动一并提交
This commit is contained in:
@@ -53,7 +53,10 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { resolvePageHref } from '@/shared/page-prefix'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { loginWithDevice } from '@/shared/api/user'
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
const AUTH_TOKEN_KEY = 'aiimage_auth_token'
|
||||
const DEVICE_ID_KEY = 'aiimage_device_id'
|
||||
@@ -68,10 +71,6 @@ function togglePassword() {
|
||||
passwordVisible.value = !passwordVisible.value
|
||||
}
|
||||
|
||||
function isDesktopClient() {
|
||||
return Boolean(window.pywebview?.api) || window.location.pathname === '/login'
|
||||
}
|
||||
|
||||
function clearAppPermissionCaches() {
|
||||
try {
|
||||
const keys: string[] = []
|
||||
@@ -137,17 +136,8 @@ async function submitLogin() {
|
||||
errorMessage.value = '未获取到设备ID,请在桌面端打开'
|
||||
return
|
||||
}
|
||||
const loginResp = await window.fetch('/newApi/login', {
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-Device-Id': deviceId,
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
},
|
||||
body: JSON.stringify({ username: account, password: password.value, deviceId }),
|
||||
})
|
||||
const loginBody = await loginResp.json().catch(() => ({}))
|
||||
// 经 shared/api/user 层登录(页面不得直连 /newApi,见 shared-api-allowlist 测试约定)
|
||||
const loginBody = await loginWithDevice(account, password.value, deviceId)
|
||||
if (!loginBody || loginBody.success !== true || !loginBody.data) {
|
||||
errorMessage.value = (loginBody && (loginBody.message || loginBody.msg)) || '登录失败'
|
||||
return
|
||||
@@ -174,20 +164,10 @@ async function submitLogin() {
|
||||
/* 忽略 */
|
||||
}
|
||||
}
|
||||
// 把 Java 签发的 JWT 同步到 Python 同源 cookie,供后续页面跳转携带
|
||||
try {
|
||||
await window.fetch('/api/auth/sync', {
|
||||
method: 'POST',
|
||||
credentials: 'same-origin',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ token: data.token }),
|
||||
})
|
||||
} catch {
|
||||
/* cookie 同步失败不阻塞跳转(页面仍可读 localStorage) */
|
||||
}
|
||||
// 桌面端 Flask cookie 同步已随瘦身下线:登录态只存 localStorage(JWT 走 Bearer),无 cookie 依赖
|
||||
clearAppPermissionCaches()
|
||||
// 桌面端走 Flask /home;Web 独立部署(路径含 /new_web_source)与 dev 走 resolvePageHref 归一
|
||||
window.location.href = isDesktopClient() ? '/home' : resolvePageHref('/new_web_source/home.html')
|
||||
// SPA:登录成功后经路由回首页(URL 无 .html 后缀,见 src/router)
|
||||
await router.replace('/home')
|
||||
} catch {
|
||||
errorMessage.value = '网络异常,请稍后重试'
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user