完成跳转页面权限校验
This commit is contained in:
parent
e34711793e
commit
2600624049
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"manifest_version": 3,
|
"manifest_version": 3,
|
||||||
"name": "渠道应用开发部知识库",
|
"name": "渠道应用开发部知识库",
|
||||||
"version": "2.0.2",
|
"version": "2.0.3",
|
||||||
"description": "通过关键词快速搜索内部文档",
|
"description": "通过关键词快速搜索内部文档",
|
||||||
"permissions": ["storage"],
|
"permissions": ["storage"],
|
||||||
"host_permissions": [
|
"host_permissions": [
|
||||||
|
|||||||
@ -6,4 +6,5 @@
|
|||||||
| 2025.06.02 | V2.0.0 | Luke.Ye | 完成插件配置化改造 |
|
| 2025.06.02 | V2.0.0 | Luke.Ye | 完成插件配置化改造 |
|
||||||
| 2025.06.03 | V2.0.1 | Luke.Ye | 完成llm token过期时间的配置化 |
|
| 2025.06.03 | V2.0.1 | Luke.Ye | 完成llm token过期时间的配置化 |
|
||||||
| 2025.06.03 | V2.0.2 | Luke.Ye | 支持LLM工作区配置化 |
|
| 2025.06.03 | V2.0.2 | Luke.Ye | 支持LLM工作区配置化 |
|
||||||
|
| 2025.06.06 | V2.0.3 | Luke.Ye | 添加跳转页面权限校验 |
|
||||||
|
|
||||||
|
|||||||
@ -1,9 +1,24 @@
|
|||||||
function handleLogout() {
|
async function handleLogout(auth) {
|
||||||
|
let token = auth ? auth.token : null;
|
||||||
|
const mergedConfig = await loadMergedConfig();
|
||||||
|
const logoutConf = mergedConfig.apiConfig.logout || {};
|
||||||
|
try {
|
||||||
|
await fetch(logoutConf.url, {
|
||||||
|
method: "POST",
|
||||||
|
credentials: "include", // 关键:带 cookie
|
||||||
|
headers: token ? { "Authorization": token } : {}
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
log("handleLogout error", e);
|
||||||
|
// 可以忽略网络异常,保证前端继续登出流程
|
||||||
|
}
|
||||||
|
|
||||||
chrome.storage.local.remove(["token", "loginAt", "username"], () => {
|
chrome.storage.local.remove(["token", "loginAt", "username"], () => {
|
||||||
window.location.href = chrome.runtime.getURL("pages/login.html");
|
window.location.href = chrome.runtime.getURL("pages/login.html");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async function loadToken() {
|
async function loadToken() {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
chrome.storage.local.get(["token", "username", "loginAt"], async (res) => {
|
chrome.storage.local.get(["token", "username", "loginAt"], async (res) => {
|
||||||
|
|||||||
@ -35,6 +35,12 @@ const defaultConfig = {
|
|||||||
{ label: "用户名字段", field: "username" }
|
{ label: "用户名字段", field: "username" }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
logout: {
|
||||||
|
name: "登出接口",
|
||||||
|
url: "http://app.wisdompulse.cn/api/v1/user/logout",
|
||||||
|
requestParams: [],
|
||||||
|
responseParams: []
|
||||||
|
},
|
||||||
filePath: {
|
filePath: {
|
||||||
name: "获取文件路径接口(批量)",
|
name: "获取文件路径接口(批量)",
|
||||||
url: "http://app.wisdompulse.cn/search/file-path",
|
url: "http://app.wisdompulse.cn/search/file-path",
|
||||||
|
|||||||
@ -76,7 +76,7 @@ document.addEventListener("DOMContentLoaded", async () => {
|
|||||||
let config = await loadMergedConfig();
|
let config = await loadMergedConfig();
|
||||||
|
|
||||||
const auth = await loadToken();
|
const auth = await loadToken();
|
||||||
if (!auth) return handleLogout();
|
if (!auth) return handleLogout(auth);
|
||||||
token = auth.token;
|
token = auth.token;
|
||||||
userNameLabel.textContent = auth.username;
|
userNameLabel.textContent = auth.username;
|
||||||
|
|
||||||
@ -249,7 +249,7 @@ document.addEventListener("DOMContentLoaded", async () => {
|
|||||||
chrome.storage.local.remove("searchHistory", () => renderHistoryTags());
|
chrome.storage.local.remove("searchHistory", () => renderHistoryTags());
|
||||||
});
|
});
|
||||||
|
|
||||||
logoutBtn?.addEventListener("click", () => handleLogout());
|
logoutBtn?.addEventListener("click", () => handleLogout(auth));
|
||||||
userAvatar?.addEventListener("click", () => {
|
userAvatar?.addEventListener("click", () => {
|
||||||
userDropdown.classList.toggle("hidden");
|
userDropdown.classList.toggle("hidden");
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user