feat: websocket 调试
This commit is contained in:
@@ -120,7 +120,7 @@ export class WebSocketManager {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
this.ws = new WebSocket(this.wsUrl, this.protocols)
|
this.ws = new WebSocket(this.wsUrl, this.protocols)
|
||||||
|
console.log('WebSocket connecting to:', this.wsUrl)
|
||||||
this.ws.onopen = this.handleOpen
|
this.ws.onopen = this.handleOpen
|
||||||
this.ws.onmessage = this.handleMessage
|
this.ws.onmessage = this.handleMessage
|
||||||
this.ws.onclose = this.handleClose
|
this.ws.onclose = this.handleClose
|
||||||
|
|||||||
@@ -85,6 +85,8 @@ import { WebSocketManager } from "@common/WebSocketManager";
|
|||||||
import { MessageRole, MessageType, ChatMessage } from "./model/ChatModel";
|
import { MessageRole, MessageType, ChatMessage } from "./model/ChatModel";
|
||||||
import { ThrottleUtils, IdUtils } from "@common/index";
|
import { ThrottleUtils, IdUtils } from "@common/index";
|
||||||
|
|
||||||
|
import { Session } from '../../utils/storage';
|
||||||
|
|
||||||
/// 输入框组件引用
|
/// 输入框组件引用
|
||||||
const inputAreaRef = ref(null);
|
const inputAreaRef = ref(null);
|
||||||
|
|
||||||
@@ -212,7 +214,7 @@ const initHandler = () => {
|
|||||||
|
|
||||||
const getAccessToken = () => {
|
const getAccessToken = () => {
|
||||||
// 从本地存储获取 token
|
// 从本地存储获取 token
|
||||||
return localStorage.getItem("access_token") || "";
|
return 'cLKaO8WiZfFrxFmpsHnuy6STXndBMxnCpFem1AOM3b_LDEqkbQsUw5laUYv5mnUmgZcp2bIdnfKlAs7SPb6OvGlCf-TJrt0ez9OHULDzxG5Zfv63RR12a-s4nwD0LXeX';
|
||||||
};
|
};
|
||||||
|
|
||||||
const checkToken = async () => {
|
const checkToken = async () => {
|
||||||
@@ -244,8 +246,7 @@ const initWebSocket = async () => {
|
|||||||
|
|
||||||
// 使用配置的WebSocket服务器地址
|
// 使用配置的WebSocket服务器地址
|
||||||
const token = getAccessToken();
|
const token = getAccessToken();
|
||||||
const wsUrl = `?access_token=${token}`;
|
const wsUrl = `wss://onefeel.brother7.cn/ingress/agent/ws/chat?access_token=${token}`;
|
||||||
|
|
||||||
// 初始化WebSocket管理器
|
// 初始化WebSocket管理器
|
||||||
webSocketManager = new WebSocketManager({
|
webSocketManager = new WebSocketManager({
|
||||||
wsUrl: wsUrl,
|
wsUrl: wsUrl,
|
||||||
@@ -482,7 +483,7 @@ const sendWebSocketMessage = async (messageType: number, messageContent: any, op
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const maxRetries = typeof options.messageId === 'number' ? options.retries : 3;
|
const maxRetries = typeof options.retries === 'number' ? options.retries : 3;
|
||||||
const baseDelay = typeof options.baseDelay === 'number' ? options.baseDelay : 300; // ms
|
const baseDelay = typeof options.baseDelay === 'number' ? options.baseDelay : 300; // ms
|
||||||
const maxDelay = typeof options.maxDelay === 'number' ? options.maxDelay : 5000; // ms
|
const maxDelay = typeof options.maxDelay === 'number' ? options.maxDelay : 5000; // ms
|
||||||
|
|
||||||
|
|||||||
@@ -87,10 +87,21 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useUserStore } from "@renderer/store/userinfo"
|
import { reactive, ref, onMounted } from "vue"
|
||||||
|
import { useUserStore } from "../../../renderer/store/userinfo"
|
||||||
import { RiUser3Fill, RiKey2Fill } from '@remixicon/vue'
|
import { RiUser3Fill, RiKey2Fill } from '@remixicon/vue'
|
||||||
import { generateUUID } from "@utils/generateUUID"
|
import { generateUUID } from "../../../renderer/utils/generateUUID"
|
||||||
import { rule } from '@utils/validate'
|
import { rule } from '../../../renderer/utils/validate'
|
||||||
|
|
||||||
|
// form 表单数据类型声明
|
||||||
|
interface LoginForm {
|
||||||
|
username: string;
|
||||||
|
password: string;
|
||||||
|
randomStr: string;
|
||||||
|
code: string;
|
||||||
|
grant_type: string;
|
||||||
|
scope: string;
|
||||||
|
}
|
||||||
|
|
||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
const form = reactive<LoginForm>({ username: "", password: "", randomStr: '', code: "", grant_type: '', scope: '' });
|
const form = reactive<LoginForm>({ username: "", password: "", randomStr: '', code: "", grant_type: '', scope: '' });
|
||||||
@@ -106,10 +117,12 @@ const rules = reactive({
|
|||||||
|
|
||||||
//获取验证码图片
|
//获取验证码图片
|
||||||
const { VITE_SERVICE_URL } = (import.meta as any).env
|
const { VITE_SERVICE_URL } = (import.meta as any).env
|
||||||
|
|
||||||
const getVerifyCode = async () => {
|
const getVerifyCode = async () => {
|
||||||
form.randomStr = generateUUID()
|
form.randomStr = generateUUID()
|
||||||
|
const url = `${VITE_SERVICE_URL}/auth/code/image?randomStr=${form.randomStr}`
|
||||||
imgSrc.value = `${VITE_SERVICE_URL}/auth/code/image?randomStr=${form.randomStr}`
|
console.log('验证码地址', url)
|
||||||
|
imgSrc.value = url
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => getVerifyCode())
|
onMounted(() => getVerifyCode())
|
||||||
|
|||||||
Reference in New Issue
Block a user