From efded34ff2161513719d1b6b2a7ac7eb5477ff52 Mon Sep 17 00:00:00 2001 From: XieYongHong <18010623010@163.com> Date: Fri, 28 Apr 2023 10:42:56 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Diot=E8=B4=A6=E5=8F=B7?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E7=99=BB=E5=BD=95=E5=8F=AF=E8=A7=86=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: bug#12637 * fix: 修复右上角通知文件notification兼容处理 * fix: bug#12637、12632 * fix: bug#12460 * fix: bug#12362 * fix: bug#12350 * fix: bug#12338 * fix: 优化插件映射传参 * fix: 修复采集器查询失败问题 * fix: 修复内部应用页面跳转后显示错误提示的问题 * fix: 修复插件设备映射后没有回显 * fix: 修复插件管理新增id校验失败 * fix: 删除多余代码 * fix: 修复iot账号无法登录可视化 * fix: 优化oauth页面 * fix: 修复iot账号无法登录可视化 --- config/config.ts | 2 +- src/api/link/plugin.ts | 7 ++ src/router/index.ts | 7 +- src/utils/menu.ts | 3 +- src/utils/request.ts | 19 ++- .../DataCollect/Collector/Tree/index.vue | 10 +- .../Info/components/InklingModal/index.vue | 8 +- .../device/Instance/Detail/Info/index.vue | 6 +- .../Product/Detail/DeviceAccess/index.vue | 6 +- .../Detail/DeviceAccess/metadataModal.vue | 4 +- .../Product/Detail/MetadataMap/index.vue | 9 +- src/views/iframe/index.vue | 10 +- src/views/link/plugin/Save.vue | 2 +- src/views/oauth/index.vue | 111 ++++++++++++------ 14 files changed, 127 insertions(+), 77 deletions(-) diff --git a/config/config.ts b/config/config.ts index 9a3c3b8a..6b94b56b 100644 --- a/config/config.ts +++ b/config/config.ts @@ -6,7 +6,7 @@ export default { title: 'Jetlinks', // 浏览器标签页title layout: { title: '物联网平台', // 平台title - logo: '/icons/icon-192x192.png', // 平台logo + logo: '/logo.png', // 平台logo siderWidth: 208, // 左侧菜单栏宽度 headerHeight: 48, // 头部高度 collapsedWidth: 48, diff --git a/src/api/link/plugin.ts b/src/api/link/plugin.ts index b7fcce6d..a23f2cab 100644 --- a/src/api/link/plugin.ts +++ b/src/api/link/plugin.ts @@ -21,6 +21,13 @@ export const detail = (id: string) => get(`/plugin/driver/${id}`) */ export const getProductsById = (id: string) => get(`/plugin/driver/${id}/products`) +/** + * + * @param type product:产品;device:设备 + * @param pluginId 设备接入id + * @param internalId 产品或者设备id + * @param externalId 映射id + */ export const savePluginData = (type: string, pluginId: string, internalId: string, externalId: string ) => patch(`/plugin/mapping/${type}/${pluginId}/${internalId}`, externalId, { headers: {'Content-Type': "text/plain"}}) export const getPluginData = (type: string, pluginId: string, internalId: string ) => get(`/plugin/mapping/${type}/${pluginId}/${internalId}`) diff --git a/src/router/index.ts b/src/router/index.ts index 1ecbc43e..1641803e 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -1,5 +1,5 @@ import { createRouter, createWebHashHistory } from 'vue-router' -import menus, { AccountCenterBindPath, InitHomePath, LoginPath } from './menu' +import menus, { AccountCenterBindPath, InitHomePath, LoginPath, OauthPath } from './menu' import { cleanToken, getToken } from '@/utils/comm' import { useUserInfo } from '@/store/userInfo' import { useSystem } from '@/store/system' @@ -14,12 +14,13 @@ const router = createRouter({ } }) -const filterPath = [ InitHomePath, AccountCenterBindPath ] +const filterPath = [ InitHomePath ] +const noTokenPath = [ AccountCenterBindPath, OauthPath ] router.beforeEach((to, from, next) => { // TODO 切换路由取消请求 const token = getToken() - if (to.path === AccountCenterBindPath) { + if (noTokenPath.includes(to.path)) { next() } else if (token) { if (to.path === LoginPath) { diff --git a/src/utils/menu.ts b/src/utils/menu.ts index 0fc4c8e7..f457d5a8 100644 --- a/src/utils/menu.ts +++ b/src/utils/menu.ts @@ -280,7 +280,8 @@ export function filterAsyncRouter(asyncRouterMap: any, parentCode = '', level = icon: route.icon, title: route.name, hideInMenu: route.isShow === false, - buttons: route.buttons?.map((b: any) => b.id) || [] + buttons: route.buttons?.map((b: any) => b.id) || [], + isApp: hasAppId, }, } diff --git a/src/utils/request.ts b/src/utils/request.ts index 9676b40d..f6b2d6ed 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -13,7 +13,16 @@ interface AxiosResponseRewrite extends AxiosResponse { export const SUCCESS_CODE = 200 // 成功代码 -const filterApiUrl = ['/system/version', '/system/config/front', '/authorize/captcha/config', '/application/sso/_all', '/authorize/captcha/image', '/application/sso/bind-code', '/authorize/login'] +const filterApiUrl = [ + '/system/version', + '/system/config/front', + '/authorize/captcha/config', + '/application/sso/_all', + '/authorize/captcha/image', + '/application/sso/bind-code', + '/authorize/login', + '/application/' +] export const request = axios.create({ withCredentials: false, @@ -149,10 +158,10 @@ const errorHandler = (error: any) => { } else if (status === 401) { showNotification('Unauthorized', '用户未登录', '401') setTimeout(() => { - cleanToken() - router.replace({ - path: LoginPath - }) + // cleanToken() + // router.replace({ + // path: LoginPath + // }) }, 0) } else if (status === 404) { showNotification(error?.code, error?.response?.data?.message, '404') diff --git a/src/views/DataCollect/Collector/Tree/index.vue b/src/views/DataCollect/Collector/Tree/index.vue index f614a4de..ff84153c 100644 --- a/src/views/DataCollect/Collector/Tree/index.vue +++ b/src/views/DataCollect/Collector/Tree/index.vue @@ -157,19 +157,17 @@ const defualtDataSource: any = ref(_.cloneDeep(root)); const defualtParams = { paging: false, sorts: [{ name: 'createTime', order: 'desc' }], - terms: [ + terms: !!channelId ? [ { - terms: !!channelId - ? [ + terms: [ { column: 'channelId', value: channelId, }, - ] - : [], + ], type: 'and', }, - ], + ] : [], }; const params = ref(); diff --git a/src/views/device/Instance/Detail/Info/components/InklingModal/index.vue b/src/views/device/Instance/Detail/Info/components/InklingModal/index.vue index 971f35e1..c4ed9b2c 100644 --- a/src/views/device/Instance/Detail/Info/components/InklingModal/index.vue +++ b/src/views/device/Instance/Detail/Info/components/InklingModal/index.vue @@ -30,10 +30,6 @@ const props = defineProps({ type: String, default: undefined }, - channelId: { - type: String, - default: undefined - }, id: { type: String, default: undefined @@ -47,12 +43,14 @@ const route = useRoute() const handleOk = async () => { if (checkKey.value) { + loading.value = true const res = await savePluginData( 'device', - props.channelId!, + props.accessId!, route.params.id as string, checkKey.value ).catch(() => ({ success: false })) + loading.value = false if (res.success) { emit('submit', checkKey.value) } diff --git a/src/views/device/Instance/Detail/Info/index.vue b/src/views/device/Instance/Detail/Info/index.vue index c9879798..3872dfc2 100644 --- a/src/views/device/Instance/Detail/Info/index.vue +++ b/src/views/device/Instance/Detail/Info/index.vue @@ -110,7 +110,6 @@ { instanceStore.refresh(instanceStore.current?.id); } channelId.value = id - giveAnInkling() + queryInkling() + inkingVisible.value = false } const giveAnInkling = () => { @@ -158,7 +158,7 @@ const queryInkling = () => { queryPluginAccessDetail(instanceStore.current?.accessId).then(async res => { if (res.success) { channelId.value = res.result.channelId - const pluginRes = await getPluginData('device', res.result.channelId, instanceStore.current?.id) + const pluginRes = await getPluginData('device',instanceStore.current?.accessId, instanceStore.current?.id) if (pluginRes.success) { inklingDeviceId.value = pluginRes.result?.externalId } diff --git a/src/views/device/Product/Detail/DeviceAccess/index.vue b/src/views/device/Product/Detail/DeviceAccess/index.vue index e56572ff..fd0e1672 100644 --- a/src/views/device/Product/Detail/DeviceAccess/index.vue +++ b/src/views/device/Product/Detail/DeviceAccess/index.vue @@ -680,7 +680,7 @@ const getData = async (accessId?: string) => { if (productStore.current?.accessProvider === 'plugin_gateway') { queryPluginAccessDetail(_accessId).then(async res => { // if (res.success) { - const pluginRes = await getPluginData('product', res.result.channelId, productStore.current?.id) + const pluginRes = await getPluginData('product', _accessId, productStore.current?.id) const resp = await getProductByPluginId(res.result.channelId).catch(() => ({ success: false, result: []})) if (resp.success) { productTypes.value = resp.result.map(item => { @@ -758,10 +758,10 @@ const updateAccessData = async (id: string, values: any) => { submitLoading.value = false } - if (access.value?.provider === "plugin_gateway") { + if (access.value?.provider === "plugin_gateway" && productData.id) { await savePluginData( 'product', - access.value?.channelId, + access.value?.id, productStore.current.id, productData.id ).catch(() => ({})) diff --git a/src/views/device/Product/Detail/DeviceAccess/metadataModal.vue b/src/views/device/Product/Detail/DeviceAccess/metadataModal.vue index 30059d76..6164f68b 100644 --- a/src/views/device/Product/Detail/DeviceAccess/metadataModal.vue +++ b/src/views/device/Product/Detail/DeviceAccess/metadataModal.vue @@ -133,10 +133,10 @@ const updateAccessData = async (id: string, values: any, metadata: string) => { return } - if (props.access?.provider === 'plugin_gateway') { + if (props.access?.provider === 'plugin_gateway' && props.data.productTypeId) { await savePluginData( 'product', - props.access.channelId, + props.access.id, props.data.id, props.data.productTypeId ).catch(() => ({})) diff --git a/src/views/device/Product/Detail/MetadataMap/index.vue b/src/views/device/Product/Detail/MetadataMap/index.vue index 59ea1ff1..fca7f634 100644 --- a/src/views/device/Product/Detail/MetadataMap/index.vue +++ b/src/views/device/Product/Detail/MetadataMap/index.vue @@ -101,11 +101,11 @@ const columns = [ ] const selectedKeys = computed(() => { - return dataSource.value.filter(item => !!item?.plugin).map(item => item.id) + return dataSource.value?.filter(item => !!item?.plugin).map(item => item.id) || [] }) const selectedPluginKeys = computed(() => { - return dataSource.value.filter(item => !!item?.plugin).map(item => item.plugin) + return dataSource.value?.filter(item => !!item?.plugin).map(item => item.plugin) || [] }) const getMetadataMapData = () => { @@ -124,7 +124,6 @@ const getMetadataMapData = () => { } const search = (value: string) => { - console.log(value) if (value) { dataSource.value = dataSourceCache.value.filter((item: any) => { return !!item.name?.includes(value) @@ -152,7 +151,7 @@ const getDefaultMetadata = async () => { type: item.valueType?.type, plugin: _m?.pluginId, // 插件物模型id } - }) + }) || [] dataSourceCache.value = dataSource.value } @@ -161,7 +160,7 @@ const getPluginMetadata = (): Promise<{ properties: any[]}> => { queryPluginAccessDetail(productDetail.value?.accessId!).then(async res => { if (res.success) { const _channelId = (res.result as any)!.channelId - const pluginRes = await getPluginData('product', _channelId, productDetail.value?.id).catch(() => ({ success: false, result: {}})) + const pluginRes = await getPluginData('product', productDetail.value?.accessId, productDetail.value?.id).catch(() => ({ success: false, result: {}})) const resp = await getProductByPluginId(_channelId).catch(() => ({ success: false, result: []})) if (resp.success) { const _item = (resp.result as any[])?.find((item: any) => item.id === (pluginRes?.result as any)?.externalId) diff --git a/src/views/iframe/index.vue b/src/views/iframe/index.vue index c1445dc0..2d9f9d92 100644 --- a/src/views/iframe/index.vue +++ b/src/views/iframe/index.vue @@ -38,10 +38,14 @@ const handle = async (appId: string, url: string) => { } }; + watchEffect(() => { - const params = route.path.split('/')?.[1]; - const url = route.path.split('/').slice(2).join('/'); - handle(params, url); + const matchedItem: any = route.matched?.[0] + if (matchedItem?.meta?.isApp) { + const params = route.path.split('/')?.[1]; + const url = route.path.split('/').slice(2).join('/'); + handle(params, url); + } }); diff --git a/src/views/link/plugin/Save.vue b/src/views/link/plugin/Save.vue index 2ef30e93..d209d9d7 100644 --- a/src/views/link/plugin/Save.vue +++ b/src/views/link/plugin/Save.vue @@ -94,7 +94,7 @@ const loading = ref(false) const vailId = async (_: any, value: string) => { if (!props.data.id && value) { // 新增校验 const resp = await vailIdFn(value) - if (resp.success && resp.result) { + if (resp.success && resp.result && !resp.result.passed) { return Promise.reject('ID重复'); } } diff --git a/src/views/oauth/index.vue b/src/views/oauth/index.vue index 547796f1..6fc36ac6 100644 --- a/src/views/oauth/index.vue +++ b/src/views/oauth/index.vue @@ -14,9 +14,10 @@
+

授权登录

- 您正在授权登录,{{ appName }}将获得以下权限: + 您正在授权登录, {{ appName }} 将获得以下权限:
  • 关联{{userName}}账号
  • @@ -32,15 +33,16 @@
    +

    授权登录