1
0
forked from dyf/dyf-vue-ui
Files
dyf-vue-ui/src/utils/auth.ts

15 lines
522 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.

const TokenKey = 'Admin-Token';
const tokenStorage = useStorage<null | string>(TokenKey, null);
export const getToken = () => tokenStorage.value;
//添加token特殊处理没有应用到全局
export const getBearerToken = () => ({
Authorization: tokenStorage.value ? `Bearer ${tokenStorage.value}` : undefined,
clientid: import.meta.env.VITE_APP_CLIENT_ID,
});
export const setToken = (access_token: string) => (tokenStorage.value = access_token);
export const removeToken = () => (tokenStorage.value = null);