♻️ Refactor configuration service
This commit is contained in:
@@ -155,14 +155,30 @@ export class Document {
|
||||
*/
|
||||
export class DocumentConfig {
|
||||
/**
|
||||
* 详细保存选项
|
||||
* 自动保存延迟(毫秒)- 内容变更后多久自动保存
|
||||
*/
|
||||
"saveOptions": SaveOptions;
|
||||
"autoSaveDelay": number;
|
||||
|
||||
/**
|
||||
* 变更字符阈值,超过此阈值立即触发保存
|
||||
*/
|
||||
"changeThreshold": number;
|
||||
|
||||
/**
|
||||
* 最小保存间隔(毫秒)- 两次保存之间的最小时间间隔,避免频繁IO
|
||||
*/
|
||||
"minSaveInterval": number;
|
||||
|
||||
/** Creates a new DocumentConfig instance. */
|
||||
constructor($$source: Partial<DocumentConfig> = {}) {
|
||||
if (!("saveOptions" in $$source)) {
|
||||
this["saveOptions"] = (new SaveOptions());
|
||||
if (!("autoSaveDelay" in $$source)) {
|
||||
this["autoSaveDelay"] = 0;
|
||||
}
|
||||
if (!("changeThreshold" in $$source)) {
|
||||
this["changeThreshold"] = 0;
|
||||
}
|
||||
if (!("minSaveInterval" in $$source)) {
|
||||
this["minSaveInterval"] = 0;
|
||||
}
|
||||
|
||||
Object.assign(this, $$source);
|
||||
@@ -172,11 +188,7 @@ export class DocumentConfig {
|
||||
* Creates a new DocumentConfig instance from a string or object.
|
||||
*/
|
||||
static createFrom($$source: any = {}): DocumentConfig {
|
||||
const $$createField0_0 = $$createType5;
|
||||
let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source;
|
||||
if ("saveOptions" in $$parsedSource) {
|
||||
$$parsedSource["saveOptions"] = $$createField0_0($$parsedSource["saveOptions"]);
|
||||
}
|
||||
return new DocumentConfig($$parsedSource as Partial<DocumentConfig>);
|
||||
}
|
||||
}
|
||||
@@ -323,11 +335,6 @@ export enum LanguageType {
|
||||
* PathsConfig 路径配置集合
|
||||
*/
|
||||
export class PathsConfig {
|
||||
/**
|
||||
* 日志文件路径
|
||||
*/
|
||||
"logPath": string;
|
||||
|
||||
/**
|
||||
* 数据存储路径
|
||||
*/
|
||||
@@ -335,9 +342,6 @@ export class PathsConfig {
|
||||
|
||||
/** Creates a new PathsConfig instance. */
|
||||
constructor($$source: Partial<PathsConfig> = {}) {
|
||||
if (!("logPath" in $$source)) {
|
||||
this["logPath"] = "";
|
||||
}
|
||||
if (!("dataPath" in $$source)) {
|
||||
this["dataPath"] = "";
|
||||
}
|
||||
@@ -354,49 +358,6 @@ export class PathsConfig {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* SaveOptions 保存选项
|
||||
*/
|
||||
export class SaveOptions {
|
||||
/**
|
||||
* 自动保存延迟(毫秒)- 内容变更后多久自动保存
|
||||
*/
|
||||
"autoSaveDelay": number;
|
||||
|
||||
/**
|
||||
* 变更字符阈值,超过此阈值立即触发保存
|
||||
*/
|
||||
"changeThreshold": number;
|
||||
|
||||
/**
|
||||
* 最小保存间隔(毫秒)- 两次保存之间的最小时间间隔,避免频繁IO
|
||||
*/
|
||||
"minSaveInterval": number;
|
||||
|
||||
/** Creates a new SaveOptions instance. */
|
||||
constructor($$source: Partial<SaveOptions> = {}) {
|
||||
if (!("autoSaveDelay" in $$source)) {
|
||||
this["autoSaveDelay"] = 0;
|
||||
}
|
||||
if (!("changeThreshold" in $$source)) {
|
||||
this["changeThreshold"] = 0;
|
||||
}
|
||||
if (!("minSaveInterval" in $$source)) {
|
||||
this["minSaveInterval"] = 0;
|
||||
}
|
||||
|
||||
Object.assign(this, $$source);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new SaveOptions instance from a string or object.
|
||||
*/
|
||||
static createFrom($$source: any = {}): SaveOptions {
|
||||
let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source;
|
||||
return new SaveOptions($$parsedSource as Partial<SaveOptions>);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* TabType 定义了制表符类型
|
||||
*/
|
||||
@@ -423,4 +384,3 @@ const $$createType1 = DocumentConfig.createFrom;
|
||||
const $$createType2 = PathsConfig.createFrom;
|
||||
const $$createType3 = ConfigMetadata.createFrom;
|
||||
const $$createType4 = DocumentMeta.createFrom;
|
||||
const $$createType5 = SaveOptions.createFrom;
|
||||
|
@@ -2,7 +2,7 @@
|
||||
// This file is automatically generated. DO NOT EDIT
|
||||
|
||||
/**
|
||||
* ConfigService 提供配置管理功能
|
||||
* ConfigService 提供基于 Viper 的配置管理功能
|
||||
* @module
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,14 @@ import {Call as $Call, Create as $Create} from "@wailsio/runtime";
|
||||
// @ts-ignore: Unused imports
|
||||
import * as models$0 from "../models/models.js";
|
||||
|
||||
/**
|
||||
* Get 获取配置项
|
||||
*/
|
||||
export function Get(key: string): Promise<any> & { cancel(): void } {
|
||||
let $resultPromise = $Call.ByID(807201772, key) as any;
|
||||
return $resultPromise;
|
||||
}
|
||||
|
||||
/**
|
||||
* GetConfig 获取完整应用配置
|
||||
*/
|
||||
@@ -26,50 +34,6 @@ export function GetConfig(): Promise<models$0.AppConfig | null> & { cancel(): vo
|
||||
return $typingPromise;
|
||||
}
|
||||
|
||||
/**
|
||||
* GetEditorConfig 获取编辑器配置
|
||||
*/
|
||||
export function GetEditorConfig(): Promise<models$0.EditorConfig> & { cancel(): void } {
|
||||
let $resultPromise = $Call.ByID(3648153351) as any;
|
||||
let $typingPromise = $resultPromise.then(($result: any) => {
|
||||
return $$createType2($result);
|
||||
}) as any;
|
||||
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
|
||||
return $typingPromise;
|
||||
}
|
||||
|
||||
/**
|
||||
* GetLanguage 获取当前语言设置
|
||||
*/
|
||||
export function GetLanguage(): Promise<models$0.LanguageType> & { cancel(): void } {
|
||||
let $resultPromise = $Call.ByID(3409375894) as any;
|
||||
return $resultPromise;
|
||||
}
|
||||
|
||||
/**
|
||||
* GetMetadata 获取配置元数据
|
||||
*/
|
||||
export function GetMetadata(): Promise<models$0.ConfigMetadata> & { cancel(): void } {
|
||||
let $resultPromise = $Call.ByID(3276720617) as any;
|
||||
let $typingPromise = $resultPromise.then(($result: any) => {
|
||||
return $$createType3($result);
|
||||
}) as any;
|
||||
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
|
||||
return $typingPromise;
|
||||
}
|
||||
|
||||
/**
|
||||
* GetPaths 获取路径配置
|
||||
*/
|
||||
export function GetPaths(): Promise<models$0.PathsConfig> & { cancel(): void } {
|
||||
let $resultPromise = $Call.ByID(1096257096) as any;
|
||||
let $typingPromise = $resultPromise.then(($result: any) => {
|
||||
return $$createType4($result);
|
||||
}) as any;
|
||||
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
|
||||
return $typingPromise;
|
||||
}
|
||||
|
||||
/**
|
||||
* ResetConfig 重置为默认配置
|
||||
*/
|
||||
@@ -79,48 +43,13 @@ export function ResetConfig(): Promise<void> & { cancel(): void } {
|
||||
}
|
||||
|
||||
/**
|
||||
* SaveConfig 保存完整应用配置
|
||||
* Set 设置配置项
|
||||
*/
|
||||
export function SaveConfig(config: models$0.AppConfig | null): Promise<void> & { cancel(): void } {
|
||||
let $resultPromise = $Call.ByID(616684383, config) as any;
|
||||
return $resultPromise;
|
||||
}
|
||||
|
||||
/**
|
||||
* SetLanguage 设置语言
|
||||
*/
|
||||
export function SetLanguage(language: models$0.LanguageType): Promise<void> & { cancel(): void } {
|
||||
let $resultPromise = $Call.ByID(814725002, language) as any;
|
||||
return $resultPromise;
|
||||
}
|
||||
|
||||
/**
|
||||
* UpdateEditorConfig 更新编辑器配置
|
||||
*/
|
||||
export function UpdateEditorConfig(editorConfig: models$0.EditorConfig): Promise<void> & { cancel(): void } {
|
||||
let $resultPromise = $Call.ByID(1237949666, editorConfig) as any;
|
||||
return $resultPromise;
|
||||
}
|
||||
|
||||
/**
|
||||
* UpdateMetadata 更新配置元数据
|
||||
*/
|
||||
export function UpdateMetadata(metadata: models$0.ConfigMetadata): Promise<void> & { cancel(): void } {
|
||||
let $resultPromise = $Call.ByID(3353893284, metadata) as any;
|
||||
return $resultPromise;
|
||||
}
|
||||
|
||||
/**
|
||||
* UpdatePaths 更新路径配置
|
||||
*/
|
||||
export function UpdatePaths(paths: models$0.PathsConfig): Promise<void> & { cancel(): void } {
|
||||
let $resultPromise = $Call.ByID(3650847675, paths) as any;
|
||||
export function Set(key: string, value: any): Promise<void> & { cancel(): void } {
|
||||
let $resultPromise = $Call.ByID(2921955968, key, value) as any;
|
||||
return $resultPromise;
|
||||
}
|
||||
|
||||
// Private type creation functions
|
||||
const $$createType0 = models$0.AppConfig.createFrom;
|
||||
const $$createType1 = $Create.Nullable($$createType0);
|
||||
const $$createType2 = models$0.EditorConfig.createFrom;
|
||||
const $$createType3 = models$0.ConfigMetadata.createFrom;
|
||||
const $$createType4 = models$0.PathsConfig.createFrom;
|
||||
|
Reference in New Issue
Block a user