12 lines
300 B
TypeScript
12 lines
300 B
TypeScript
|
|
const TERMINAL_KEY = "meezi_terminal_id";
|
||
|
|
|
||
|
|
export function getOrCreateTerminalId(): string {
|
||
|
|
if (typeof window === "undefined") return "server";
|
||
|
|
let id = localStorage.getItem(TERMINAL_KEY);
|
||
|
|
if (!id) {
|
||
|
|
id = crypto.randomUUID();
|
||
|
|
localStorage.setItem(TERMINAL_KEY, id);
|
||
|
|
}
|
||
|
|
return id;
|
||
|
|
}
|