20 lines
425 B
TypeScript
20 lines
425 B
TypeScript
import { useAccountStore } from '@/stores/user';
|
|
import { emitEvent } from '@/utils/eventBus';
|
|
|
|
/**
|
|
* 验证登录转态,可触发登录操作
|
|
* @returns
|
|
*/
|
|
export function useLoginCheck() {
|
|
const account = useAccountStore();
|
|
const loginCheck = (triggerType?: string) => {
|
|
if (!account.isLogin) {
|
|
emitEvent('login', { triggerType });
|
|
}
|
|
return account.isLogin;
|
|
};
|
|
return {
|
|
loginCheck
|
|
};
|
|
}
|