mirror of
https://github.com/Wanxp/obsidian-douban.git
synced 2026-04-04 16:48:44 +08:00
fix login error
This commit is contained in:
parent
23daffa699
commit
99eb83d4b5
@ -71,6 +71,11 @@ export const PersonNameModeRecords: { [key in PersonNameMode]: string } = {
|
|||||||
[PersonNameMode.CH_EN_NAME]: i18nHelper.getMessage('121208'),
|
[PersonNameMode.CH_EN_NAME]: i18nHelper.getMessage('121208'),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum SyncType {
|
||||||
|
MY_MOVIE= 'MY_MOVIE',
|
||||||
|
MY_BOOK= 'MY_BOOK',
|
||||||
|
BROADCAST= 'BROADCAST',
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -29,6 +29,9 @@ export default class DoubanLoginModel {
|
|||||||
this.modal.setTitle(i18nHelper.getMessage('100101'));
|
this.modal.setTitle(i18nHelper.getMessage('100101'));
|
||||||
this.modal.show();
|
this.modal.show();
|
||||||
});
|
});
|
||||||
|
this.modal.on('closed', () => {
|
||||||
|
constructDoubanTokenSettingsUI(this.containerEl, this.settingsManager);
|
||||||
|
});
|
||||||
|
|
||||||
const session = this.modal.webContents.session;
|
const session = this.modal.webContents.session;
|
||||||
const filter = {
|
const filter = {
|
||||||
@ -40,10 +43,11 @@ export default class DoubanLoginModel {
|
|||||||
// const wr_name = cookieArr.find((cookie) => cookie.name == 'wr_name').value;
|
// const wr_name = cookieArr.find((cookie) => cookie.name == 'wr_name').value;
|
||||||
if (cookieArr) {
|
if (cookieArr) {
|
||||||
let user = await settingsManager.plugin.userComponent.loginCookie(cookieArr);
|
let user = await settingsManager.plugin.userComponent.loginCookie(cookieArr);
|
||||||
constructDoubanTokenSettingsUI(containerEl, settingsManager);
|
if (user && user.login) {
|
||||||
this.modal.close();
|
this.onClose();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.modal.reload();
|
this.onReload();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -63,4 +67,8 @@ export default class DoubanLoginModel {
|
|||||||
onClose() {
|
onClose() {
|
||||||
this.modal.close();
|
this.modal.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onReload() {
|
||||||
|
this.modal.reload();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,21 +26,26 @@ export default class DoubanLogoutModel {
|
|||||||
this.modal.setTitle(i18nHelper.getMessage('100101'));
|
this.modal.setTitle(i18nHelper.getMessage('100101'));
|
||||||
this.modal.show();
|
this.modal.show();
|
||||||
});
|
});
|
||||||
|
this.modal.on('closed', () => {
|
||||||
|
constructDoubanTokenSettingsUI(this.containerEl, this.settingsManager);
|
||||||
|
});
|
||||||
const session = this.modal.webContents.session;
|
const session = this.modal.webContents.session;
|
||||||
const filter = {
|
const filter = {
|
||||||
urls: ['https://www.douban.com/']
|
urls: ['https://www.douban.com/',
|
||||||
|
'https://www.douban.com/accounts/logout']
|
||||||
};
|
};
|
||||||
session.webRequest.onCompleted(filter, (details:any) => {
|
session.webRequest.onSendHeaders(filter, (details:any) => {
|
||||||
if (details.statusCode == 200) {
|
const cookies = details.requestHeaders['Cookie'];
|
||||||
|
// const wr_name = cookieArr.find((cookie) => cookie.name == 'wr_name').value;
|
||||||
|
if (cookies && cookies.indexOf('dbcl2') < 0) {
|
||||||
this.settingsManager.plugin.userComponent.logout();
|
this.settingsManager.plugin.userComponent.logout();
|
||||||
constructDoubanTokenSettingsUI(this.containerEl, this.settingsManager);
|
this.onClose();
|
||||||
this.modal.close();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async doLogout() {
|
async doLogout() {
|
||||||
await this.modal.loadURL('https://www.douban.com/');
|
await this.modal.loadURL('https://www.douban.com/accounts/logout?source=main&ck=DfFJ');
|
||||||
}
|
}
|
||||||
|
|
||||||
onClose() {
|
onClose() {
|
||||||
|
|||||||
57
src/douban/component/DoubanSearchModal.ts
Normal file
57
src/douban/component/DoubanSearchModal.ts
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
import {App, DropdownComponent, Modal, TextComponent} from "obsidian";
|
||||||
|
|
||||||
|
import DoubanPlugin from "main";
|
||||||
|
import {i18nHelper} from "src/lang/helper";
|
||||||
|
import HandleContext from "@App/data/model/HandleContext";
|
||||||
|
|
||||||
|
export class DoubanSearchModal extends Modal {
|
||||||
|
searchTerm: string;
|
||||||
|
plugin: DoubanPlugin;
|
||||||
|
context: HandleContext
|
||||||
|
|
||||||
|
constructor(app: App, plugin: DoubanPlugin, context: HandleContext) {
|
||||||
|
super(app);
|
||||||
|
this.plugin = plugin;
|
||||||
|
this.context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
onOpen() {
|
||||||
|
let {contentEl} = this;
|
||||||
|
|
||||||
|
contentEl.createEl("h3", {text: i18nHelper.getMessage('500001')});
|
||||||
|
|
||||||
|
const inputs = contentEl.createDiv("inputs");
|
||||||
|
|
||||||
|
// const syncTypeDropdown = new DropdownComponent(contentEl)
|
||||||
|
// .addOptions();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const controls = contentEl.createDiv("controls");
|
||||||
|
const searchButton = controls.createEl("button", {
|
||||||
|
text: i18nHelper.getMessage('110004'),
|
||||||
|
cls: "mod-cta",
|
||||||
|
attr: {
|
||||||
|
autofocus: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
searchButton.addClass("obsidian_douban_search_button");
|
||||||
|
|
||||||
|
searchButton.addEventListener("click", this.close.bind(this));
|
||||||
|
const cancelButton = controls.createEl("button", {text: i18nHelper.getMessage('110005')});
|
||||||
|
cancelButton.addEventListener("click", this.close.bind(this));
|
||||||
|
cancelButton.addClass("obsidian_douban_search_button");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async onClose() {
|
||||||
|
let {contentEl} = this;
|
||||||
|
contentEl.empty();
|
||||||
|
if (this.searchTerm) {
|
||||||
|
await this.plugin.search(this.searchTerm, this.context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -153,7 +153,6 @@ ${i18nHelper.getMessage('100125')}`;
|
|||||||
button.setDisabled(true);
|
button.setDisabled(true);
|
||||||
const loginModel = new DoubanLogoutModel(containerEl, manager);
|
const loginModel = new DoubanLogoutModel(containerEl, manager);
|
||||||
await loginModel.doLogout();
|
await loginModel.doLogout();
|
||||||
button.setDisabled(false);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -180,6 +179,7 @@ ${i18nHelper.getMessage('100125')}`;
|
|||||||
.setButtonText(i18nHelper.getMessage('100128'))
|
.setButtonText(i18nHelper.getMessage('100128'))
|
||||||
.setCta()
|
.setCta()
|
||||||
.onClick(async () => {
|
.onClick(async () => {
|
||||||
|
button.setDisabled(true);
|
||||||
manager.updateSetting('loginCookiesContent', '');
|
manager.updateSetting('loginCookiesContent', '');
|
||||||
constructDoubanTokenSettingsUI(containerEl, manager);
|
constructDoubanTokenSettingsUI(containerEl, manager);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -403,6 +403,10 @@ export default {
|
|||||||
'160229': `Comment`,
|
'160229': `Comment`,
|
||||||
'160230': `Rate Date`,
|
'160230': `Rate Date`,
|
||||||
|
|
||||||
|
|
||||||
|
'500001': `Sync Config`,
|
||||||
|
|
||||||
|
|
||||||
'ALL': `all`,
|
'ALL': `all`,
|
||||||
'MOVIE': `movie`,
|
'MOVIE': `movie`,
|
||||||
'BOOK': `book`,
|
'BOOK': `book`,
|
||||||
|
|||||||
@ -426,6 +426,7 @@ export default {
|
|||||||
'160229': `我的评论`,
|
'160229': `我的评论`,
|
||||||
'160230': `我的评论/标记的日期`,
|
'160230': `我的评论/标记的日期`,
|
||||||
|
|
||||||
|
'500001': `同步设置`,
|
||||||
|
|
||||||
|
|
||||||
'ALL': `全部类型`,
|
'ALL': `全部类型`,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user