|
|
@@ -64,6 +64,7 @@ import { userToken } from "@/composables/config";
|
|
|
import { useI18n } from 'vue-i18n'
|
|
|
import Config from '@/config/index'
|
|
|
import { customApi } from '@/service/custom'
|
|
|
+import tool from "@/global/tool"
|
|
|
|
|
|
const { t, locale } = useI18n()
|
|
|
const globalStore = useGlobalStore()
|
|
|
@@ -143,17 +144,14 @@ const initWebSocket = () => {
|
|
|
let token = userToken.value || uni.getStorageSync('token')
|
|
|
if (!token) return
|
|
|
|
|
|
- // 模拟 tool.tokenReplace 移除 Bearer
|
|
|
- if (token.startsWith('Bearer ')) {
|
|
|
- token = token.replace('Bearer ', '')
|
|
|
- }
|
|
|
+ token = tool.tokenReplace(token);
|
|
|
|
|
|
const wsUrl = `${Config.HostWs}/webSocket?Access-Token=${token}`
|
|
|
|
|
|
websock = uni.connectSocket({
|
|
|
url: wsUrl,
|
|
|
success: () => {
|
|
|
- // console.log('WebSocket connected successfully')
|
|
|
+ console.log('WebSocket connected successfully')
|
|
|
},
|
|
|
fail: () => {
|
|
|
uni.showToast({ title: t('Msg.socket'), icon: 'none' })
|