@zhin.js/client 1.0.17 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/client/app.ts +228 -0
  2. package/client/bootstrap/loadConsoleEntries.test.ts +32 -0
  3. package/client/bootstrap/loadConsoleEntries.ts +149 -0
  4. package/client/console-utils/cn.ts +6 -0
  5. package/client/console-utils/remoteApi.ts +48 -0
  6. package/client/index.ts +61 -14
  7. package/client/persistence/idb-store.ts +76 -0
  8. package/client/runtime/index.ts +12 -0
  9. package/client/store/createRegistryStore.ts +46 -0
  10. package/client/websocket/hooks.ts +218 -510
  11. package/client/websocket/index.ts +6 -43
  12. package/client/websocket/instance.ts +10 -32
  13. package/client/websocket/manager.ts +301 -385
  14. package/client/websocket/remote-settings.ts +25 -0
  15. package/client/websocket/types.ts +58 -222
  16. package/dist/app.d.ts +95 -0
  17. package/dist/app.d.ts.map +1 -0
  18. package/dist/app.js +147 -0
  19. package/dist/app.js.map +1 -0
  20. package/dist/bootstrap/loadConsoleEntries.d.ts +26 -0
  21. package/dist/bootstrap/loadConsoleEntries.d.ts.map +1 -0
  22. package/dist/bootstrap/loadConsoleEntries.js +111 -0
  23. package/dist/bootstrap/loadConsoleEntries.js.map +1 -0
  24. package/dist/bootstrap/loadConsoleEntries.test.d.ts +2 -0
  25. package/dist/bootstrap/loadConsoleEntries.test.d.ts.map +1 -0
  26. package/dist/bootstrap/loadConsoleEntries.test.js +27 -0
  27. package/dist/bootstrap/loadConsoleEntries.test.js.map +1 -0
  28. package/dist/console-utils/cn.d.ts +3 -0
  29. package/dist/console-utils/cn.d.ts.map +1 -0
  30. package/dist/console-utils/cn.js +6 -0
  31. package/dist/console-utils/cn.js.map +1 -0
  32. package/dist/console-utils/remoteApi.d.ts +7 -0
  33. package/dist/console-utils/remoteApi.d.ts.map +1 -0
  34. package/dist/console-utils/remoteApi.js +41 -0
  35. package/dist/console-utils/remoteApi.js.map +1 -0
  36. package/dist/index.d.ts +11 -7
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/index.js +13 -14
  39. package/dist/index.js.map +1 -1
  40. package/dist/persistence/idb-store.d.ts +15 -0
  41. package/dist/persistence/idb-store.d.ts.map +1 -0
  42. package/dist/persistence/idb-store.js +61 -0
  43. package/dist/persistence/idb-store.js.map +1 -0
  44. package/dist/runtime/index.d.ts +6 -0
  45. package/dist/runtime/index.d.ts.map +1 -0
  46. package/dist/runtime/index.js +10 -0
  47. package/dist/runtime/index.js.map +1 -0
  48. package/dist/store/createRegistryStore.d.ts +9 -0
  49. package/dist/store/createRegistryStore.d.ts.map +1 -0
  50. package/dist/store/createRegistryStore.js +38 -0
  51. package/dist/store/createRegistryStore.js.map +1 -0
  52. package/dist/websocket/hooks.d.ts +35 -58
  53. package/dist/websocket/hooks.d.ts.map +1 -1
  54. package/dist/websocket/hooks.js +134 -410
  55. package/dist/websocket/hooks.js.map +1 -1
  56. package/dist/websocket/index.d.ts +5 -10
  57. package/dist/websocket/index.d.ts.map +1 -1
  58. package/dist/websocket/index.js +5 -25
  59. package/dist/websocket/index.js.map +1 -1
  60. package/dist/websocket/instance.d.ts +1 -14
  61. package/dist/websocket/instance.d.ts.map +1 -1
  62. package/dist/websocket/instance.js +2 -20
  63. package/dist/websocket/instance.js.map +1 -1
  64. package/dist/websocket/manager.d.ts +28 -93
  65. package/dist/websocket/manager.d.ts.map +1 -1
  66. package/dist/websocket/manager.js +213 -221
  67. package/dist/websocket/manager.js.map +1 -1
  68. package/dist/websocket/remote-settings.d.ts +5 -0
  69. package/dist/websocket/remote-settings.d.ts.map +1 -0
  70. package/dist/websocket/remote-settings.js +23 -0
  71. package/dist/websocket/remote-settings.js.map +1 -0
  72. package/dist/websocket/types.d.ts +35 -122
  73. package/dist/websocket/types.d.ts.map +1 -1
  74. package/dist/websocket/types.js +4 -13
  75. package/dist/websocket/types.js.map +1 -1
  76. package/package.json +13 -11
  77. package/client/router/index.tsx +0 -54
  78. package/client/store/index.ts +0 -132
  79. package/client/store/reducers/config.ts +0 -135
  80. package/client/store/reducers/index.ts +0 -19
  81. package/client/store/reducers/route.ts +0 -126
  82. package/client/store/reducers/script.ts +0 -109
  83. package/client/store/reducers/ui.ts +0 -31
  84. package/client/websocket/messageHandler.ts +0 -208
  85. package/dist/router/index.d.ts +0 -25
  86. package/dist/router/index.d.ts.map +0 -1
  87. package/dist/router/index.js +0 -48
  88. package/dist/router/index.js.map +0 -1
  89. package/dist/store/index.d.ts +0 -19
  90. package/dist/store/index.d.ts.map +0 -1
  91. package/dist/store/index.js +0 -67
  92. package/dist/store/index.js.map +0 -1
  93. package/dist/store/reducers/config.d.ts +0 -54
  94. package/dist/store/reducers/config.d.ts.map +0 -1
  95. package/dist/store/reducers/config.js +0 -78
  96. package/dist/store/reducers/config.js.map +0 -1
  97. package/dist/store/reducers/index.d.ts +0 -13
  98. package/dist/store/reducers/index.d.ts.map +0 -1
  99. package/dist/store/reducers/index.js +0 -11
  100. package/dist/store/reducers/index.js.map +0 -1
  101. package/dist/store/reducers/route.d.ts +0 -30
  102. package/dist/store/reducers/route.d.ts.map +0 -1
  103. package/dist/store/reducers/route.js +0 -85
  104. package/dist/store/reducers/route.js.map +0 -1
  105. package/dist/store/reducers/script.d.ts +0 -13
  106. package/dist/store/reducers/script.d.ts.map +0 -1
  107. package/dist/store/reducers/script.js +0 -78
  108. package/dist/store/reducers/script.js.map +0 -1
  109. package/dist/store/reducers/ui.d.ts +0 -8
  110. package/dist/store/reducers/ui.d.ts.map +0 -1
  111. package/dist/store/reducers/ui.js +0 -23
  112. package/dist/store/reducers/ui.js.map +0 -1
  113. package/dist/websocket/messageHandler.d.ts +0 -58
  114. package/dist/websocket/messageHandler.d.ts.map +0 -1
  115. package/dist/websocket/messageHandler.js +0 -174
  116. package/dist/websocket/messageHandler.js.map +0 -1
