Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
frostime committed Jan 21, 2025
2 parents 3ddbd16 + 7ee8f24 commit 3a733d2
Show file tree
Hide file tree
Showing 13 changed files with 667 additions and 402 deletions.
30 changes: 30 additions & 0 deletions auto-i18n.project.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# * `i18n_dir`: The directory for storing translation files
# * `main_file`: The translation file for the main language
# * `code_files`: The types of code files to scan
# * `i18n_pattern`: The pattern to mark text that needs to be translated in the code
# * `dict`: A dictionary of specific terms for translation; you can place specific translations for your project here
# * `strategy`: The translation strategy
# * `"diff"` means only translating new content
# * `"full"` means translating all content
# * `i18n_var_prefix`: The prefix used for replacement variables in the code
# * `export_dir`: The export directory. If set, it will be used as the output directory for the export command.
# * `i18n_var_mid`: The strategy for generating the middle part of the i18n key. Options are:
# * `"filename"`: Uses the full filename, e.g. `testts`
# * `"filename_noext"`: Uses the filename without its extension
# * `"pathname"`: Uses the relative path of the file, replacing '/' with '_'
#
code_files:
- src/**/*.ts
- src/**/*.svelte
dict:
思源: SiYuan
日记: daily note
export_dir: src/types
i18n_dir: src/i18n
i18n_pattern: \(\(`(.+?)`\)\)
i18n_var_mid: filename
i18n_var_prefix: i18n
main_file: zh_CN.yaml
strategy: diff
global_config:
lang: zh_CN
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "siyuan-dailynote-today",
"version": "1.7.1",
"version": "1.7.2",
"description": "",
"main": ".src/index.js",
"keywords": [],
Expand Down
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"en_US": "Daily Note Today"
},
"url": "https://github.com/frostime/siyuan-dailynote-today",
"version": "1.7.1",
"version": "1.7.2",
"minAppVersion": "3.1.7",
"description": {
"zh_CN": "自动创建日记 + 快速打开日记 + 日程 TODO 管理 + 移动块功能",
Expand Down
40 changes: 20 additions & 20 deletions src/components/setting-gui.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
let groups = {
enable: [
{
name: "OpenOnStart",
type: "checkbox",
name: "OpenOnStart",
type: "checkbox",
},
{
name: "EnableMove",
Expand All @@ -28,7 +28,7 @@
{
name: "EnableResvDock",
type: "checkbox",
}
},
],
interact: [
{
Expand All @@ -41,8 +41,8 @@
},
{
name: "ReplaceAlt5Hotkey",
type: "checkbox"
}
type: "checkbox",
},
],
dailynote: [
{
Expand All @@ -51,24 +51,24 @@
},
{
name: "NotebookBlacklist",
type: "button"
type: "button",
},
{
name: "DisableAutoCreateOnMobile",
type: "checkbox"
type: "checkbox",
},
{
name: "SetPastDailyNoteAttr",
type: "button"
},
{
name: "AutoOpenAfterSync",
type: "checkbox"
type: "button",
},
// {
// name: "AutoOpenAfterSync",
// type: "checkbox",
// },
{
name: "AutoHandleDuplicateMethod",
type: "select"
}
type: "select",
},
],
reservation: [
{
Expand All @@ -85,9 +85,9 @@
},
{
name: "HighlightResv",
type: "checkbox"
}
]
type: "checkbox",
},
],
};
let allSettingPanels: {
Expand Down Expand Up @@ -123,7 +123,7 @@
function onClick({ detail }) {
console.log(detail);
let key = detail.key;
if (key === 'NotebookBlacklist') {
if (key === "NotebookBlacklist") {
let dialog = new Dialog({
title: i18n.Blacklist.name,
content: `<div id="blacklist" style="height: 100%;"></div>`,
Expand All @@ -138,12 +138,12 @@
},
},
});
} else if (key === 'SetPastDailyNoteAttr') {
} else if (key === "SetPastDailyNoteAttr") {
setDNAttrDialog();
}
}
</script>

