diff --git a/src/api/device/product.ts b/src/api/device/product.ts index d0228def..de7e0256 100644 --- a/src/api/device/product.ts +++ b/src/api/device/product.ts @@ -106,7 +106,7 @@ export const addProduct = (data:any) => server.post('/device-product',data) * @param data * @returns */ -export const editProduct = (data: any) => server.patch('/device-product', data) +export const editProduct = (data: any) => server.put(`/device-product/${data.id}`, data) /** * 删除产品 diff --git a/src/views/init-home/Menu/index.vue b/src/views/init-home/Menu/index.vue index a0266104..f9d6a4cf 100644 --- a/src/views/init-home/Menu/index.vue +++ b/src/views/init-home/Menu/index.vue @@ -23,15 +23,27 @@ const menuDatas = reactive({ count: 0, current: undefined, }); + +/** + * 查询支持的协议 + */ +const getProvidersFn = async () => { + const res: any = await getProviders(); + const ids = res.result?.map?.(item => item.id) || [] + return protocolList.some(item => ids.includes(item.value)) +} + /** * 获取当前系统权限信息 */ const getSystemPermissionData = async () => { + const hasProtocol = await getProvidersFn(); const resp = await getSystemPermission(); if (resp.status === 200) { const newTree = filterMenu( resp.result.map((item: any) => JSON.parse(item).id), BaseMenu, + hasProtocol ); const _count = menuCount(newTree); menuDatas.current = newTree; @@ -39,21 +51,10 @@ const getSystemPermissionData = async () => { } }; -/** - * 查询支持的协议 - */ -let filterProtocolList: any[] = []; -const getProvidersFn = async () => { - const res: any = await getProviders(); - filterProtocolList = protocolList.filter((item) => { - return res.result?.find((val: any) => item.alias == val.id); - }) -} -getProvidersFn(); /** * 过滤菜单 */ -const filterMenu = (permissions: string[], menus: any[]) => { +const filterMenu = (permissions: string[], menus: any[], hasProtocol: boolean) => { return menus.filter((item) => { let isShow = false; if (item.showPage && item.showPage.length) { @@ -62,9 +63,9 @@ const filterMenu = (permissions: string[], menus: any[]) => { }); } if (item.children) { - item.children = filterMenu(permissions, item.children); + item.children = filterMenu(permissions, item.children, hasProtocol); } - if (!filterProtocolList.length && item.code == 'link/DataCollect') { + if (!hasProtocol && item.code == 'link/DataCollect') { return false; } return isShow || !!item.children?.length; diff --git a/vite.config.ts b/vite.config.ts index f5403f0c..72f6cab0 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -95,8 +95,8 @@ export default defineConfig(({ mode}) => { // target: 'http://192.168.32.226:8844', // target: 'http://192.168.32.244:8881', // target: 'http://192.168.32.163:8844', //张季本地 - // target: 'http://120.77.179.54:8844', // 120测试 - target: 'http://192.168.33.46:8844', // 本地开发环境 + target: 'http://120.77.179.54:8844', // 120测试 + // target: 'http://47.109.52.230:8844', // 本地开发环境 ws: 'ws://192.168.33.46:8844', changeOrigin: true, rewrite: (path) => path.replace(/^\/api/, '') diff --git a/yarn.lock b/yarn.lock index d00dce27..8d51d4d7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3755,8 +3755,8 @@ jetlinks-ui-components@^1.0.23: jetlinks-ui-components@^1.0.28: version "1.0.28" - resolved "http://registry.jetlinks.cn/jetlinks-ui-components/-/jetlinks-ui-components-1.0.28.tgz#592812416edb5b1f45991d1714ab13701eeba8da" - integrity sha512-+6zDWT3QwnrtmCNwpZkejZ084Sx5UrH+Jd7z0e8Ds71p7VGxMx/GE+2DQ/ob8ZW2tB7dHQmJi7JhYblHxl6EFg== + resolved "http://registry.jetlinks.cn/jetlinks-ui-components/-/jetlinks-ui-components-1.0.28.tgz#f409bdb62769947bf026a32b98899417d2352d0e" + integrity sha512-SO/04K//MHJ4lAK1KPYf8q+FNaXCnSVsAOhr8YIcaPWlgHuitj9sxdso8xHwypCvNBMEUzTx+kDXB9HAlFqGMA== dependencies: "@vueuse/core" "^9.12.0" "@vueuse/router" "^9.13.0"