mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-12-02 22:10:25 +08:00
feature: 每个客户端独立处理后端发送的系统消息
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user