Files
boursecu_admin/src/utils/index.ts
T

50 lines
1.3 KiB
TypeScript
Raw Normal View History

2026-01-24 17:45:54 +03:30
import { tokenName } from '@root/config'
export const loading = ref<boolean>(false)
export const loadingMore = ref<boolean>(false)
export function getToken() {
return localStorage.getItem(tokenName)
}
export async function setToken(token: string) {
localStorage.setItem(tokenName, token)
}
export async function setMyInfo(token: string) {
localStorage.setItem(tokenName, token)
}
/*export function getMyInfo() {
return JSON.parse(localStorage.getItem('tamin_my_info') as string)
}*/
export function removeToken() {
return localStorage.removeItem(tokenName)
}
export function hotSelect(e: any) {
e.target?.select()
2026-07-30 18:30:32 +03:30
}
export const createUuid = () => {
if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {
return crypto.randomUUID()
}
if (typeof crypto !== 'undefined' && typeof crypto.getRandomValues === 'function') {
const bytes = new Uint8Array(16)
crypto.getRandomValues(bytes)
bytes[6] = (bytes[6] & 0x0f) | 0x40
bytes[8] = (bytes[8] & 0x3f) | 0x80
const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('')
return [
hex.slice(0, 8),
hex.slice(8, 12),
hex.slice(12, 16),
hex.slice(16, 20),
hex.slice(20),
].join('-')
}
return `${Date.now()}-${Math.floor(Math.random() * 1e9)}`
}