refactor: websocket支持单用户多连接

This commit is contained in:
meilin.huang
2023-10-19 19:00:23 +08:00
parent 747ea6404d
commit 2b91bbe185
31 changed files with 365 additions and 263 deletions

View File

@@ -1,7 +1,7 @@
import router from '../router';
import Axios from 'axios';
import config from './config';
import { getClientUuid, getToken, joinClientParams } from './utils/storage';
import { getClientId, getToken } from './utils/storage';
import { templateResolve } from './utils/string';
import { ElMessage } from 'element-plus';
@@ -54,7 +54,7 @@ service.interceptors.request.use(
if (token) {
// 设置token
config.headers['Authorization'] = token;
config.headers['Client-Uuid'] = getClientUuid();
config.headers['ClientId'] = getClientId();
}
return config;
},
@@ -180,6 +180,11 @@ function getApiUrl(url: string) {
return baseUrl + url + '?' + joinClientParams();
}
// 组装客户端参数,包括 token 和 clientId
export function joinClientParams(): string {
return `token=${getToken()}&clientId=${getClientId()}`;
}
export default {
request,
get,