Skip to content

Commit

Permalink
fix: login & logout failed issue
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaohongxuan committed Aug 6, 2024
1 parent 4ec1ef1 commit 59aa59e
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 38 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "obsidian-weread-plugin",
"name": "Weread",
"version": "0.11.0",
"version": "0.11.1",
"minAppVersion": "0.12.0",
"description": "This is obsidian plugin for Tencent weread.",
"author": "hankzhao",
Expand Down
62 changes: 31 additions & 31 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian-weread-plugin",
"version": "0.11.0",
"version": "0.11.1",
"description": "This is a community plugin for tencent weread (https://r.qq.com)",
"main": "main.ts",
"scripts": {
Expand Down Expand Up @@ -40,7 +40,7 @@
"@types/lodash.pickby": "^4.6.7",
"@types/set-cookie-parser": "^2.4.2",
"crypto-js": "^4.1.1",
"electron": "^28.1.0",
"electron": "^31.3.1",
"lodash.pickby": "^4.6.0",
"node-html-markdown": "^1.2.0",
"nunjucks": "^3.2.3",
Expand Down
12 changes: 12 additions & 0 deletions src/components/wereadLoginModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ export default class WereadLoginModel {
});

const session = this.modal.webContents.session;

const loginFilter = {
urls: ['https://weread.qq.com/api/auth/getLoginInfo?uid=*']
};

session.webRequest.onCompleted(loginFilter, (details) => {
if (details.statusCode == 200) {
console.log('weread login success, redirect to weread shelf');
this.modal.loadURL('https://weread.qq.com/web/shelf')
}
});

const filter = {
urls: ['https://weread.qq.com/web/user?userVid=*']
};
Expand Down
8 changes: 4 additions & 4 deletions src/components/wereadLogoutModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ export default class WereadLoginModel {
show: false
});
this.modal.once('ready-to-show', () => {
this.modal.setTitle('注销微信读书,右上角头像点击退出登录~');
this.modal.setTitle('注销微信读书,点击头像选择->退出登录');
this.modal.show();
});
const session = this.modal.webContents.session;
const filter = {
urls: ['https://weread.qq.com/web/logout']
urls: ['https://weread.qq.com/api/auth/logout']
};
session.webRequest.onCompleted(filter, (details) => {
if (details.statusCode == 200) {
if (details.statusCode == 200 || details.statusCode ==204) {
console.log('weread logout success, clear cookies...');
settingsStore.actions.clearCookies();
this.settingTab.display();
Expand All @@ -33,7 +33,7 @@ export default class WereadLoginModel {
}

async doLogout() {
await this.modal.loadURL('https://weread.qq.com/web/shelf/#logout');
await this.modal.loadURL('https://weread.qq.com');
}

onClose() {
Expand Down

0 comments on commit 59aa59e

Please sign in to comment.