From a9eef0d69f930d9a38476200785df6e20464a203 Mon Sep 17 00:00:00 2001 From: zzp <34701892@qq.com> Date: Sat, 8 Nov 2025 12:05:24 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=9E=E7=8E=B0=E9=80=80=E5=87=BA?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E6=97=B6=E8=B0=83=E7=94=A8=E5=90=8E=E7=AB=AF?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在多个组件和工具文件中添加了doLogout调用,确保用户退出时通知后端 更新环境配置文件中的API地址 --- .env.development | 4 +- .env.production | 4 +- src/api/index.ts | 8 +++- src/components/mine.vue | 15 +++---- src/pages/realtimeInfo/index.vue | 45 ++++++++++++------- src/pages/realtimeInfo/indexRelease.vue | 24 ++++++---- .../realtimeInfo/pc/components/PageTop.vue | 8 +++- src/utils/index.ts | 4 ++ src/utils/indexDatav.ts | 4 ++ 9 files changed, 74 insertions(+), 42 deletions(-) diff --git a/.env.development b/.env.development index c881666..9a5e003 100644 --- a/.env.development +++ b/.env.development @@ -2,8 +2,8 @@ ENV = development # 本地环境接口地址 -# VITE_API_URL = http://123.60.153.169:8040/apih5 -VITE_API_URL = http://4155gf93ll13.vicp.fun/apih5 +VITE_API_URL = http://123.60.153.169:8040/apih5 +# VITE_API_URL = http://4155gf93ll13.vicp.fun/apih5 # VITE_API_URL = http://123.60.79.143:8041/apih5 # VITE_API_URL =http://localhost:8040/apih5 # VITE_API_URL = https://cankao.cs.com.cn/apih5 diff --git a/.env.production b/.env.production index 8ff2d92..de01dda 100644 --- a/.env.production +++ b/.env.production @@ -3,8 +3,8 @@ ENV = production # 线上环境接口地址 # VITE_API_URL = https://cankao.cs.com.cn/mini -# VITE_API_URL = http://123.60.153.169:8040/apih5 -VITE_API_URL = https://cankao.cs.com.cn/apih5 +VITE_API_URL = http://123.60.153.169:8040/apih5 +# VITE_API_URL = https://cankao.cs.com.cn/apih5 # VITE_API_URL = http://123.60.79.143:8041/apih5 diff --git a/src/api/index.ts b/src/api/index.ts index bb8e713..6bcb856 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -55,13 +55,11 @@ export const getUnlockList = (data: any) => { return Request.post("/user/unlockList", data); }; - // 全文搜索 export const searchNews = (data: any) => { return Request.post("/news/search", data); }; - // 已发布列表 export const getReleaseList = (data: any) => { return Request.post("/news/top_news_release_h5_d", data); @@ -76,3 +74,9 @@ export const editTopNews = (data: any) => { export const sendToken = (data: any) => { return Request.post("/common/forward/financial", data); }; + +// 退出登录 +export const doLogout = (data: any) => { + console.log("🚀 ~ doLogout ~ data:", data); + return Request.post("/common/logout", data); +}; diff --git a/src/components/mine.vue b/src/components/mine.vue index 3a588a8..07be567 100644 --- a/src/components/mine.vue +++ b/src/components/mine.vue @@ -4,11 +4,7 @@ - {{ - !isLoginStatus - ? "未登录用户" - : maskPhoneNumber(Session.get("userPhone")) - }} + {{ !isLoginStatus ? "未登录用户" : maskPhoneNumber(Session.get("userPhone")) }} - {{ - !isLoginStatus ? "点击登录" : "退出登录" - }} + {{ !isLoginStatus ? "点击登录" : "退出登录" }} @@ -127,6 +121,8 @@ import like from "@/assets/images/like.png"; import time from "@/assets/images/time.png"; import vip from "@/assets/images/vip.png"; import { useShareStore } from "@/stores/shareStore"; +import { doLogout } from "@/api"; + const stores = useShareStore(); const curPages = getCurrentPages(); @@ -177,6 +173,9 @@ const loginOut = () => { icon: "none", duration: 1500, }); + doLogout({ + financialAccount: Session.get("userPhone"), + }); // 清除 cookie Session.clear(); uni.removeStorageSync("subStatus"); diff --git a/src/pages/realtimeInfo/index.vue b/src/pages/realtimeInfo/index.vue index 9a97740..42007ff 100644 --- a/src/pages/realtimeInfo/index.vue +++ b/src/pages/realtimeInfo/index.vue @@ -58,8 +58,7 @@ - + @@ -67,9 +66,7 @@
- + {{ chooseDate.startDate.split(" ")[0] }} @@ -84,8 +81,7 @@ - + 查看全部 @@ -97,8 +93,7 @@ - + 查看全部 @@ -111,12 +106,24 @@ 退出登录 - + - + @@ -284,8 +291,12 @@ const handlePopupSuccessCallback = () => { const handlePopupErrorCallback = () => { console.log("登录失败"); }; - +import { doLogout } from "@/api"; function loginOut() { + doLogout({ + financialAccount: Session.get("userPhone"), + }); + Session.clear(); window.location.reload(); } @@ -305,8 +316,8 @@ onMounted(async () => { const { aplus_queue } = window; aplus_queue.push({ - action: 'aplus.sendPV', - arguments: [{ is_auto: false }] // 此处上报的数据暂时在后台没有展示 + action: "aplus.sendPV", + arguments: [{ is_auto: false }], // 此处上报的数据暂时在后台没有展示 }); }); diff --git a/src/pages/realtimeInfo/indexRelease.vue b/src/pages/realtimeInfo/indexRelease.vue index 307e1bd..8687f43 100644 --- a/src/pages/realtimeInfo/indexRelease.vue +++ b/src/pages/realtimeInfo/indexRelease.vue @@ -98,8 +98,12 @@ 退出登录 - + @@ -243,8 +247,11 @@ const handlePopupSuccessCallback = () => { const handlePopupErrorCallback = () => { console.log("登录失败"); }; - +import { doLogout } from "@/api"; function loginOut() { + doLogout({ + financialAccount: Session.get("userPhone"), + }); Session.clear(); window.location.reload(); } @@ -260,7 +267,7 @@ async function getLineDataFn() { if (lineTabIndex.value == 0) { // 行业 getTopIndustryPeriod({ - start_time: dayjs().subtract(7, 'day').format("YYYY-MM-DD"), + start_time: dayjs().subtract(7, "day").format("YYYY-MM-DD"), end_time: dayjs().format("YYYY-MM-DD"), limit_num: 10, }).then((res) => { @@ -269,7 +276,7 @@ async function getLineDataFn() { } else if (lineTabIndex.value == 1) { // 概念 getTopConceptPeriod({ - start_time: dayjs().subtract(7, 'day').format("YYYY-MM-DD"), + start_time: dayjs().subtract(7, "day").format("YYYY-MM-DD"), end_time: dayjs().format("YYYY-MM-DD"), limit_num: 10, }).then((res) => { @@ -278,7 +285,7 @@ async function getLineDataFn() { } else if (lineTabIndex.value == 2) { // 媒体 getTopSourcePeriod({ - start_time: dayjs().subtract(7, 'day').format("YYYY-MM-DD"), + start_time: dayjs().subtract(7, "day").format("YYYY-MM-DD"), end_time: dayjs().format("YYYY-MM-DD"), limit_num: 10, }).then((res) => { @@ -308,10 +315,9 @@ onMounted(async () => { } getLineDataFn(); - aplus_queue.push({ - action: 'aplus.sendPV', - arguments: [{ is_auto: false }] // 此处上报的数据暂时在后台没有展示 + action: "aplus.sendPV", + arguments: [{ is_auto: false }], // 此处上报的数据暂时在后台没有展示 }); }); diff --git a/src/pages/realtimeInfo/pc/components/PageTop.vue b/src/pages/realtimeInfo/pc/components/PageTop.vue index 132bf98..ce46b65 100644 --- a/src/pages/realtimeInfo/pc/components/PageTop.vue +++ b/src/pages/realtimeInfo/pc/components/PageTop.vue @@ -34,7 +34,7 @@ import { ref, onMounted, onUnmounted, reactive } from "vue"; import { onLoad, onShow } from "@dcloudio/uni-app"; import { Session } from "@/utils/storage"; - +import { doLogout } from "@/api"; const tabIndex = ref(0); function tabChange(type) { @@ -45,7 +45,11 @@ function tabChange(type) { }); } -function logout() { +async function logout() { + await doLogout({ + financialAccount: Session.get("userPhone"), + }); + Session.clear(); window.location.reload(); } diff --git a/src/utils/index.ts b/src/utils/index.ts index 39f9b96..5606919 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -3,6 +3,7 @@ import type { AxiosResponse } from "axios"; // import { ElMessage, ElMessageBox, ElNotification } from 'element-plus'; import { Session } from "@/utils/storage"; import qs from "qs"; +import { doLogout } from "@/api"; // 配置新建一个 axios 实例 const service = axios.create({ @@ -52,6 +53,9 @@ service.interceptors.response.use( // `token` 过期或者账号已在别处登录 if (res.code === 401 || res.code === 4001) { + doLogout({ + financialAccount: Session.get("userPhone"), + }); Session.clear(); // 清除浏览器全部临时缓存 window.location.href = "/"; // 去登录页 console.log("你已被登出,请重新登录"); diff --git a/src/utils/indexDatav.ts b/src/utils/indexDatav.ts index 12a3cef..4cbcd9e 100644 --- a/src/utils/indexDatav.ts +++ b/src/utils/indexDatav.ts @@ -3,6 +3,7 @@ import type { AxiosResponse } from "axios"; // import { ElMessage, ElMessageBox, ElNotification } from 'element-plus'; import { Session } from "@/utils/storage"; import qs from "qs"; +import { doLogout } from "@/api"; // 配置新建一个 axios 实例 const service = axios.create({ @@ -52,6 +53,9 @@ service.interceptors.response.use( // `token` 过期或者账号已在别处登录 if (res.status === 401 || res.status === 4001) { + doLogout({ + financialAccount: Session.get("userPhone"), + }); Session.clear(); // 清除浏览器全部临时缓存 window.location.href = "/"; // 去登录页 console.log("你已被登出,请重新登录");