<!-- <SettingPanel dataname="global" {settingItems} />
-->
<SettingPanels panels={allSettingPanels} on:click={onClick}/>
<SettingPanels panels={allSettingPanels} on:click={onClick} />
21 changes: 8 additions & 13 deletions src/func/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class RoutineEventHandler {
hasOpened: false,

openOnStart: false,
autoOpenAfterSync: false,
// autoOpenAfterSync: false,

isSyncChecked: false,
hasCheckSyncFor: 0,
Expand All @@ -47,7 +47,7 @@ export class RoutineEventHandler {
this.eventBus = plugin.eventBus;

this.flag.openOnStart = settings.get('OpenOnStart');
this.flag.autoOpenAfterSync = settings.get('AutoOpenAfterSync');
// this.flag.autoOpenAfterSync = settings.get('AutoOpenAfterSync');

this.checkDuplicateDiary_Debounce = debouncer.debounce(
this.checkDuplicateDiary.bind(this), 2000, 'CheckDuplicateDiary'
Expand All @@ -71,26 +71,21 @@ export class RoutineEventHandler {
if (!SYNC_ENABLED) {
//Case 1: 如果思源没有开启同步, 就直接创建, 并无需绑定同步事件
await this.tryAutoOpenDN();
} else if (this.flag.autoOpenAfterSync === false) {
//Case 2: 如果思源开启了同步, 但是用户没有设置在同步后打开, 就直接创建
this.bindSyncEvent();
await this.tryAutoOpenDN();
} else {
//Case 3: 如果思源开启了同步, 并且用户设置了在同步后打开, 就绑定同步事件
//Case 2: 如果思源开启了同步, 就直接创建并绑定同步事件
this.bindSyncEvent();
await this.tryAutoOpenDN();
}
}
public onPluginUnload() {
this.plugin.eventBus.off('opened-notebook', this.onNotebookChangedBindThis);
this.plugin.eventBus.off('closed-notebook', this.onNotebookChangedBindThis);
}

async onSyncEnd({ detail }) {
console.debug('on-sync-end');

if (this.flag.hasOpened === false && this.flag.autoOpenAfterSync === true) {
this.tryAutoOpenDN();
}
async onSyncEnd() {
// if (this.flag.hasOpened === false && this.flag.autoOpenAfterSync === true) {
// this.tryAutoOpenDN();
// }

if (!this.flag.isSyncChecked) {
this.checkDuplicateDiary_Debounce();
Expand Down
28 changes: 26 additions & 2 deletions src/global-notebooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
* @Author : Yp Z
* @Date : 2023-06-03 23:36:46
* @FilePath : /src/global-notebooks.ts
* @LastEditTime : 2023-08-06 18:07:20
* @LastEditTime : 2024-11-28 23:05:56
* @Description :
*/
import { confirm } from 'siyuan';
import { queryNotebooks } from './func';
import { settings } from './global-status';

import { getBlockByID } from './serverApi';
import { i18n } from './utils';

class Notebooks {
notebooks: Array<Notebook>;
Expand Down Expand Up @@ -76,12 +78,34 @@ class Notebooks {
} else {
// confirm(i18n.Name, `${notebookId} ${i18n.InvalidDefaultNotebook}`);
this.default = undefined;
this.checkCorrectNotebookId(notebookId).then(notebook => {
if (notebook) {
this.default = notebook;
settings.set('DefaultNotebook', notebook.id);
} else {
confirm(i18n.Name, `${notebookId} ${i18n.InvalidDefaultNotebook}`);
}
});
}
} else {
this.default = this.get(0);
}
}

private async checkCorrectNotebookId(notebookId: string) {
const block: Block = await getBlockByID(notebookId);
if (!block) {
return null;
}

let notebook = this.find(block.box);
if (notebook) {
confirm(`${i18n.Name} Warning`, i18n.global_notebooks_ts.invalid_notebook_id_config.replace('{0}', block.content).replace('{1}', notebookId).replace('{2}', block.box));
return notebook;
}
return null;
}

}

const notebooks = new Notebooks();
Expand Down
4 changes: 2 additions & 2 deletions src/global-status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @Author : frostime
* @Date : 2024-05-21 14:14:08
* @FilePath : /src/global-status.ts
* @LastEditTime : 2024-09-26 16:21:06
* @LastEditTime : 2025-01-21 15:01:51
* @Description :
*/
import { eventBus } from './event-bus';
Expand All @@ -26,7 +26,7 @@ class SettingManager {

settings: any = {
OpenOnStart: true as boolean, //启动的时候自动打开日记
AutoOpenAfterSync: false as boolean, //在第一次同步之后再自动打开日记
// AutoOpenAfterSync: false as boolean, //在第一次同步之后再自动打开日记
DefaultNotebook: '', //默认笔记本的 ID
DisableAutoCreateOnMobile: false as boolean, //移动端自动创建日记
IconPosition: 'left' as IconPosition, //图标放置位置
Expand Down
Loading

0 comments on commit 3a733d2

Please sign in to comment.