Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
frostime
siyuan-dailynote-today
提交
3097a85c
S
siyuan-dailynote-today
项目概览
frostime
/
siyuan-dailynote-today
通知
17
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
siyuan-dailynote-today
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
3097a85c
编写于
5月 22, 2023
作者:
frostime
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
插件启动时检查版本
上级
99ec3ef0
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
26 addition
and
20 deletion
+26
-20
src/global-status.ts
src/global-status.ts
+4
-18
src/index.ts
src/index.ts
+22
-2
未找到文件。
src/global-status.ts
浏览文件 @
3097a85c
...
...
@@ -4,12 +4,14 @@
import
{
Plugin
}
from
'
siyuan
'
;
import
{
info
,
error
}
from
'
./utils
'
;
import
{
eventBus
}
from
'
./event-bus
'
;
import
*
as
serverApi
from
'
./serverApi
'
;
type
NotebookSorting
=
'
doc-tree
'
|
'
custom-sort
'
type
IconPosition
=
'
left
'
|
'
right
'
;
type
SettingKey
=
'
OpenOnStart
'
|
'
NotebookSort
'
|
'
DefaultNotebook
'
|
'
IconPosition
'
|
'
DiaryUpToDate
'
;
type
SettingKey
=
(
'
OpenOnStart
'
|
'
NotebookSort
'
|
'
DefaultNotebook
'
|
'
IconPosition
'
|
'
DiaryUpToDate
'
|
'
PluginVersion
'
);
interface
Item
{
key
:
SettingKey
,
...
...
@@ -21,7 +23,6 @@ const SettingFile = 'DailyNoteToday.json.txt';
class
SettingManager
{
plugin
:
Plugin
;
realVersion
:
string
=
''
;
settings
:
any
=
{
OpenOnStart
:
true
as
boolean
,
//启动的时候自动打开日记
DiaryUpToDate
:
false
as
boolean
,
//自动更新日记的日期
...
...
@@ -60,7 +61,6 @@ class SettingManager {
* 导入的时候,需要先加载设置;如果没有设置,则使用默认设置
*/
async
load
()
{
this
.
loadVersion
();
let
loaded
=
await
this
.
plugin
.
loadData
(
SettingFile
);
if
(
loaded
==
null
||
loaded
==
undefined
||
loaded
==
''
)
{
//如果没有配置文件,则使用默认配置,并保存
...
...
@@ -82,20 +82,6 @@ class SettingManager {
}
}
async
loadVersion
()
{
try
{
let
plugin_file
=
await
serverApi
.
getFile
(
'
/data/plugins/siyuan-dailynote-today/plugin.json
'
);
if
(
plugin_file
===
null
)
{
return
;
}
let
version
=
plugin_file
.
version
;
info
(
`插件版本:
${
version
}
`
);
this
.
realVersion
=
version
;
}
catch
(
error_msg
)
{
error
(
`Setting load error:
${
error_msg
}
`
);
}
}
async
save
()
{
let
json
=
JSON
.
stringify
(
this
.
settings
);
info
(
`写入配置文件:
${
json
}
`
);
...
...
src/index.ts
浏览文件 @
3097a85c
/**
* Copyright (c) 2023 frostime. All rights reserved.
*/
import
{
openTab
,
Plugin
}
from
'
siyuan
'
;
import
{
openTab
,
Plugin
,
showMessage
}
from
'
siyuan
'
;
import
Setting
from
'
./components/setting.svelte
'
import
{
ToolbarMenuItem
}
from
'
./components/toolbar-menu
'
;
import
{
notify
,
compareVersion
}
from
'
./func
'
;
import
{
info
,
setI18n
}
from
'
./utils
'
;
import
{
error
,
info
,
setI18n
}
from
'
./utils
'
;
import
{
settings
}
from
'
./global-status
'
;
import
notebooks
from
'
./global-notebooks
'
;
import
{
ContextMenu
}
from
'
./components/move-menu
'
;
...
...
@@ -44,6 +44,8 @@ export default class DailyNoteTodayPlugin extends Plugin {
// });
await
settings
.
load
();
this
.
checkPluginVersion
();
this
.
initSetting
();
this
.
initContextMenu
();
this
.
initToolbarItem
();
...
...
@@ -121,6 +123,24 @@ export default class DailyNoteTodayPlugin extends Plugin {
notify
(
this
.
i18n
.
UpdateAll
,
'
info
'
,
2500
);
}
private
async
checkPluginVersion
()
{
try
{
let
plugin_file
=
await
serverApi
.
getFile
(
'
/data/plugins/siyuan-dailynote-today/plugin.json
'
);
if
(
plugin_file
===
null
)
{
return
;
}
let
version
=
plugin_file
.
version
;
info
(
`插件版本:
${
version
}
`
);
if
(
version
!==
settings
.
get
(
'
PluginVersion
'
))
{
settings
.
set
(
'
PluginVersion
'
,
version
);
notify
(
`
${
this
.
i18n
.
Name
}
: v
${
version
}
`
,
'
info
'
,
1500
);
}
}
catch
(
error_msg
)
{
error
(
`Setting load error:
${
error_msg
}
`
);
}
}
openSetting
():
void
{
openTab
({
custom
:
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录