1234567891011121314151617181920212223242526 |
- import { useAuthStore } from "@/store/auth";
- import { confirm } from "../utils/DialogAction";
- import { navTo } from "../utils/PageAction";
- export function useReqireLogin() {
- const authStore = useAuthStore();
- return {
- requireLogin(cb: () => void, message: string = '登录后查看') {
- if (!authStore.isLogged) {
- confirm({
- title: '提示',
- content: message,
- confirmText: '去登录'
- }).then((res) => {
- if (res) {
- navTo('/pages/user/login');
- return;
- }
- })
- } else {
- cb();
- }
- }
- }
- }
|