添加退出登录功能

This commit is contained in:
WindowBird 2025-10-13 15:19:44 +08:00
parent 0c6a7a85be
commit 03ba6f518f
2 changed files with 31 additions and 23 deletions

View File

@ -17,27 +17,6 @@ export function wxLogin(data) {
}); });
} }
/**
* 用户登录
* @param {Object} data - 登录数据
* @returns {Promise} 返回登录结果
*/
export function userLogin(data) {
return post("/user/login", data, {
noToken: true,
showLoading: true,
loadingText: "登录中...",
});
}
/**
* 用户登出
* @returns {Promise} 返回登出结果
*/
export function userLogout() {
return post("/user/logout");
}
/** /**
* 刷新token * 刷新token
* @param {string} refreshToken - 刷新token * @param {string} refreshToken - 刷新token
@ -52,3 +31,12 @@ export function isSysAdmin() {
url: "/app/user/isSysAdmin", url: "/app/user/isSysAdmin",
}); });
} }
/**
* 退出登录
*/
export function logout() {
return request({
url: "/logout",
});
}

View File

@ -41,7 +41,7 @@
<script> <script>
import { CommonEnum } from "@/enum/common.js"; import { CommonEnum } from "@/enum/common.js";
import { getUserInfo } from "@/api/personalCenter/index.js"; import { getUserInfo } from "@/api/personalCenter/index.js";
import { isSysAdmin } from "../../api/auth/auth"; import { isSysAdmin, logout } from "../../api/auth/auth";
export default { export default {
data() { data() {
@ -86,6 +86,10 @@ export default {
icon: CommonEnum.MY_ACTIVITY, icon: CommonEnum.MY_ACTIVITY,
path: "/page_user/luru/index", path: "/page_user/luru/index",
}, },
{
title: "退出登录",
path: "/pages/login/login",
},
], ],
}; };
}, },
@ -129,7 +133,23 @@ export default {
// //
handleMenuClick(item) { handleMenuClick(item) {
console.log("点击菜单项:", item.title); console.log("点击菜单项:", item.title);
if (item.path === "/pages/login/login") {
uni.showModal({
title: "提示",
content: "确定退出登录",
confirmText: "确定",
cancelText: "取消",
success: async (res) => {
if (res.confirm) {
await logout();
uni.navigateTo({
url: "/pages/login/login",
});
}
},
});
return;
}
// //
if (item.path) { if (item.path) {
uni.navigateTo({ uni.navigateTo({