Browse Source

增加 moubus ice104 的端口配置

yanglzh 1 month ago
parent
commit
161a07f51a
4 changed files with 16 additions and 10 deletions
  1. 2 0
      .env.golocal
  2. 4 4
      src/utils/authDirective.ts
  3. 3 3
      src/utils/colDirective.ts
  4. 7 3
      src/utils/origin.ts

+ 2 - 0
.env.golocal

@@ -6,5 +6,7 @@ VITE_ROUTER_MODE = 'hash'
 
 VITE_SERVER_ORIGIN = ''
 
+VITE_MODBUS_API = ':8110'
+VITE_ICE104_API = ':8310'
 VITE_RULE_SERVER_URL = ':9090'
 VITE_MEDIA_SERVER_URL = ':8080'

+ 4 - 4
src/utils/authDirective.ts

@@ -18,7 +18,7 @@ export function authDirective(app: App) {
 			if (buttons.includes(allPermissions)) return
 
 			// 不显示该dom
-			if (!buttons.includes(binding.value)) el.parentNode.removeChild(el)
+			if (!buttons.includes(binding.value)) el.parentNode?.removeChild(el)
 			// 设置为disabled
 			// if (!buttons.includes(binding.value)) el.classList.add('v-disabled')
 		},
@@ -26,7 +26,7 @@ export function authDirective(app: App) {
 	app.directive('noauth', {
 		mounted(el, binding) {
 			const buttons = <string[]>router.currentRoute.value.meta.buttons
-			if (buttons.includes(binding.value)) el.parentNode.removeChild(el)
+			if (buttons.includes(binding.value)) el.parentNode?.removeChild(el)
 		},
 	});
 	// 多个权限验证,满足一个则显示(v-auths="[xxx,xxx]")
@@ -41,7 +41,7 @@ export function authDirective(app: App) {
 					if (val === v) flag = true;
 				});
 			});
-			if (!flag) el.parentNode.removeChild(el);
+			if (!flag) el.parentNode?.removeChild(el);
 			// if (!flag) el.classList.add('v-disabled')
 		},
 	});
@@ -51,7 +51,7 @@ export function authDirective(app: App) {
 			if (localStorage.btnNoAuth) return
 			const buttons = <string[]>router.currentRoute.value.meta.buttons
 			if (buttons.includes(allPermissions)) return
-			!smallInBig(buttons, binding.value) && el.parentNode.removeChild(el)
+			!smallInBig(buttons, binding.value) && el.parentNode?.removeChild(el)
 			// !smallInBig(buttons, binding.value) && el.classList.add('v-disabled')
 		},
 	});

+ 3 - 3
src/utils/colDirective.ts

@@ -16,7 +16,7 @@ export function colDirective(app: App) {
 			if (localStorage.colNoAuth) return
 			const columns = <string[]>router.currentRoute.value.meta.columns
 			if (columns.includes(allPermissions)) return
-			if (!columns.includes(binding.value)) el.parentNode.removeChild(el)
+			if (!columns.includes(binding.value)) el.parentNode?.removeChild(el)
 		},
 	});
 	// 多个权限验证,满足一个则显示(v-cols="[xxx,xxx]")
@@ -31,7 +31,7 @@ export function colDirective(app: App) {
 					if (val === v) flag = true;
 				});
 			});
-			if (!flag) el.parentNode.removeChild(el);
+			if (!flag) el.parentNode?.removeChild(el);
 		},
 	});
 	// 多个权限验证,全部满足则显示(v-col-all="[xxx,xxx]")
@@ -40,7 +40,7 @@ export function colDirective(app: App) {
 			if (localStorage.colNoAuth) return
 			const columns = <string[]>router.currentRoute.value.meta.columns
 			if (columns.includes(allPermissions)) return
-			!smallInBig(columns, binding.value) && el.parentNode.removeChild(el)
+			!smallInBig(columns, binding.value) && el.parentNode?.removeChild(el)
 		},
 	});
 }

+ 7 - 3
src/utils/origin.ts

@@ -28,9 +28,13 @@ export default function getOrigin(urlStr: string = '', type: string = 'http') {
 
 // 如果 modbus服务  ice104协议网关服务 指数管理服务
 export function getOtherServersOrigin(urlStr: string = '') {
-  const origin = import.meta.env.VITE_SERVER_ORIGIN || window.location.origin
-  const nginxProxy = import.meta.env.VITE_NGINX_PROXY
-  return origin + nginxProxy + urlStr
+  if (urlStr?.startsWith(':')) {
+    return window.location.protocol + '//' + window.location.hostname + urlStr
+  } else {
+    const nginxProxy = import.meta.env.VITE_NGINX_PROXY
+    const origin = getOnlyPartOrigin(import.meta.env.VITE_SERVER_ORIGIN)
+    return origin + nginxProxy + urlStr
+  }
 }
 
 // 规则引擎