caner 1 year ago
parent
commit
01730fd62d
4 changed files with 36 additions and 14 deletions
  1. 21 6
      .eslintrc.json
  2. 1 0
      package.json
  3. 13 7
      src/pages/login/index.vue
  4. 1 1
      src/services/net.service.ts

+ 21 - 6
.eslintrc.json

@@ -16,17 +16,30 @@
   ],
   ],
   "rules": {
   "rules": {
     "no-console": 0, // 禁用打印
     "no-console": 0, // 禁用打印
-    "comma-dangle": [ 2, "never" ], // 禁止使用拖尾逗号
+    "comma-dangle": [
+      2,
+      "never"
+    ], // 禁止使用拖尾逗号
     "no-extra-semi": 2, // 禁止不必要的分号
     "no-extra-semi": 2, // 禁止不必要的分号
-    "array-bracket-spacing": [ 2, "always" ], // 指定数组的元素之间要以空格隔开
+    "array-bracket-spacing": [
+      2,
+      "always"
+    ], // 指定数组的元素之间要以空格隔开
     "jsx-quotes": 0, // 强制使用单引号
     "jsx-quotes": 0, // 强制使用单引号
     "max-len": 0, // 强制一行的最大长度
     "max-len": 0, // 强制一行的最大长度
-    "semi": [ 2, "never" ], // 禁止使用分号
+    "semi": [
+      2,
+      "never"
+    ], // 禁止使用分号
     "no-unused-vars": 0,
     "no-unused-vars": 0,
     "no-unneeded-ternary": 0, // 禁止不必要的嵌套 var isYes = answer === 1 ? true : false;
     "no-unneeded-ternary": 0, // 禁止不必要的嵌套 var isYes = answer === 1 ? true : false;
     "no-unreachable": 2, // 不能有无法执行的代码
     "no-unreachable": 2, // 不能有无法执行的代码
     "no-unused-expressions": 1, // 禁止无用的表达式
     "no-unused-expressions": 1, // 禁止无用的表达式
-    "linebreak-style": [ 0, "error", "windows" ],
+    "linebreak-style": [
+      0,
+      "error",
+      "windows"
+    ],
     "import/no-unresolved": 0,
     "import/no-unresolved": 0,
     "import/extensions": 0,
     "import/extensions": 0,
     "vue/multi-word-component-names": 0,
     "vue/multi-word-component-names": 0,
@@ -39,9 +52,11 @@
     "no-new": 0,
     "no-new": 0,
     "func-names": 0,
     "func-names": 0,
     "no-nested-ternary": 0,
     "no-nested-ternary": 0,
-    "import/no-extraneous-dependencies": 0 ,
+    "import/no-extraneous-dependencies": 0,
     "max-classes-per-file": 0,
     "max-classes-per-file": 0,
     "class-methods-use-this": 0,
     "class-methods-use-this": 0,
-    "no-return-await": 0
+    "no-return-await": 0,
+    "no-throw-literal": 0,
+    "no-undef": 1
   }
   }
 }
 }

+ 1 - 0
package.json

@@ -14,6 +14,7 @@
   "dependencies": {
   "dependencies": {
     "@kuyoonjo/tauri-plugin-mqtt": "^0.1.0",
     "@kuyoonjo/tauri-plugin-mqtt": "^0.1.0",
     "@tauri-apps/api": "^2",
     "@tauri-apps/api": "^2",
+    "@tauri-apps/plugin-http": "^2.2.0",
     "naive-ui": "^2.40.1",
     "naive-ui": "^2.40.1",
     "pinia": "^2.2.6",
     "pinia": "^2.2.6",
     "pinia-plugin-persist": "^1.0.0",
     "pinia-plugin-persist": "^1.0.0",

+ 13 - 7
src/pages/login/index.vue

@@ -63,20 +63,26 @@ import {
 } from '@kuyoonjo/tauri-plugin-mqtt'
 } from '@kuyoonjo/tauri-plugin-mqtt'
 import topBar from '@/components/topBar.vue'
 import topBar from '@/components/topBar.vue'
 import useStore from '@/store/index'
 import useStore from '@/store/index'
+import NetService from '@/services/net.service'
 
 
 const err = ref('')
 const err = ref('')
-const name = ref('')
-const room = ref('')
-const url = ref('')
+const name = ref('test123')
+const room = ref('test')
+const url = ref('mqtts://caner.top:49659')
 const disabled = computed(() => !name.value || !room.value || !url.value || !url.value.includes('mqtts://'))
 const disabled = computed(() => !name.value || !room.value || !url.value || !url.value.includes('mqtts://'))
 const store = useStore()
 const store = useStore()
+const netService = new NetService()
 
 
 async function login() {
 async function login() {
   if (disabled.value) return
   if (disabled.value) return
-  const newUrl = `${url.value}?username=${room.value}&password=${name.value}`
-  console.log(123, newUrl)
-
-  connect(store.mqtt_client_id, newUrl)
+  const parsedUrl = url.value.split(':')
+  const newUrl = `${parsedUrl[0]}:${parsedUrl[1]}?username=${room.value}&password=${name.value}&port=${parsedUrl[2] || ''}`
+  console.log('登陆', newUrl)
+  netService.get('https://www.baidu.com')
+  connect(store.mqtt_client_id, newUrl, { skipVerification: true })
+  listen((payload) => {
+    console.log(6666, payload)
+  })
 }
 }
 </script>
 </script>
 <style scoped lang="scss">
 <style scoped lang="scss">

+ 1 - 1
src/services/net.service.ts

@@ -118,4 +118,4 @@ export default class NetService extends Service {
       })
       })
     })
     })
   }
   }
-}
+}