Browse Source

测试 mqtt

caner 1 year ago
parent
commit
aee331aa86
7 changed files with 156 additions and 217 deletions
  1. 1 1
      .eslintrc.json
  2. 5 0
      README.md
  3. 0 1
      package.json
  4. 142 202
      src-tauri/Cargo.lock
  5. 0 3
      src-tauri/Cargo.toml
  6. 5 2
      src/pages/login/index.vue
  7. 3 8
      src/services/net.service.ts

+ 1 - 1
.eslintrc.json

@@ -57,6 +57,6 @@
     "class-methods-use-this": 0,
     "no-return-await": 0,
     "no-throw-literal": 0,
-    "no-undef": 1
+    "no-undef": 0
   }
 }

+ 5 - 0
README.md

@@ -7,3 +7,8 @@
 1. yarn
 2. yarn tauri dev
 ```
+
+### clear cache
+```
+1. cargo cache -a
+```

+ 0 - 1
package.json

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

File diff suppressed because it is too large
+ 142 - 202
src-tauri/Cargo.lock


+ 0 - 3
src-tauri/Cargo.toml

@@ -22,6 +22,3 @@ tauri = { version = "2", features = ["macos-private-api"] }
 serde = { version = "1", features = ["derive"] }
 serde_json = "1"
 tauri-plugin-mqtt = "0.1.0"
-
-[target."cfg(target_os = \"macos\")".dependencies]
-cocoa = "0.25"

+ 5 - 2
src/pages/login/index.vue

@@ -76,9 +76,12 @@ const netService = new NetService()
 async function login() {
   if (disabled.value) return
   const parsedUrl = url.value.split(':')
-  const newUrl = `${parsedUrl[0]}:${parsedUrl[1]}?username=${room.value}&password=${name.value}&port=${parsedUrl[2] || ''}`
+  const newUrl = `${parsedUrl[0]}:${parsedUrl[1]}?username=${room.value}&password=${name.value}&port=${parsedUrl[2] || ''}&client_id=test33`
   console.log('登陆', newUrl)
-  netService.get('https://www.baidu.com')
+
+  const a = await netService.get('https://restapi.amap.com/v3/ip?key=76f9007ba8c4c44bb9ad757fe27acb44')
+  console.log(123, a)
+
   connect(store.mqtt_client_id, newUrl, { skipVerification: true })
   listen((payload) => {
     console.log(6666, payload)

+ 3 - 8
src/services/net.service.ts

@@ -11,8 +11,6 @@ declare type NetResult = {
  */
 @injectable
 export default class NetService extends Service {
-  protected url = import.meta.env.VITE_PROXY_URL
-
   /**
    * post方法请求接口
    * @param url 接口地址
@@ -100,7 +98,7 @@ export default class NetService extends Service {
           controller.abort()
         }, timeout)
       }
-      fetch(this.url + url, {
+      fetch(url, {
         signal,
         ...opt,
         headers: opt.headers || { 'Content-Type': 'application/json' }
@@ -108,11 +106,8 @@ export default class NetService extends Service {
         if (res.status === 500) return { success: false, data: '请求错误' }
         return res.json()
       }).then((res) => {
-        const obj = { data: res.data, success: res.data instanceof Object }
-        if (!obj.success && obj.data.includes('need authrize')) {
-          throw 401
-        }
-        resolve(obj)
+        console.log(8, res)
+        resolve({ data: res.data, success: res.data instanceof Object })
       }).catch((er) => {
         throw er
       })

Some files were not shown because too many files changed in this diff