feature: 每个客户端独立处理后端发送的系统消息

This commit is contained in:
wanli
2023-10-18 15:24:29 +08:00
committed by kanzihuang
parent 361eafedae
commit ccfc6bd1df
26 changed files with 171 additions and 95 deletions

View File

@@ -1,6 +1,9 @@
import { v1 as uuidv1 } from 'uuid';
const TokenKey = 'token';
const UserKey = 'user';
const TagViewsKey = 'tagViews';
const ClientUuid = 'clientUuid'
// 获取请求token
export function getToken(): string {
@@ -48,6 +51,21 @@ export function removeTagViews() {
removeSession(TagViewsKey);
}
// 获取客户端UUID
export function getClientUuid(): string {
let uuid = getSession(ClientUuid)
if (uuid == null) {
uuid = uuidv1()
setSession(ClientUuid, uuid)
}
return uuid
}
// 组装客户端参数,包括 token 和 clientUuid
export function joinClientParams(): string {
return `token=${getToken()}&clientUuid=${getClientUuid()}`
}
// 1. localStorage
// 设置永久缓存
export function setLocal(key: string, val: any) {