|
@@ -70,7 +70,17 @@
|
|
|
</div>
|
|
|
<div class="form-item mt-8">
|
|
|
<label>URL地址</label>
|
|
|
- <t-input v-model="modelValue.url" />
|
|
|
+ <t-input
|
|
|
+ :format="urlFormat"
|
|
|
+ :placeholder="
|
|
|
+ modelValue.protocol !== 'http'
|
|
|
+ ? isSafeProtocol()
|
|
|
+ ? '必须是wss协议'
|
|
|
+ : '必须是ws协议'
|
|
|
+ : '请输入'
|
|
|
+ "
|
|
|
+ v-model="modelValue.url"
|
|
|
+ />
|
|
|
</div>
|
|
|
<template v-if="modelValue.protocol === 'websocket'">
|
|
|
<div class="form-item mt-8">
|
|
@@ -275,6 +285,26 @@ const onDelNetWork = async (item: any, i: number) => {
|
|
|
networkList.value.splice(i, 1);
|
|
|
}
|
|
|
};
|
|
|
+
|
|
|
+const isSafeProtocol = () => {
|
|
|
+ return document.location.protocol === 'https:' ? true : false;
|
|
|
+};
|
|
|
+
|
|
|
+const urlFormat = (val) => {
|
|
|
+ if (modelValue.protocol === 'mqtt') {
|
|
|
+ let reg = /^ws\:.*/;
|
|
|
+ if (isSafeProtocol()) {
|
|
|
+ reg = /^wss\:.*/;
|
|
|
+ }
|
|
|
+ if (reg.test(val)) {
|
|
|
+ return val;
|
|
|
+ } else {
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return val;
|
|
|
+ }
|
|
|
+};
|
|
|
</script>
|
|
|
<style lang="postcss" scoped>
|
|
|
.network-component {
|