refactor: ♻️ 我的和登录页面优化,添加主题设置

This commit is contained in:
Ray.Hao
2025-04-05 10:05:05 +08:00
parent 572d347bdb
commit 6a245e9d26
21 changed files with 2594 additions and 182 deletions

22
src/utils/auth.ts Normal file
View File

@@ -0,0 +1,22 @@
import { useUserStore } from "@/store/modules/user";
/**
* 检查用户登录状态,未登录则跳转到登录页面
* @returns 返回用户是否已登录
*/
export function checkLogin(): boolean {
const userStore = useUserStore();
if (!userStore.userInfo) {
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
const currentPagePath = `/${currentPage.route}`;
uni.navigateTo({
url: `/pages/login/index?redirect=${encodeURIComponent(currentPagePath)}`,
});
return false;
}
return true;
}