diff --git a/frontend/src/api/system/sntp.ts b/frontend/src/api/system/sntp.ts index fe8b6db..688ac8a 100644 --- a/frontend/src/api/system/sntp.ts +++ b/frontend/src/api/system/sntp.ts @@ -1,5 +1,15 @@ import http from '@/api' +export interface SntpTimeMessage { + type: string + deviceIp?: string + computerTime?: string + deviceTime?: string + computerTimestampMs?: number + deviceTimestampMs?: number + errorMs?: number +} + export const startSntpService = () => { return http.post('/sntp/start', {}) } diff --git a/frontend/src/stores/modules/auth.ts b/frontend/src/stores/modules/auth.ts index 5e99f51..c6ea2e8 100644 --- a/frontend/src/stores/modules/auth.ts +++ b/frontend/src/stores/modules/auth.ts @@ -7,75 +7,60 @@ import { useModeStore } from '@/stores/modules/mode' import { getLicense } from '@/api/activate' import type { Activate } from '@/api/activate/interface' +const CONTRAST_MODE_NAME = '比对式' + export const useAuthStore = defineStore(AUTH_STORE_KEY, { state: (): AuthState => ({ - // 按钮权限列表 authButtonList: {}, - // 菜单权限列表 authMenuList: [], - // 当前页面的 router name,用来做按钮权限筛选 routeName: '', - //登录不显示菜单栏和导航栏,点击进入测试的时候显示 showMenuFlag: JSON.parse(localStorage.getItem('showMenuFlag') as string), activateInfo: {} as Activate.ActivationCodePlaintext }), getters: { - // 按钮权限列表 authButtonListGet: state => state.authButtonList, - // 菜单权限列表 ==> 这里的菜单没有经过任何处理 authMenuListGet: state => state.authMenuList, - // 菜单权限列表 ==> 左侧菜单栏渲染,需要剔除 isHide == true showMenuListGet: state => getShowMenuList(state.authMenuList), - // 菜单权限列表 ==> 扁平化之后的一维数组菜单,主要用来添加动态路由 flatMenuListGet: state => getFlatMenuList(state.authMenuList), - // 递归处理后的所有面包屑导航列表 breadcrumbListGet: state => getAllBreadcrumbList(state.authMenuList), - //是否显示菜单和导航栏 showMenuFlagGet: state => state.showMenuFlag, - // 获取激活信息 activateInfoGet: state => state.activateInfo }, actions: { - // Get AuthButtonList async getAuthButtonList() { const { data } = await getAuthButtonListApi() this.authButtonList = data }, - // Get AuthMenuList async getAuthMenuList() { const modeStore = useModeStore() - const { data: menuData } = await getAuthMenuListApi() - // 根据不同模式过滤菜单 - const filteredMenu = - modeStore.currentMode === '比对式' - ? filterMenuByExcludedNames(menuData, ['testSource', 'testScript', 'controlSource']) - : filterMenuByExcludedNames(menuData, ['standardDevice']) - this.authMenuList = filteredMenu + const isContrastMode = modeStore.currentMode === CONTRAST_MODE_NAME + const filteredMenu = isContrastMode + ? filterMenuByExcludedNames(menuData, ['testSource', 'testScript', 'controlSource']) + : filterMenuByExcludedNames(menuData, ['standardDevice']) + + this.authMenuList = filterMenuByExcludedNames(filteredMenu, ['sntp']) }, - // Set RouteName async setRouteName(name: string) { this.routeName = name }, - //重置权限 async resetAuthStore() { this.showMenuFlag = false localStorage.removeItem('showMenuFlag') }, - //修改判断菜单栏/导航栏显示条件 async setShowMenu() { this.showMenuFlag = true localStorage.setItem('showMenuFlag', 'true') }, - //更改模式 changeModel() { this.showMenuFlag = false localStorage.removeItem('showMenuFlag') }, async setActivateInfo() { - const license_result = await getLicense() - const licenseData = license_result.data as Activate.ActivationCodePlaintext + const licenseResult = await getLicense() + const licenseData = licenseResult.data as Activate.ActivationCodePlaintext + if (!licenseData.simulate) { licenseData.simulate = { permanently: 0 @@ -91,24 +76,18 @@ export const useAuthStore = defineStore(AUTH_STORE_KEY, { permanently: 0 } } + this.activateInfo = licenseData } } }) -/** - * 通用菜单过滤函数 - * @param menuList 菜单列表 - * @param excludedNames 需要排除的菜单名称数组 - * @returns 过滤后的菜单列表 - */ -function filterMenuByExcludedNames(menuList: any[], excludedNames: string[]): any[] { +function filterMenuByExcludedNames(menuList: Menu.MenuOptions[], excludedNames: string[]): Menu.MenuOptions[] { return menuList.filter(menu => { - // 如果当前项有 children,递归处理子项 if (menu.children && menu.children.length > 0) { menu.children = filterMenuByExcludedNames(menu.children, excludedNames) } - // 过滤掉在排除列表中的菜单项 + return !excludedNames.includes(menu.name) }) } diff --git a/frontend/src/views/machine/sntp/index.vue b/frontend/src/views/machine/sntp/index.vue deleted file mode 100644 index 15fe350..0000000 --- a/frontend/src/views/machine/sntp/index.vue +++ /dev/null @@ -1,368 +0,0 @@ - - - - - - - 当前电脑时间 - {{ computerTime }} - - - - - 装置返回时间 - {{ deviceTime }} - - - - - - - 启动SNTP对时服务 - - - 停止SNTP对时服务 - - - - - - 历史记录 - - 清空 - - - - - - 序号 - 当前电脑时间 - 装置返回时间 - 误差(ms) - - - 暂无数据 - - - - {{ index + 1 }} - {{ item.computerTime }} - {{ item.deviceTime }} - {{ formatErrorMs(item.errorMs) }} - - - - - - - - - - - diff --git a/frontend/src/views/toolbox/components/SntpToolDialog.vue b/frontend/src/views/toolbox/components/SntpToolDialog.vue new file mode 100644 index 0000000..d169462 --- /dev/null +++ b/frontend/src/views/toolbox/components/SntpToolDialog.vue @@ -0,0 +1,627 @@ + + + + + + + + + + {{ computerTimeLabel }} + {{ activeDeviceState?.computerTime || '--' }} + + + + + {{ deviceTimeLabel }} + {{ activeDeviceState?.deviceTime || '--' }} + + + + + + + {{ activeDeviceLabel }} + {{ activeDeviceIp || '--' }} + + + {{ latestErrorLabel }} + {{ activeErrorMs }} + + + + + + {{ startButtonText }} + + + {{ stopButtonText }} + + + + + + {{ historyTitle }} + + {{ clearButtonText }} + + + + + + {{ orderColumnLabel }} + {{ computerTimeLabel }} + {{ deviceTimeLabel }} + {{ errorColumnLabel }} + + + {{ emptyHistoryText }} + + + + {{ index + 1 }} + {{ item.computerTime }} + {{ item.deviceTime }} + {{ formatErrorMs(item.errorMs) }} + + + + + + + + + + + + diff --git a/frontend/src/views/toolbox/config/tools.ts b/frontend/src/views/toolbox/config/tools.ts new file mode 100644 index 0000000..a2f3daf --- /dev/null +++ b/frontend/src/views/toolbox/config/tools.ts @@ -0,0 +1,16 @@ +export interface ToolboxToolItem { + key: 'sntp' + title: string + description: string + icon: string + disabled?: boolean +} + +export const toolboxTools: ToolboxToolItem[] = [ + { + key: 'sntp', + title: 'SNTP对时', + description: '内置SNTP服务器,可投入装置SNTP对时功能,进行装置对时', + icon: 'Clock' + } +] diff --git a/frontend/src/views/toolbox/index.vue b/frontend/src/views/toolbox/index.vue new file mode 100644 index 0000000..dd60c57 --- /dev/null +++ b/frontend/src/views/toolbox/index.vue @@ -0,0 +1,126 @@ + + + + + + + + + + + + {{ tool.title }} + {{ tool.description }} + + + + + + + + + +