Skip to content

Commit

Permalink
Merge pull request #109 from frostime/dev
Browse files Browse the repository at this point in the history
增加配置字段
  • Loading branch information
frostime authored Jun 4, 2023
2 parents 3a02dcf + b3423a1 commit 094aa88
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 20 deletions.
14 changes: 9 additions & 5 deletions src/components/libs/reserve.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { i18n, lute } from "../../utils";
import { showMessage, confirm } from "siyuan";
import * as serverApi from "../../serverApi";
import { reservation } from "../../global-status";
import { reservation, settings } from "../../global-status";


const Zh1to9 = '一二三四五六七八九';
Expand Down Expand Up @@ -159,10 +159,14 @@ export async function reserveBlock(blockId) {
return;
}

let html = createConfirmDialog(kramdown, resMatch);
confirm(`${i18n.ReserveMenu.Title}: ${resDate.toLocaleDateString()}?`, html
, () => doReserveBlock(blockId, resDate)
);
if (settings.get('PopupReserveDialog')) {
let html = createConfirmDialog(kramdown, resMatch);
confirm(`${i18n.ReserveMenu.Title}: ${resDate.toLocaleDateString()}?`, html
, () => doReserveBlock(blockId, resDate)
);
} else {
doReserveBlock(blockId, resDate);
}
}

/**
Expand Down
14 changes: 4 additions & 10 deletions src/components/setting.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,13 @@
import { onDestroy, onMount } from "svelte";
import { settings } from "../global-status";
import { i18n } from "../utils";
import {eventBus} from "../event-bus";
import SettingItem from "./setting-item.svelte";
let checked = settings.get("OpenOnStart");
let defaultNotebook = settings.get("DefaultNotebook");
let iconPosition = settings.get("IconPosition");
let contents = i18n.Setting;
function onClick() {
eventBus.publish("UpdateAll");
}
onMount(() => {
console.log("Setting Svelte Mounted");
});
Expand Down Expand Up @@ -68,10 +63,9 @@
settingValue={settings.get("ExpandGutterMenu")}
/>
<SettingItem
type="button"
content={contents.update}
settingKey="Update"
settingValue={""}
on:click={onClick}
type="checkbox"
content={contents.PopupReserveDialog}
settingKey="PopupReserveDialog"
settingValue={settings.get("PopupReserveDialog")}
/>
</div>
10 changes: 5 additions & 5 deletions src/global-status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type IconPosition = 'left' | 'right';
type SettingKey = (
'OpenOnStart' | 'DefaultNotebook' | 'IconPosition' |
'DiaryUpToDate' | 'PluginVersion' | "EnableMove" |
'EnableReserve' | "ExpandGutterMenu"
'EnableReserve' | "ExpandGutterMenu" | 'PopupReserveDialog'
);

interface Item {
Expand All @@ -32,10 +32,10 @@ class SettingManager {
DefaultNotebook: '', //默认笔记本的 ID
IconPosition: 'left' as IconPosition, //图标放置位置
PluginVersion: '',
EnableMove: false as boolean,
EnableReserve: false as boolean,
ExpandGutterMenu: true as boolean //是否将菜单项目展开

EnableMove: true as boolean,
EnableReserve: true as boolean,
ExpandGutterMenu: true as boolean, //是否将菜单项目展开
PopupReserveDialog: true as boolean //是否弹出预约对话框
};

constructor() {
Expand Down
2 changes: 2 additions & 0 deletions src/i18n/CHANGELOG_en_US-1.1.2.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ This minor update mainly optimizes some feature details, see [Milestone V1.1.2](
- Cancelling reservation: When tapping on the menu of a block that is already booked, the button that says 'Reserve this block' will now say 'Cancel reservation'
- Expand the feature menu to show by default: The new version of SiYuan now organises all of the plugin's menus under a secondary menu. The plugin now expands all function menus by default under the secondary menu of 'Plugins' instead of the tertiary menu of 'Plugins - Daily Note Today'. This is a configurable option that you can change in the settings.
- Block menu related settings take effect directly. All three of the existing block-related menus take effect directly after the change is made, without the need to restart the plugin.
- Added option to choose whether to display a confirmation window when reserving a block.
- Removed "Update All" button from settings.

#### Fix

Expand Down
2 changes: 2 additions & 0 deletions src/i18n/CHANGELOG_zh_CN-1.1.2.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
- 取消预约:现在点开一个已经预约的块的菜单,原本「预约此块」的按钮会变成「取消预约」
- 默认将功能菜单展开显示:新版本的 SiYuan 现在把所有插件的菜单全部收纳到一个二级菜单下。现在插件会默认把所有的功能菜单全部展开在「插件」的二级菜单下,而非「插件-今日笔记」的三级菜单下。这是一个可配置的选项,你可以在设置中更改。
- 块菜单相关设置直接生效。目前已有的三个和块相关的菜单都在更改后直接生效,不需要再重启插件。
- 增加设置,可以选择预约块时是否弹出确认窗口
- 去掉了设置中「更新全部」的按钮

#### Fix

Expand Down
4 changes: 4 additions & 0 deletions src/i18n/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@
"ExpandGutterMenu": {
"title": "Expand all block menu items",
"text": "When enabled, the plugin's block menu items are expanded to appear as a separate secondary menu under the plugin menu"
},
"PopupReserveDialog": {
"title": "Popup Confirmation Window When Reserving a Block",
"text": "Automatically displays a confirmation window when reserving a block to ensure the date is correct."
}
},
"Open": "Open daily note",
Expand Down
4 changes: 4 additions & 0 deletions src/i18n/zh_CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@
"ExpandGutterMenu": {
"title": "将所有块菜单项目展开",
"text": "启用后, 插件的块菜单项目都会展开到插件菜单下作为独立的二级菜单显示"
},
"PopupReserveDialog": {
"title": "预约块时弹出确认窗口",
"text": "预约块的时候自动弹出确认窗口, 确保日期无误"
}
},
"Open": "打开日记",
Expand Down

0 comments on commit 094aa88

Please sign in to comment.