Files
FastGPT/src/utils/user.ts
2023-03-25 20:43:03 +08:00

20 lines
504 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { PRICE_SCALE } from '@/constants/common';
const tokenKey = 'fast-gpt-token';
export const setToken = (val: string) => {
localStorage.setItem(tokenKey, val);
};
export const getToken = () => {
return localStorage.getItem(tokenKey);
};
export const clearToken = () => {
localStorage.removeItem(tokenKey);
};
/**
* 把数据库读取到的price转化成元
*/
export const formatPrice = (val: number, multiple = 1) => {
return Number(((val / PRICE_SCALE) * multiple).toFixed(10));
};