🎨 Refactor save service
This commit is contained in:
@@ -28,11 +28,6 @@ export class AppConfig {
|
||||
*/
|
||||
"metadata": ConfigMetadata;
|
||||
|
||||
/**
|
||||
* 界面语言
|
||||
*/
|
||||
"language": LanguageType;
|
||||
|
||||
/** Creates a new AppConfig instance. */
|
||||
constructor($$source: Partial<AppConfig> = {}) {
|
||||
if (!("editor" in $$source)) {
|
||||
@@ -44,9 +39,6 @@ export class AppConfig {
|
||||
if (!("metadata" in $$source)) {
|
||||
this["metadata"] = (new ConfigMetadata());
|
||||
}
|
||||
if (!("language" in $$source)) {
|
||||
this["language"] = ("" as LanguageType);
|
||||
}
|
||||
|
||||
Object.assign(this, $$source);
|
||||
}
|
||||
@@ -119,7 +111,7 @@ export class EditorConfig {
|
||||
/**
|
||||
* 文件保存的编码
|
||||
*/
|
||||
"encoding": string;
|
||||
"encoding": EncodingType;
|
||||
|
||||
/**
|
||||
* 是否启用Tab缩进
|
||||
@@ -136,13 +128,18 @@ export class EditorConfig {
|
||||
*/
|
||||
"tabType": TabType;
|
||||
|
||||
/**
|
||||
* 界面语言
|
||||
*/
|
||||
"language": LanguageType;
|
||||
|
||||
/** Creates a new EditorConfig instance. */
|
||||
constructor($$source: Partial<EditorConfig> = {}) {
|
||||
if (!("fontSize" in $$source)) {
|
||||
this["fontSize"] = 0;
|
||||
}
|
||||
if (!("encoding" in $$source)) {
|
||||
this["encoding"] = "";
|
||||
this["encoding"] = ("" as EncodingType);
|
||||
}
|
||||
if (!("enableTabIndent" in $$source)) {
|
||||
this["enableTabIndent"] = false;
|
||||
@@ -153,6 +150,9 @@ export class EditorConfig {
|
||||
if (!("tabType" in $$source)) {
|
||||
this["tabType"] = ("" as TabType);
|
||||
}
|
||||
if (!("language" in $$source)) {
|
||||
this["language"] = ("" as LanguageType);
|
||||
}
|
||||
|
||||
Object.assign(this, $$source);
|
||||
}
|
||||
@@ -166,6 +166,56 @@ export class EditorConfig {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* EncodingType 定义文件编码格式类型
|
||||
*/
|
||||
export enum EncodingType {
|
||||
/**
|
||||
* The Go zero value for the underlying type of the enum.
|
||||
*/
|
||||
$zero = "",
|
||||
|
||||
/**
|
||||
* EncodingUTF8 UTF-8编码
|
||||
*/
|
||||
EncodingUTF8 = "UTF-8",
|
||||
|
||||
/**
|
||||
* EncodingUTF8BOM UTF-8带BOM编码
|
||||
*/
|
||||
EncodingUTF8BOM = "UTF-8-BOM",
|
||||
|
||||
/**
|
||||
* EncodingUTF16LE UTF-16小端编码
|
||||
*/
|
||||
EncodingUTF16LE = "UTF-16 LE",
|
||||
|
||||
/**
|
||||
* EncodingUTF16BE UTF-16大端编码
|
||||
*/
|
||||
EncodingUTF16BE = "UTF-16 BE",
|
||||
|
||||
/**
|
||||
* EncodingISO88591 ISO-8859-1编码
|
||||
*/
|
||||
EncodingISO88591 = "ISO-8859-1",
|
||||
|
||||
/**
|
||||
* EncodingGB18030 GB18030编码
|
||||
*/
|
||||
EncodingGB18030 = "GB18030",
|
||||
|
||||
/**
|
||||
* EncodingGBK GBK编码
|
||||
*/
|
||||
EncodingGBK = "GBK",
|
||||
|
||||
/**
|
||||
* EncodingBig5 Big5编码
|
||||
*/
|
||||
EncodingBig5 = "Big5",
|
||||
};
|
||||
|
||||
/**
|
||||
* LanguageType 语言类型定义
|
||||
*/
|
||||
|
@@ -15,10 +15,10 @@ import {Call as $Call, Create as $Create} from "@wailsio/runtime";
|
||||
import * as models$0 from "../models/models.js";
|
||||
|
||||
/**
|
||||
* GetAppConfig 获取应用配置
|
||||
* GetConfig 获取完整应用配置
|
||||
*/
|
||||
export function GetAppConfig(): Promise<models$0.AppConfig | null> & { cancel(): void } {
|
||||
let $resultPromise = $Call.ByID(3361428829) as any;
|
||||
export function GetConfig(): Promise<models$0.AppConfig | null> & { cancel(): void } {
|
||||
let $resultPromise = $Call.ByID(1013336538) as any;
|
||||
let $typingPromise = $resultPromise.then(($result: any) => {
|
||||
return $$createType1($result);
|
||||
}) as any;
|
||||
@@ -38,14 +38,6 @@ export function GetEditorConfig(): Promise<models$0.EditorConfig> & { cancel():
|
||||
return $typingPromise;
|
||||
}
|
||||
|
||||
/**
|
||||
* GetFullConfigPath 获取完整的配置文件路径
|
||||
*/
|
||||
export function GetFullConfigPath(): Promise<string> & { cancel(): void } {
|
||||
let $resultPromise = $Call.ByID(38527092) as any;
|
||||
return $resultPromise;
|
||||
}
|
||||
|
||||
/**
|
||||
* GetLanguage 获取当前语言设置
|
||||
*/
|
||||
@@ -55,18 +47,42 @@ export function GetLanguage(): Promise<models$0.LanguageType> & { cancel(): void
|
||||
}
|
||||
|
||||
/**
|
||||
* ResetToDefault 重置为默认配置
|
||||
* GetMetadata 获取配置元数据
|
||||
*/
|
||||
export function ResetToDefault(): Promise<void> & { cancel(): void } {
|
||||
let $resultPromise = $Call.ByID(4057687351) as any;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* GetPathConfig 获取路径配置
|
||||
*/
|
||||
export function GetPathConfig(): Promise<models$0.PathConfig> & { cancel(): void } {
|
||||
let $resultPromise = $Call.ByID(2053285689) as any;
|
||||
let $typingPromise = $resultPromise.then(($result: any) => {
|
||||
return $$createType4($result);
|
||||
}) as any;
|
||||
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
|
||||
return $typingPromise;
|
||||
}
|
||||
|
||||
/**
|
||||
* ResetConfig 重置为默认配置
|
||||
*/
|
||||
export function ResetConfig(): Promise<void> & { cancel(): void } {
|
||||
let $resultPromise = $Call.ByID(3593047389) as any;
|
||||
return $resultPromise;
|
||||
}
|
||||
|
||||
/**
|
||||
* SaveAppConfig 保存应用配置
|
||||
* SaveConfig 保存完整应用配置
|
||||
*/
|
||||
export function SaveAppConfig(config: models$0.AppConfig | null): Promise<void> & { cancel(): void } {
|
||||
let $resultPromise = $Call.ByID(2077587650, config) as any;
|
||||
export function SaveConfig(config: models$0.AppConfig | null): Promise<void> & { cancel(): void } {
|
||||
let $resultPromise = $Call.ByID(616684383, config) as any;
|
||||
return $resultPromise;
|
||||
}
|
||||
|
||||
@@ -86,7 +102,25 @@ export function UpdateEditorConfig(editorConfig: models$0.EditorConfig): Promise
|
||||
return $resultPromise;
|
||||
}
|
||||
|
||||
/**
|
||||
* UpdateMetadata 更新配置元数据
|
||||
*/
|
||||
export function UpdateMetadata(metadata: models$0.ConfigMetadata): Promise<void> & { cancel(): void } {
|
||||
let $resultPromise = $Call.ByID(3353893284, metadata) as any;
|
||||
return $resultPromise;
|
||||
}
|
||||
|
||||
/**
|
||||
* UpdatePathConfig 更新路径配置
|
||||
*/
|
||||
export function UpdatePathConfig(pathConfig: models$0.PathConfig): Promise<void> & { cancel(): void } {
|
||||
let $resultPromise = $Call.ByID(1492772004, pathConfig) 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.PathConfig.createFrom;
|
||||
|
@@ -1,73 +0,0 @@
|
||||
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
|
||||
// This file is automatically generated. DO NOT EDIT
|
||||
|
||||
/**
|
||||
* FileService 提供文件操作
|
||||
* @module
|
||||
*/
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore: Unused imports
|
||||
import {Call as $Call, Create as $Create} from "@wailsio/runtime";
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore: Unused imports
|
||||
import * as time$0 from "../../../time/models.js";
|
||||
|
||||
/**
|
||||
* DeleteFile 删除文件
|
||||
*/
|
||||
export function DeleteFile(filePath: string): Promise<void> & { cancel(): void } {
|
||||
let $resultPromise = $Call.ByID(1771867857, filePath) as any;
|
||||
return $resultPromise;
|
||||
}
|
||||
|
||||
/**
|
||||
* EnsureDir 确保目录存在,如不存在则创建
|
||||
*/
|
||||
export function EnsureDir(dirPath: string): Promise<void> & { cancel(): void } {
|
||||
let $resultPromise = $Call.ByID(2291976369, dirPath) as any;
|
||||
return $resultPromise;
|
||||
}
|
||||
|
||||
/**
|
||||
* FileExists 检查文件是否存在
|
||||
*/
|
||||
export function FileExists(filePath: string): Promise<boolean> & { cancel(): void } {
|
||||
let $resultPromise = $Call.ByID(4264173930, filePath) as any;
|
||||
return $resultPromise;
|
||||
}
|
||||
|
||||
/**
|
||||
* GetFileModTime 获取文件的修改时间
|
||||
*/
|
||||
export function GetFileModTime(filePath: string): Promise<time$0.Time> & { cancel(): void } {
|
||||
let $resultPromise = $Call.ByID(2240854203, filePath) as any;
|
||||
return $resultPromise;
|
||||
}
|
||||
|
||||
/**
|
||||
* LoadJSON 从文件加载JSON数据
|
||||
*/
|
||||
export function LoadJSON(filePath: string, target: any): Promise<void> & { cancel(): void } {
|
||||
let $resultPromise = $Call.ByID(1385779418, filePath, target) as any;
|
||||
return $resultPromise;
|
||||
}
|
||||
|
||||
/**
|
||||
* SaveJSON 保存JSON数据到文件
|
||||
*/
|
||||
export function SaveJSON(filePath: string, data: any): Promise<void> & { cancel(): void } {
|
||||
let $resultPromise = $Call.ByID(3646933935, filePath, data) as any;
|
||||
return $resultPromise;
|
||||
}
|
||||
|
||||
/**
|
||||
* SaveJSONWithCheck 保存JSON数据到文件,带并发检查
|
||||
* expectedModTime是期望的文件修改时间,如果为零值则不检查
|
||||
* onConflict是冲突处理函数,如果文件已被修改且此函数不为nil,则调用此函数合并数据
|
||||
*/
|
||||
export function SaveJSONWithCheck(filePath: string, data: any, expectedModTime: time$0.Time, onConflict: any): Promise<void> & { cancel(): void } {
|
||||
let $resultPromise = $Call.ByID(4074237977, filePath, data, expectedModTime, onConflict) as any;
|
||||
return $resultPromise;
|
||||
}
|
@@ -2,8 +2,6 @@
|
||||
// This file is automatically generated. DO NOT EDIT
|
||||
|
||||
import * as ConfigService from "./configservice.js";
|
||||
import * as FileService from "./fileservice.js";
|
||||
export {
|
||||
ConfigService,
|
||||
FileService
|
||||
ConfigService
|
||||
};
|
||||
|
Reference in New Issue
Block a user