提交 99ec3ef0 编写于 作者: frostime's avatar frostime

启动时读取插件版本

上级 7fc5456c
......@@ -4,6 +4,7 @@
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'
......@@ -19,12 +20,15 @@ const SettingFile = 'DailyNoteToday.json.txt';
class SettingManager {
plugin: Plugin;
realVersion: string = '';
settings: any = {
OpenOnStart: true as boolean, //启动的时候自动打开日记
DiaryUpToDate: false as boolean, //自动更新日记的日期
NotebookSort: 'doc-tree' as NotebookSorting, //笔记本排序方式
DefaultNotebook: '', //默认笔记本的 ID
IconPosition: 'left' as IconPosition //图标放置位置
IconPosition: 'left' as IconPosition, //图标放置位置
PluginVersion: ''
};
constructor() {
......@@ -80,7 +84,13 @@ 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}`);
}
......
......@@ -15,7 +15,6 @@ import * as serverApi from './serverApi';
export default class DailyNoteTodayPlugin extends Plugin {
app: any;
toolbar_item: ToolbarMenuItem;
component_setting: Setting;
......
......@@ -72,3 +72,16 @@ export async function renderSprig(sprig: string) {
export async function version(): Promise<string> {
return request('/api/system/version', {});
}
export async function getFile(path: string): Promise<any> {
let data = {
path: path
}
let url = '/api/file/getFile';
try {
let file = await fetchSyncPost(url, data);
return file;
} catch (error_msg) {
return null;
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册