fix
Some checks failed
Deploy / deploy (push) Has been cancelled

This commit is contained in:
2025-10-12 14:09:15 +08:00
parent 6ee8fe02ba
commit a08f4a1935
4 changed files with 104 additions and 63 deletions

View File

@@ -20,8 +20,21 @@ interface Testcase {
const message = useMessage()
const configStore = useConfigStore()
const userStore = useUserStore()
const { updateConfig } = useConfigWebSocket()
// 确保只有登录用户才能使用WebSocket
watch(
() => userStore.isAuthed,
(isAuthed) => {
if (!isAuthed) {
// 如果用户未登录禁用WebSocket功能
console.warn('用户未登录WebSocket配置更新功能已禁用')
}
},
{ immediate: true }
)
const testcaseColumns: DataTableColumn<Testcase>[] = [
{ title: "测试用例 ID", key: "id" },
{

View File

@@ -1,4 +1,5 @@
import { useConfigStore } from "shared/store/config"
import { useUserStore } from "shared/store/user"
import {
useConfigWebSocket,
type ConfigUpdate,
@@ -6,6 +7,7 @@ import {
export function useConfigUpdate() {
const configStore = useConfigStore()
const userStore = useUserStore()
// 处理 WebSocket 配置更新
const handleConfigUpdate = (data: ConfigUpdate) => {
@@ -17,12 +19,23 @@ export function useConfigUpdate() {
}
// 初始化 WebSocket - handler 会在 onMounted 时自动添加
const { connect } = useConfigWebSocket(handleConfigUpdate)
const { connect, disconnect } = useConfigWebSocket(handleConfigUpdate)
// 监听登录状态变化
watch(
() => userStore.isAuthed,
(isAuthed) => {
if (isAuthed) {
connect()
} else {
disconnect()
}
},
{ immediate: true }
)
onMounted(() => {
connect()
})
return {
connect,
disconnect,
}
}

View File

@@ -1,4 +1,5 @@
import { useConfigStore } from "shared/store/config"
import { useUserStore } from "shared/store/user"
import {
useConfigWebSocket,
type ConfigUpdate,
@@ -6,6 +7,7 @@ import {
export function useMaxKB() {
const configStore = useConfigStore()
const userStore = useUserStore()
const isLoaded = ref(false)
// 处理 WebSocket 配置更新 - 只处理 MaxKB 相关
@@ -20,7 +22,20 @@ export function useMaxKB() {
}
// 初始化 WebSocket
const { connect } = useConfigWebSocket(handleConfigUpdate)
const { connect, disconnect } = useConfigWebSocket(handleConfigUpdate)
// 监听登录状态变化
watch(
() => userStore.isAuthed,
(isAuthed) => {
if (isAuthed) {
connect()
} else {
disconnect()
}
},
{ immediate: true }
)
const loadMaxKBScript = () => {
const { enable_maxkb } = configStore.config