oa自动登录

This commit is contained in:
砂糖
2025-07-14 10:04:33 +08:00
parent 94b3ded9fb
commit fc8741c0c1
3 changed files with 87 additions and 103 deletions

View File

@@ -70,8 +70,8 @@ export default {
},
{
idx: 6,
title: "清缓存",
icon: require("static/images/profile_menu_about.png"),
title: "清缓存",
icon: require("static/images/profile_menu_account.png"),
},
{
idx: 7,
@@ -110,6 +110,9 @@ export default {
uni.removeStorage({
key: "BusinessToken",
});
uni.removeStorage({
key: 'oaToken'
})
})
.catch((err) => console.log(err))
.finally(() => {
@@ -178,6 +181,36 @@ export default {
url: `/pages/common/userOrGroupQrCode/index`,
});
},
clearCache() {
uni.showModal({
title: "提示",
content: "确定要清除缓存吗这将清除oaToken等缓存数据。",
confirmText: "确认",
cancelText: "取消",
success: (res) => {
if (res.confirm) {
// 清除oaToken
uni.removeStorage({
key: 'oaToken',
success: () => {
console.log('oaToken已清除');
},
fail: (err) => {
console.log('清除oaToken失败:', err);
}
});
// 可以在这里添加其他需要清除的缓存
// 例如清除其他相关的存储数据
uni.showToast({
icon: "success",
title: "缓存清除成功",
});
}
},
});
},
showUpdateOptions() {
const ignoredVersion = uni.$updateManager.getIgnoredVersion();
let content = '选择更新操作:';
@@ -213,82 +246,6 @@ export default {
}
});
},
clearCache() {
uni.showModal({
title: "清理缓存",
content: "确定要清理应用缓存吗?清理后需要重新登录。",
confirmText: "确认清理",
cancelText: "取消",
success: (res) => {
if (res.confirm) {
uni.showLoading({
title: '清理中...'
});
// 清理本地存储
const clearStorageKeys = [
'IMToken',
'BusinessToken',
'userInfo',
'conversationList',
'messageList',
'contactList'
];
clearStorageKeys.forEach(key => {
try {
uni.removeStorageSync(key);
} catch (e) {
console.log(`清理缓存失败: ${key}`, e);
}
});
// 清理文件缓存
uni.getSavedFileList({
success: (fileRes) => {
if (fileRes.fileList && fileRes.fileList.length > 0) {
fileRes.fileList.forEach(file => {
uni.removeSavedFile({
filePath: file.filePath,
success: () => {
console.log('文件缓存清理成功:', file.filePath);
},
fail: (err) => {
console.log('文件缓存清理失败:', file.filePath, err);
}
});
});
}
},
fail: (err) => {
console.log('获取文件列表失败:', err);
}
});
// 清理图片缓存
uni.getImageInfo({
src: '/static/images/default_avatar.png',
success: () => {
// 这里可以添加更多图片缓存清理逻辑
}
});
setTimeout(() => {
uni.hideLoading();
uni.showToast({
title: '缓存清理完成',
icon: 'success'
});
// 清理完成后跳转到登录页
setTimeout(() => {
uni.$u.route("/pages/login/index");
}, 1500);
}, 1000);
}
}
});
},
},
};
</script>

View File

@@ -24,12 +24,31 @@
<script>
import CustomNavBar from '@/components/CustomNavBar/index.vue';
import { getUserProfile } from '@/api/oa/user.js';
export default {
name: "WorkbenchIndex",
components: {
CustomNavBar,
},
onShow() {
console.log('页面onLoad被调用');
// 页面加载时调用getUserProfile
this.fetchUserProfile();
},
methods: {
// 获取用户个人信息
async fetchUserProfile() {
console.log('fetchUserProfile方法开始执行');
try {
console.log('开始调用getUserProfile API');
const response = await getUserProfile();
console.log('用户个人信息:', response);
// 这里可以根据需要处理返回的用户信息
} catch (error) {
console.error('获取用户个人信息失败:', error);
}
},
goReportWork() {
uni.navigateTo({
url: '/pages/workbench/reportWork/reportWork'
@@ -45,7 +64,7 @@ export default {
url: '/pages/workbench/task/task'
})
}
}
},
};
</script>