Skip to content

Commit

Permalink
🔥 rm: 删除 AutoOpenAfterSync
Browse files Browse the repository at this point in the history
  • Loading branch information
frostime committed Jan 21, 2025
1 parent 5ee19cf commit 7ee8f24
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 45 deletions.
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
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
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ export default class DailyNoteTodayPlugin extends Plugin {
//@ts-ignore
title: `${this.i18n.Name}`,
content: `<div id="SettingPanel" style="height: 100%"></div>`,
width: '50%',
height: '27rem',
width: '54rem',
height: '36rem',
destroyCallback: () => {
pannel.$destroy();
}
Expand Down
37 changes: 29 additions & 8 deletions src/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,35 @@ type doOperation = {
retData: null;
}

type SettingKey = (
'OpenOnStart' | 'DefaultNotebook' | 'IconPosition' |
'PluginVersion' | "EnableMove" | 'EnableReserve' |
"ExpandGutterMenu" | 'PopupReserveDialog' | 'ResvEmbedAt' |
'RetvType' | 'EnableResvDock' | 'DisableAutoCreateOnMobile' |
'NotebookBlacklist' | 'AutoOpenAfterSync' | 'HighlightResv' |
'AutoHandleDuplicateMethod' | 'ReplaceAlt5Hotkey'
);
type SettingKey =
// App behavior settings
| 'OpenOnStart'
// | 'AutoOpenAfterSync'
| 'DisableAutoCreateOnMobile'

// Notebook settings
| 'DefaultNotebook'
| 'NotebookBlacklist'

// UI settings
| 'IconPosition'
| 'ExpandGutterMenu'
| 'PopupReserveDialog'
| 'HighlightResv'

// Feature toggles
| 'EnableMove'
| 'EnableReserve'
| 'EnableResvDock'

// Reservation settings
| 'ResvEmbedAt'
| 'RetvType'

// System settings
| 'PluginVersion'
| 'ReplaceAlt5Hotkey'
| 'AutoHandleDuplicateMethod';

interface ISettingItem {
type: string;
Expand Down

0 comments on commit 7ee8f24

Please sign in to comment.