import { useUserStore } from '@/stores/modules/user';
|
import Taro from '@tarojs/taro';
|
import { Message } from '@/utils';
|
import { useIsLogin, useUser } from './user';
|
|
/**
|
* 需要登录
|
*/
|
export function useAccessLogin<T extends (...args: any[]) => any>(fn: T) {
|
const isLogin = useIsLogin();
|
const router = Taro.useRouter();
|
|
const _fn = (...args2) => {
|
if (!isLogin.value) {
|
Message.confirm({ message: '请前往登录' }).then(() => {
|
Taro.navigateTo({
|
url: `${RouterPath.authorization}`,
|
});
|
});
|
return;
|
}
|
fn?.(...args2);
|
};
|
return _fn as T;
|
}
|