test_lgq/web/utils/common.ts

28 lines
580 B
TypeScript
Raw Normal View History

2024-01-24 17:36:08 +08:00
import useMemberStores from '@/stores/member'
/**
* token
* @returns
*/
export function getToken(): null | string {
return useMemberStores().token
}
/**
* url
* @param str
* @returns
*/
export function isUrl(str: string): boolean {
return str.indexOf('http://') != -1 || str.indexOf('https://') != -1
}
/**
*
* @param path
* @returns
*/
export function img(path: string): string {
const runtimeConfig = useRuntimeConfig()
return isUrl(path) ? path : `${runtimeConfig.public.VITE_IMG_DOMAIN || location.origin}/${path}`
}