16 lines
339 B
TypeScript
16 lines
339 B
TypeScript
import { defineStore } from "pinia";
|
|
|
|
export const useStoreLocal = defineStore("local", () => {
|
|
function getSessionID(): string {
|
|
let id = localStorage.getItem("session_id");
|
|
if (id) {
|
|
return id;
|
|
}
|
|
id = crypto.randomUUID();
|
|
localStorage.setItem("session_id", id.toString());
|
|
return id;
|
|
}
|
|
return {
|
|
getSessionID,
|
|
};
|
|
});
|