@@ -1,135 +0,0 @@
1
- /**
2
- * 配置管理 Redux Slice
3
- * 通过 WebSocket 管理插件配置
4
- */
5
-
6
- import { createSlice, createAsyncThunk, PayloadAction } from '@reduxjs/toolkit'
7
-
8
- export interface ConfigState {
9
- // 所有插件的配置,按插件名分发
10
- configs: Record<string, any>
11
- // 所有插件的 Schema,按插件名分发
12
- schemas: Record<string, any>
13
- // 加载状态
14
- loading: Record<string, boolean>
15
- // 错误信息
16
- errors: Record<string, string | null>
17
- // WebSocket 连接状态
18
- connected: boolean
19
- }
20
-
21
- const initialState: ConfigState = {
22
- configs: {},
23
- schemas: {},
24
- loading: {},
25
- errors: {},
26
- connected: false
27
- }
28
-
29
- // WebSocket 消息类型
30
- export interface ConfigMessage {
31
- type: 'config:get' | 'config:set' | 'config:updated' | 'schema:get' | 'schema:updated'
32
- pluginName: string
33
- data?: any
34
- error?: string
35
- }
36
-
37
- const configSlice = createSlice({
38
- name: 'config',
39
- initialState,
40
- reducers: {
41
- // WebSocket 连接状态
42
- setConnected: (state, action: PayloadAction<boolean>) => {
43
- state.connected = action.payload
44
- },
45
-
46
- // 设置配置加载状态
47
- setLoading: (state, action: PayloadAction<{ pluginName: string; loading: boolean }>) => {
48
- const { pluginName, loading } = action.payload
49
- state.loading[pluginName] = loading
50
- },
51
-
52
- // 设置错误信息
53
- setError: (state, action: PayloadAction<{ pluginName: string; error: string | null }>) => {
54
- const { pluginName, error } = action.payload
55
- state.errors[pluginName] = error
56
- },
57
-
58
- // 更新插件配置
59
- updateConfig: (state, action: PayloadAction<{ pluginName: string; config: any }>) => {
60
- const { pluginName, config } = action.payload
61
- state.configs[pluginName] = config
62
- state.loading[pluginName] = false
63
- state.errors[pluginName] = null
64
- },
65
-
66
- // 更新插件 Schema
67
- updateSchema: (state, action: PayloadAction<{ pluginName: string; schema: any }>) => {
68
- const { pluginName, schema } = action.payload
69
- state.schemas[pluginName] = schema
70
- },
71
-
72
- // 批量更新配置
73
- updateConfigs: (state, action: PayloadAction<Record<string, any>>) => {
74
- state.configs = { ...state.configs, ...action.payload }
75
- },
76
-
77
- // 批量更新 Schema
78
- updateSchemas: (state, action: PayloadAction<Record<string, any>>) => {
79
- state.schemas = { ...state.schemas, ...action.payload }
80
- },
81
-
82
- // 清除插件配置
83
- removeConfig: (state, action: PayloadAction<string>) => {
84
- const pluginName = action.payload
85
- delete state.configs[pluginName]
86
- delete state.schemas[pluginName]
87
- delete state.loading[pluginName]
88
- delete state.errors[pluginName]
89
- },
90
-
91
- // 清除所有配置
92
- clearConfigs: (state) => {
93
- state.configs = {}
94
- state.schemas = {}
95
- state.loading = {}
96
- state.errors = {}
97
- }
98
- }
99
- })
100
-
101
- export const {
102
- setConnected,
103
- setLoading,
104
- setError,
105
- updateConfig,
106
- updateSchema,
107
- updateConfigs,
108
- updateSchemas,
109
- removeConfig,
110
- clearConfigs
111
- } = configSlice.actions
112
-
113
- export default configSlice.reducer
114
-
115
- // Selectors
116
- export const selectConfig = (state: { config: ConfigState }, pluginName: string) =>
117
- state.config.configs[pluginName]
118
-
119
- export const selectSchema = (state: { config: ConfigState }, pluginName: string) =>
120
- state.config.schemas[pluginName]
121
-
122
- export const selectConfigLoading = (state: { config: ConfigState }, pluginName: string) =>
123
- state.config.loading[pluginName] || false
124
-
125
- export const selectConfigError = (state: { config: ConfigState }, pluginName: string) =>
126
- state.config.errors[pluginName] || null
127
-
128
- export const selectConfigConnected = (state: { config: ConfigState }) =>
129
- state.config.connected
130
-
131
- export const selectAllConfigs = (state: { config: ConfigState }) =>
132
- state.config.configs
133
-
134
- export const selectAllSchemas = (state: { config: ConfigState }) =>
135
- state.config.schemas
@@ -1,19 +0,0 @@
1
- import { Reducer } from "@reduxjs/toolkit"
2
- import ui from "./ui"
3
- import route from "./route"
4
- import script from "./script"
5
- import config from "./config"
6
-
7
- export interface Reducers {
8
- ui: ReturnType<typeof ui>
9
- route: ReturnType<typeof route>
10
- script: ReturnType<typeof script>
11
- config: ReturnType<typeof config>
12
- }
13
-
14
- export const reducers: Record<keyof Reducers, Reducer<any, any>> = {
15
- ui,
16
- route,
17
- script,
18
- config
19
- }
@@ -1,126 +0,0 @@
1
- import { createSlice, PayloadAction } from "@reduxjs/toolkit"
2
- import { ComponentType, ReactNode } from "react"
3
-
4
- // 路由菜单项接口
5
- export interface RouteMenuItem {
6
- key: string
7
- path: string
8
- title: string
9
- index?: boolean
10
- icon?: ReactNode
11
- element?: ReactNode
12
- Component?: ComponentType
13
- children?: RouteMenuItem[]
14
- meta?: {
15
- hideInMenu?: boolean
16
- requiresAuth?: boolean
17
- order?: number
18
- /** 侧栏分组标签,同组内按 order 排序 */
19
- group?: string
20
- /** 主内容区全宽(无 max-w-7xl) */
21
- fullWidth?: boolean
22
- }
23
- }
24
-
25
- export interface RouteState {
26
- routes: RouteMenuItem[]
27
- }
28
-
29
- const initialState: RouteState = {
30
- routes: []
31
- }
32
-
33
- // 辅助函数:查找最佳父路由
34
- const findBestParent = (routes: RouteMenuItem[], fullPath: string): RouteMenuItem | null => {
35
- const segments = fullPath.split('/').filter(Boolean)
36
-
37
- for (let i = segments.length - 1; i > 0; i--) {
38
- const parentPath = '/' + segments.slice(0, i).join('/')
39
- const parent = routes.find(r => r.path === parentPath)
40
- if (parent) return parent
41
- }
42
-
43
- return routes.find(r=>r.path==='/')||null
44
- }
45
-
46
- // 辅助函数:计算相对路径
47
- const calculateRelativePath = (parentPath: string, fullPath: string): string => {
48
- if (parentPath === '/') return fullPath
49
- return fullPath.replace(parentPath + '/', '')
50
- }
51
-
52
- const routeSlice = createSlice({
53
- name: 'route',
54
- initialState,
55
- reducers: {
56
- addRoute: (state, action: PayloadAction<RouteMenuItem>) => {
57
- const route = action.payload
58
- const parent = findBestParent(state.routes, route.path)
59
-
60
- if (parent) {
61
- if (!parent.children) parent.children = []
62
- const relativePath = calculateRelativePath(parent.path, route.path)
63
- parent.children.push({ ...route, path: relativePath })
64
- } else {
65
- state.routes.push(route)
66
- }
67
-
68
- state.routes.sort((a, b) => (a.meta?.order || 999) - (b.meta?.order || 999))
69
- },
70
-
71
- removeRoute: (state, action: PayloadAction<string>) => {
72
- const path = action.payload
73
-
74
- const removeFromArray = (routes: RouteMenuItem[]): boolean => {
75
- const index = routes.findIndex(r => r.path === path)
76
- if (index >= 0) {
77
- routes.splice(index, 1)
78
- return true
79
- }
80
-
81
- for (const route of routes) {
82
- if (route.children && removeFromArray(route.children)) {
83
- return true
84
- }
85
- }
86
- return false
87
- }
88
-
89
- removeFromArray(state.routes)
90
- },
91
-
92
- updateRoute: (state, action: PayloadAction<{ path: string; updates: Partial<RouteMenuItem> }>) => {
93
- const { path, updates } = action.payload
94
-
95
- const updateInArray = (routes: RouteMenuItem[]): boolean => {
96
- const index = routes.findIndex(r => r.path === path)
97
- if (index >= 0) {
98
- routes[index] = { ...routes[index], ...updates }
99
- return true
100
- }
101
-
102
- for (const route of routes) {
103
- if (route.children && updateInArray(route.children)) {
104
- return true
105
- }
106
- }
107
- return false
108
- }
109
-
110
- updateInArray(state.routes)
111
- },
112
-
113
- setRoutes: (state, action: PayloadAction<RouteMenuItem[]>) => {
114
- state.routes = action.payload
115
- state.routes.sort((a, b) => (a.meta?.order || 999) - (b.meta?.order || 999))
116
- },
117
-
118
- clearRoutes: (state) => {
119
- state.routes = []
120
- }
121
- }
122
- })
123
-
124
- export const { addRoute, removeRoute, updateRoute, setRoutes, clearRoutes } = routeSlice.actions
125
- export default routeSlice.reducer
126
-
@@ -1,109 +0,0 @@
1
- import { createSlice, PayloadAction, createAsyncThunk } from "@reduxjs/toolkit"
2
-
3
- export interface ScriptState {
4
- entries: string[]
5
- loadedScripts: string[]
6
- /** 是否已收到 WebSocket 的首次 entries 同步 */
7
- synced: boolean
8
- }
9
-
10
- const initialState: ScriptState = {
11
- entries: [],
12
- loadedScripts: [],
13
- synced: false
14
- }
15
-
16
- // AsyncThunk: 加载单个脚本
17
- export const loadScript = createAsyncThunk(
18
- 'script/loadScript',
19
- async (src: string) => {
20
- return new Promise<string>((resolve, reject) => {
21
- const script = document.createElement('script')
22
- script.type = 'module'
23
- script.src = src
24
- script.dataset.dynamicEntry = 'true'
25
-
26
- script.onload = () => resolve(src)
27
- script.onerror = (error) => {
28
- console.error('[Script] Load failed:', src)
29
- reject(error)
30
- }
31
-
32
- document.body.appendChild(script)
33
- })
34
- }
35
- )
36
-
37
- // AsyncThunk: 批量加载脚本
38
- export const loadScripts = createAsyncThunk(
39
- 'script/loadScripts',
40
- async (entries: string[], { dispatch }) => {
41
- const results = await Promise.allSettled(
42
- entries.map(entry => dispatch(loadScript(entry)).unwrap())
43
- )
44
-
45
- return results
46
- .filter((r): r is PromiseFulfilledResult<string> => r.status === 'fulfilled')
47
- .map(r => r.value)
48
- }
49
- )
50
-
51
- // AsyncThunk: 卸载脚本
52
- export const unloadScript = createAsyncThunk(
53
- 'script/unloadScript',
54
- async (src: string) => {
55
- const scripts = document.querySelectorAll(`script[src="${src}"][data-dynamic-entry="true"]`)
56
- scripts.forEach(script => script.remove())
57
- return src
58
- }
59
- )
60
-
61
- const scriptSlice = createSlice({
62
- name: 'script',
63
- initialState,
64
- reducers: {
65
- syncEntries: (state, action: PayloadAction<string[]>) => {
66
- state.entries = action.payload
67
- // 清理掉不在新 entries 中的 loadedScripts(重启后 entries 可能变化)
68
- state.loadedScripts = state.loadedScripts.filter(s => action.payload.includes(s))
69
- state.synced = true
70
- },
71
-
72
- addEntry: (state, action: PayloadAction<string>) => {
73
- if (!state.entries.includes(action.payload)) {
74
- state.entries.push(action.payload)
75
- }
76
- },
77
-
78
- removeEntry: (state, action: PayloadAction<string>) => {
79
- state.entries = state.entries.filter(e => e !== action.payload)
80
- state.loadedScripts = state.loadedScripts.filter(s => s !== action.payload)
81
- }
82
- },
83
- extraReducers: (builder) => {
84
- // loadScript 成功
85
- builder.addCase(loadScript.fulfilled, (state, action) => {
86
- if (!state.loadedScripts.includes(action.payload)) {
87
- state.loadedScripts.push(action.payload)
88
- }
89
- })
90
-
91
- // loadScripts 成功
92
- builder.addCase(loadScripts.fulfilled, (state, action) => {
93
- action.payload.forEach(src => {
94
- if (!state.loadedScripts.includes(src)) {
95
- state.loadedScripts.push(src)
96
- }
97
- })
98
- })
99
-
100
- // unloadScript 成功
101
- builder.addCase(unloadScript.fulfilled, (state, action) => {
102
- state.loadedScripts = state.loadedScripts.filter(s => s !== action.payload)
103
- })
104
- }
105
- })
106
-
107
- export const { syncEntries, addEntry, removeEntry } = scriptSlice.actions
108
- export default scriptSlice.reducer
109
-
@@ -1,31 +0,0 @@
1
- import { createSlice, PayloadAction } from "@reduxjs/toolkit"
2
-
3
- export interface UIState {
4
- sidebarOpen: boolean
5
- activeMenu: string
6
- }
7
-
8
- const initialState: UIState = {
9
- sidebarOpen: true,
10
- activeMenu: 'home'
11
- }
12
-
13
- const uiSlice = createSlice({
14
- name: 'ui',
15
- initialState,
16
- reducers: {
17
- toggleSidebar: (state) => {
18
- state.sidebarOpen = !state.sidebarOpen
19
- },
20
- setSidebarOpen: (state, action: PayloadAction<boolean>) => {
21
- state.sidebarOpen = action.payload
22
- },
23
- setActiveMenu: (state, action: PayloadAction<string>) => {
24
- state.activeMenu = action.payload
25
- }
26
- }
27
- })
28
-
29
- export const { toggleSidebar, setSidebarOpen, setActiveMenu } = uiSlice.actions
30
- export default uiSlice.reducer
31
-
@@ -1,208 +0,0 @@
1
- /**
2
- * WebSocket 消息处理器
3
- * 负责处理不同类型的 WebSocket 消息并分发到对应的处理逻辑
4
- */
5
-
6
- import {
7
- store,
8
- syncEntries,
9
- addEntry,
10
- removeEntry,
11
- loadScripts,
12
- loadScript,
13
- unloadScript,
14
- updateConfig,
15
- updateSchema,
16
- updateConfigs,
17
- updateSchemas,
18
- setError
19
- } from '../store'
20
- import type { WebSocketMessage } from './types'
21
-
22
- export class MessageHandler {
23
- /**
24
- * 处理 WebSocket 消息
25
- */
26
- static handle(message: WebSocketMessage): void {
27
- try {
28
- const t = (message as { type: string }).type
29
- if (t === 'bot:request' || t === 'bot:notice' || t === 'bot:message') {
30
- if (typeof window !== 'undefined') {
31
- window.dispatchEvent(
32
- new CustomEvent('zhin-console-bot-push', { detail: message })
33
- )
34
- }
35
- return
36
- }
37
- switch (message.type) {
38
- // 脚本管理相关消息
39
- case 'sync':
40
- this.handleScriptSync(message)
41
- break
42
- case 'add':
43
- this.handleScriptAdd(message)
44
- break
45
- case 'delete':
46
- this.handleScriptDelete(message)
47
- break
48
-
49
- // 配置管理相关消息
50
- case 'config:updated':
51
- this.handleConfigUpdated(message)
52
- break
53
- case 'config:batch':
54
- this.handleConfigBatch(message)
55
- break
56
- case 'config:error':
57
- this.handleConfigError(message)
58
- break
59
-
60
- // Schema 管理相关消息
61
- case 'schema:updated':
62
- this.handleSchemaUpdated(message)
63
- break
64
- case 'schema:batch':
65
- this.handleSchemaBatch(message)
66
- break
67
-
68
- // 轻量 HMR:文件变更时刷新页面
69
- case 'hmr:reload':
70
- this.handleHmrReload(message)
71
- break
72
-
73
- // 系统重启通知:延迟后刷新页面
74
- case 'system:restarting':
75
- this.handleSystemRestart()
76
- break
77
-
78
- // 系统消息
79
- case 'init-data':
80
- case 'data-update':
81
- this.handleSystemMessage(message)
82
- break
83
-
84
- default:
85
- console.warn('[WebSocket] Unknown message type:', message.type)
86
- }
87
- } catch (error) {
88
- console.error('[WebSocket] Message handling error:', error)
89
- }
90
- }
91
-
92
- /**
93
- * 处理脚本同步消息
94
- */
95
- private static handleScriptSync(message: any): void {
96
- if (message.data?.key === 'entries') {
97
- const entries = Array.isArray(message.data.value)
98
- ? message.data.value
99
- : [message.data.value]
100
-
101
- store.dispatch(syncEntries(entries))
102
- store.dispatch(loadScripts(entries))
103
- }
104
- }
105
-
106
- /**
107
- * 处理脚本添加消息
108
- */
109
- private static handleScriptAdd(message: any): void {
110
- if (message.data?.key === 'entries') {
111
- store.dispatch(addEntry(message.data.value))
112
- store.dispatch(loadScript(message.data.value))
113
- }
114
- }
115
-
116
- /**
117
- * 处理脚本删除消息
118
- */
119
- private static handleScriptDelete(message: any): void {
120
- if (message.data?.key === 'entries') {
121
- store.dispatch(removeEntry(message.data.value))
122
- store.dispatch(unloadScript(message.data.value))
123
- }
124
- }
125
-
126
- /**
127
- * 处理配置更新消息
128
- */
129
- private static handleConfigUpdated(message: any): void {
130
- if (message.pluginName && message.data !== undefined) {
131
- store.dispatch(updateConfig({
132
- pluginName: message.pluginName,
133
- config: message.data
134
- }))
135
- }
136
- }
137
-
138
- /**
139
- * 处理批量配置消息
140
- */
141
- private static handleConfigBatch(message: any): void {
142
- if (message.data) {
143
- store.dispatch(updateConfigs(message.data))
144
- }
145
- }
146
-
147
- /**
148
- * 处理配置错误消息
149
- */
150
- private static handleConfigError(message: any): void {
151
- if (message.pluginName && message.error) {
152
- store.dispatch(setError({
153
- pluginName: message.pluginName,
154
- error: message.error
155
- }))
156
- }
157
- }
158
-
159
- /**
160
- * 处理 Schema 更新消息
161
- */
162
- private static handleSchemaUpdated(message: any): void {
163
- if (message.pluginName && message.data !== undefined) {
164
- store.dispatch(updateSchema({
165
- pluginName: message.pluginName,
166
- schema: message.data
167
- }))
168
- }
169
- }
170
-
171
- /**
172
- * 处理批量 Schema 消息
173
- */
174
- private static handleSchemaBatch(message: any): void {
175
- if (message.data) {
176
- store.dispatch(updateSchemas(message.data))
177
- }
178
- }
179
-
180
- /**
181
- * 处理轻量 HMR 刷新通知
182
- * 服务端监听到入口目录文件变更后发送此消息,客户端直接刷新页面
183
- */
184
- private static handleHmrReload(message: any): void {
185
- const file = message.data?.file || ''
186
- console.info(`[HMR] 文件变更: ${file},正在刷新页面...`)
187
- window.location.reload()
188
- }
189
-
190
- /**
191
- * 处理系统重启通知
192
- * 服务端即将重启,延迟后刷新页面以重新连接
193
- */
194
- private static handleSystemRestart(): void {
195
- console.info('[System] 服务端正在重启,稍后将自动刷新...')
196
- setTimeout(() => {
197
- window.location.reload()
198
- }, 3000)
199
- }
200
-
201
- /**
202
- * 处理系统消息
203
- */
204
- private static handleSystemMessage(message: WebSocketMessage): void {
205
- // 系统消息暂时不需要特殊处理
206
- // 可以在这里添加系统级别的消息处理逻辑
207
- }
208
- }
@@ -1,25 +0,0 @@
1
- import { RouteMenuItem } from '../store';
2
- export { useOutlet, Outlet, Link, useNavigate, useParams } from 'react-router';
3
- export declare const addPage: (route: RouteMenuItem) => {
4
- payload: RouteMenuItem;
5
- type: "route/addRoute";
6
- };
7
- export declare const removePage: (path: string) => {
8
- payload: string;
9
- type: "route/removeRoute";
10
- };
11
- export declare const updatePage: (path: string, route: RouteMenuItem) => {
12
- payload: {
13
- path: string;
14
- updates: Partial<RouteMenuItem>;
15
- };
16
- type: "route/updateRoute";
17
- };
18
- export declare const getPage: (path: string) => RouteMenuItem | undefined;
19
- export declare const getAllPages: () => RouteMenuItem[];
20
- export declare const clearPages: () => {
21
- payload: undefined;
22
- type: "route/clearRoutes";
23
- };
24
- export declare function DynamicRouter(): import("react/jsx-runtime").JSX.Element;
25
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../client/router/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAA0D,aAAa,EAAe,MAAM,UAAU,CAAA;AAC7G,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAK9E,eAAO,MAAM,OAAO,GAAI,OAAO,aAAa;;;CAAoC,CAAA;AAChF,eAAO,MAAM,UAAU,GAAI,MAAM,MAAM;;;CAAsC,CAAA;AAC7E,eAAO,MAAM,UAAU,GAAI,MAAM,MAAM,EAAE,OAAO,aAAa;;;;;;CAG1D,CAAA;AACH,eAAO,MAAM,OAAO,GAAI,MAAM,MAAM,8BAAqE,CAAA;AACzG,eAAO,MAAM,WAAW,uBAAsC,CAAA;AAC9D,eAAO,MAAM,UAAU;;;CAAsC,CAAA;AAG7D,wBAAgB,aAAa,4CAkC5B"}