Skip to content

Commit

Permalink
Merge pull request #773 from obgnail/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
obgnail authored Oct 1, 2024
2 parents 4a925b9 + a66ec54 commit e10c2cf
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 22 deletions.
7 changes: 4 additions & 3 deletions plugin/custom/plugins/reopenClosedFiles/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,18 @@ class reopenClosedFilesPlugin extends BaseCustomPlugin {
if (!this.windowTabBarPlugin) return;
await this.ensureFile();
if (this.config.auto_reopen_when_init) {
// 因为打开特定文件时,不能重定向(isDiscardableUntitled为false)
this.utils.loopDetector(this.utils.isDiscardableUntitled, this.callback, 40, 2000, false);
}
this.utils.eventHub.addEventListener(this.utils.eventHub.eventType.fileContentLoaded, this.save);
setTimeout(() => this.utils.eventHub.addEventListener(this.utils.eventHub.eventType.fileContentLoaded, this.save), 2500);
})
}

save = async () => this.windowTabBarPlugin && this.windowTabBarPlugin.saveTabs(this.saveFile)
save = async () => this.windowTabBarPlugin && this.windowTabBarPlugin.saveTabs(this.saveFile);

ensureFile = async () => await this.utils.Package.FsExtra.ensureFile(this.saveFile);

callback = anchorNode => this.windowTabBarPlugin && this.windowTabBarPlugin.openSaveTabs(this.saveFile);
callback = anchorNode => this.windowTabBarPlugin && this.windowTabBarPlugin.openSaveTabs(this.saveFile, true);
}

module.exports = {
Expand Down
4 changes: 2 additions & 2 deletions plugin/global/core/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,8 @@ class utils {
const configList = contentList.map(c => c ? TOML.parse(c) : {});
return configList.reduce(this.merge)
} catch (e) {
const message = "配置文件格式错误,是否前往校验网站";
const detail = `您手动修改过配置文件,由于写入的内容有问题,导致配置文件无法正确读取,报错如下:\n${e.toString()}`;
const message = "配置文件格式错误";
const detail = `您修改过配置文件且写入的内容有问题,导致无法正确读取配置文件。\n\n请点击「确定」前往校验网站手动修复(如果您有 GPT 也可以让它帮您修复)\n\n报错信息:${e.toString()}`;
const op = { type: "error", title: "Typora Plugin", buttons: ["确定", "取消"], message, detail };
const { response } = await this.showMessageBox(op);
if (response === 0) {
Expand Down
2 changes: 1 addition & 1 deletion plugin/global/settings/custom_plugin.default.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1115,7 +1115,7 @@ order = 1
hotkey = ""
# 打开Typora(打开可丢弃的无标题的标签时)自动恢复上次退出时尚未关闭的标签页
# 注意:只当双击typora.exe打开Typora时生效(因为打开特定文件时,自动恢复上次退出时尚未关闭的标签页,明显不符合用户预期)
auto_reopen_when_init = false
auto_reopen_when_init = true


############### hotkeyHub ###############
Expand Down
2 changes: 1 addition & 1 deletion plugin/global/settings/settings.default.toml
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ FORMAT_IN_SELECTION_ONLY = false
# 不希望拆分的词组(这些字词内部和前后禁止加空格)
IGNORE_WORDS = []
# 不希望拆分的正则词组(这些正则内部和前后禁止加空格)
IGNORE_PATTERNS = ["<br\\s*/>"]
IGNORE_PATTERNS = ["<br\\s*?/>"]
# 最多连续X个换行符,多余的删除(若为-1,则不使用此功能,推荐为2)
# 举例,为2时:\n\n\n\n【a】\n\n\n\n\n【b】 -> \n\n【a】\n\n【b】
LINE_BREAK_MAX_NUM = -1
Expand Down
Loading

0 comments on commit e10c2cf

Please sign in to comment.