浏览代码

feature/消息接口联调

dy 1 年之前
父节点
当前提交
f034570788
共有 5 个文件被更改,包括 11 次插入6 次删除
  1. 3 2
      .env.development
  2. 2 0
      .env.production
  3. 2 0
      .env.test
  4. 2 2
      src/api/user/index.ts
  5. 2 2
      src/components/RealTimeMsg/index.vue

+ 3 - 2
.env.development

@@ -13,8 +13,9 @@ VITE_APP_UPLOAD_URL = 'http://192.168.101.4:9000'
 # 线上接口地址
 # VITE_APP_API_URL = http://vapi.youlai.tech
 # 开发接口地址
- VITE_APP_API_URL = 'http://192.168.101.4:8079'
-
+VITE_APP_API_URL = 'http://192.168.101.188:8079'
+# Websocket地址
+VITE_WEBSOCKET_URL = 'ws://192.168.101.4:8079'
 ``
 # 是否启用 Mock 服务
 VITE_MOCK_DEV_SERVER = false

+ 2 - 0
.env.production

@@ -5,3 +5,5 @@ NODE_ENV='production'
 VITE_APP_BASE_API = '/client-server'
 
 
+# Websocket地址
+VITE_WEBSOCKET_URL = 'ws://192.168.101.4:8079'

+ 2 - 0
.env.test

@@ -4,3 +4,5 @@ NODE_ENV='test'
 # 代理前缀 测试环境
 VITE_APP_BASE_API = '/prod-api'
 
+# Websocket地址
+VITE_WEBSOCKET_URL = 'ws://192.168.101.4:8079'

+ 2 - 2
src/api/user/index.ts

@@ -151,8 +151,8 @@ export function userMessage(data: any) {
 //实时消息确认
 export function readMessage(data: any) {
   return request({
-    url: "/api/v1/sys/message/readMessage",
+    url: "/api/v1/sys/message/confirmMessage",
     method: "post",
     data,
   });
-}
+}

+ 2 - 2
src/components/RealTimeMsg/index.vue

@@ -26,7 +26,7 @@
   </div>
 </template>
 
-<script setup lang="ts">
+<script setup>
 import { useDictionaryStore } from "@/store";
 import { readMessage } from "@/api/user";
 const dictS = useDictionaryStore();
@@ -50,7 +50,7 @@ const submit = async (item, index) => {
 };
 //连接地址
 const ws = new WebSocket(
-  `ws://192.168.101.4:8079/websocket/${localStorage.getItem("token")}`
+  `${import.meta.env.VITE_WEBSOCKET_URL}/websocket/${localStorage.getItem("token")}`
 );
 ws.onopen = () => {
   console.log("实时已连接");