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

@@ -76,64 +76,64 @@ export default defineConfig(({ envMode }) => {
performance: { performance: {
chunkSplit: { chunkSplit: {
strategy: "split-by-module", strategy: "split-by-module",
// override: { override: {
// cacheGroups: { cacheGroups: {
// // ===== 核心框架层 (100+) ===== // ===== 核心框架层 (100+) =====
// // Vue 生态 - 框架基础,最高优先级 // Vue 生态 - 框架基础,最高优先级
// vue: { vue: {
// test: /[\\/]node_modules[\\/](vue|vue-router|pinia|@vue|@vueuse)[\\/]/, test: /[\\/]node_modules[\\/](vue|vue-router|pinia|@vue|@vueuse)[\\/]/,
// name: "vendor-vue", name: "vendor-vue",
// priority: 100, priority: 100,
// }, },
// // ===== UI 层 (90+) ===== // ===== UI 层 (90+) =====
// // Naive UI 及其依赖 - 核心 UI 框架 // Naive UI 及其依赖 - 核心 UI 框架
// ui: { ui: {
// test: /[\\/]node_modules[\\/](naive-ui|@css-render|css-render|seemly|vooks|vueuc|treemate|vdirs|evtd)[\\/]/, test: /[\\/]node_modules[\\/](naive-ui|@css-render|css-render|seemly|vooks|vueuc|treemate|vdirs|evtd)[\\/]/,
// name: "vendor-ui", name: "vendor-ui",
// priority: 90, priority: 90,
// }, },
// // ===== 编辑器层 (70-80) ===== // ===== 编辑器层 (70-80) =====
// // CodeMirror - 代码编辑器(使用最频繁) // CodeMirror - 代码编辑器(使用最频繁)
// editor: { editor: {
// test: /[\\/]node_modules[\\/](codemirror|@codemirror|vue-codemirror|y-codemirror\.next)[\\/]/, test: /[\\/]node_modules[\\/](codemirror|@codemirror|vue-codemirror|y-codemirror\.next)[\\/]/,
// name: "vendor-editor", name: "vendor-editor",
// priority: 80, priority: 80,
// }, },
// // Markdown 编辑器 // Markdown 编辑器
// mdeditor: { mdeditor: {
// test: /[\\/]node_modules[\\/]md-editor-v3[\\/]/, test: /[\\/]node_modules[\\/]md-editor-v3[\\/]/,
// name: "vendor-mdeditor", name: "vendor-mdeditor",
// priority: 75, priority: 75,
// }, },
// // WangEditor - 富文本编辑器 // WangEditor - 富文本编辑器
// wangeditor: { wangeditor: {
// test: /[\\/]node_modules[\\/]@wangeditor-next[\\/]/, test: /[\\/]node_modules[\\/]@wangeditor-next[\\/]/,
// name: "vendor-wangeditor", name: "vendor-wangeditor",
// priority: 70, priority: 70,
// }, },
// // ===== 功能库层 (50-60) ===== // ===== 功能库层 (50-60) =====
// // Chart.js - 图表库(按需加载) // Chart.js - 图表库(按需加载)
// charts: { charts: {
// test: /[\\/]node_modules[\\/](chart\.js|vue-chartjs|@kurkle|canvas-confetti)[\\/]/, test: /[\\/]node_modules[\\/](chart\.js|vue-chartjs|@kurkle|canvas-confetti)[\\/]/,
// name: "vendor-charts", name: "vendor-charts",
// priority: 60, priority: 60,
// }, },
// // Mermaid - 流程图库(按需加载) // Mermaid - 流程图库(按需加载)
// mermaid: { mermaid: {
// test: /[\\/]node_modules[\\/]mermaid[\\/]/, test: /[\\/]node_modules[\\/]mermaid[\\/]/,
// name: "vendor-mermaid", name: "vendor-mermaid",
// priority: 55, priority: 55,
// }, },
// // ===== 通用层 (10) ===== // ===== 通用层 (10) =====
// // 其他常用库 - 兜底分组 // 其他常用库 - 兜底分组
// common: { common: {
// test: /[\\/]node_modules[\\/]/, test: /[\\/]node_modules[\\/]/,
// name: "vendor-common", name: "vendor-common",
// priority: 10, priority: 10,
// minChunks: 2, minChunks: 2,
// }, },
// }, },
// }, },
}, },
removeConsole: ["log"], removeConsole: ["log"],
}, },

View File

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

View File

@@ -1,4 +1,5 @@
import { useConfigStore } from "shared/store/config" import { useConfigStore } from "shared/store/config"
import { useUserStore } from "shared/store/user"
import { import {
useConfigWebSocket, useConfigWebSocket,
type ConfigUpdate, type ConfigUpdate,
@@ -6,6 +7,7 @@ import {
export function useConfigUpdate() { export function useConfigUpdate() {
const configStore = useConfigStore() const configStore = useConfigStore()
const userStore = useUserStore()
// 处理 WebSocket 配置更新 // 处理 WebSocket 配置更新
const handleConfigUpdate = (data: ConfigUpdate) => { const handleConfigUpdate = (data: ConfigUpdate) => {
@@ -17,12 +19,23 @@ export function useConfigUpdate() {
} }
// 初始化 WebSocket - handler 会在 onMounted 时自动添加 // 初始化 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 { return {
connect, connect,
disconnect,
} }
} }

View File

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