✨ Add self-updating service
This commit is contained in:
@@ -471,6 +471,84 @@ export class GeneralConfig {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* GiteaConfig Gitea配置
|
||||
*/
|
||||
export class GiteaConfig {
|
||||
/**
|
||||
* Gitea服务器URL
|
||||
*/
|
||||
"baseURL": string;
|
||||
|
||||
/**
|
||||
* 仓库所有者
|
||||
*/
|
||||
"owner": string;
|
||||
|
||||
/**
|
||||
* 仓库名称
|
||||
*/
|
||||
"repo": string;
|
||||
|
||||
/** Creates a new GiteaConfig instance. */
|
||||
constructor($$source: Partial<GiteaConfig> = {}) {
|
||||
if (!("baseURL" in $$source)) {
|
||||
this["baseURL"] = "";
|
||||
}
|
||||
if (!("owner" in $$source)) {
|
||||
this["owner"] = "";
|
||||
}
|
||||
if (!("repo" in $$source)) {
|
||||
this["repo"] = "";
|
||||
}
|
||||
|
||||
Object.assign(this, $$source);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new GiteaConfig instance from a string or object.
|
||||
*/
|
||||
static createFrom($$source: any = {}): GiteaConfig {
|
||||
let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source;
|
||||
return new GiteaConfig($$parsedSource as Partial<GiteaConfig>);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* GithubConfig GitHub配置
|
||||
*/
|
||||
export class GithubConfig {
|
||||
/**
|
||||
* 仓库所有者
|
||||
*/
|
||||
"owner": string;
|
||||
|
||||
/**
|
||||
* 仓库名称
|
||||
*/
|
||||
"repo": string;
|
||||
|
||||
/** Creates a new GithubConfig instance. */
|
||||
constructor($$source: Partial<GithubConfig> = {}) {
|
||||
if (!("owner" in $$source)) {
|
||||
this["owner"] = "";
|
||||
}
|
||||
if (!("repo" in $$source)) {
|
||||
this["repo"] = "";
|
||||
}
|
||||
|
||||
Object.assign(this, $$source);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new GithubConfig instance from a string or object.
|
||||
*/
|
||||
static createFrom($$source: any = {}): GithubConfig {
|
||||
let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source;
|
||||
return new GithubConfig($$parsedSource as Partial<GithubConfig>);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* HotkeyCombo 热键组合定义
|
||||
*/
|
||||
@@ -1023,6 +1101,26 @@ export enum TabType {
|
||||
TabTypeTab = "tab",
|
||||
};
|
||||
|
||||
/**
|
||||
* UpdateSourceType 更新源类型
|
||||
*/
|
||||
export enum UpdateSourceType {
|
||||
/**
|
||||
* The Go zero value for the underlying type of the enum.
|
||||
*/
|
||||
$zero = "",
|
||||
|
||||
/**
|
||||
* UpdateSourceGithub GitHub更新源
|
||||
*/
|
||||
UpdateSourceGithub = "github",
|
||||
|
||||
/**
|
||||
* UpdateSourceGitea Gitea更新源
|
||||
*/
|
||||
UpdateSourceGitea = "gitea",
|
||||
};
|
||||
|
||||
/**
|
||||
* UpdatesConfig 更新设置配置
|
||||
*/
|
||||
@@ -1037,6 +1135,36 @@ export class UpdatesConfig {
|
||||
*/
|
||||
"autoUpdate": boolean;
|
||||
|
||||
/**
|
||||
* 主要更新源
|
||||
*/
|
||||
"primarySource": UpdateSourceType;
|
||||
|
||||
/**
|
||||
* 备用更新源
|
||||
*/
|
||||
"backupSource": UpdateSourceType;
|
||||
|
||||
/**
|
||||
* 更新前是否备份
|
||||
*/
|
||||
"backupBeforeUpdate": boolean;
|
||||
|
||||
/**
|
||||
* 更新超时时间(秒)
|
||||
*/
|
||||
"updateTimeout": number;
|
||||
|
||||
/**
|
||||
* GitHub配置
|
||||
*/
|
||||
"github": GithubConfig;
|
||||
|
||||
/**
|
||||
* Gitea配置
|
||||
*/
|
||||
"gitea": GiteaConfig;
|
||||
|
||||
/** Creates a new UpdatesConfig instance. */
|
||||
constructor($$source: Partial<UpdatesConfig> = {}) {
|
||||
if (!("version" in $$source)) {
|
||||
@@ -1045,6 +1173,24 @@ export class UpdatesConfig {
|
||||
if (!("autoUpdate" in $$source)) {
|
||||
this["autoUpdate"] = false;
|
||||
}
|
||||
if (!("primarySource" in $$source)) {
|
||||
this["primarySource"] = ("" as UpdateSourceType);
|
||||
}
|
||||
if (!("backupSource" in $$source)) {
|
||||
this["backupSource"] = ("" as UpdateSourceType);
|
||||
}
|
||||
if (!("backupBeforeUpdate" in $$source)) {
|
||||
this["backupBeforeUpdate"] = false;
|
||||
}
|
||||
if (!("updateTimeout" in $$source)) {
|
||||
this["updateTimeout"] = 0;
|
||||
}
|
||||
if (!("github" in $$source)) {
|
||||
this["github"] = (new GithubConfig());
|
||||
}
|
||||
if (!("gitea" in $$source)) {
|
||||
this["gitea"] = (new GiteaConfig());
|
||||
}
|
||||
|
||||
Object.assign(this, $$source);
|
||||
}
|
||||
@@ -1053,7 +1199,15 @@ export class UpdatesConfig {
|
||||
* Creates a new UpdatesConfig instance from a string or object.
|
||||
*/
|
||||
static createFrom($$source: any = {}): UpdatesConfig {
|
||||
const $$createField6_0 = $$createType11;
|
||||
const $$createField7_0 = $$createType12;
|
||||
let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source;
|
||||
if ("github" in $$parsedSource) {
|
||||
$$parsedSource["github"] = $$createField6_0($$parsedSource["github"]);
|
||||
}
|
||||
if ("gitea" in $$parsedSource) {
|
||||
$$parsedSource["gitea"] = $$createField7_0($$parsedSource["gitea"]);
|
||||
}
|
||||
return new UpdatesConfig($$parsedSource as Partial<UpdatesConfig>);
|
||||
}
|
||||
}
|
||||
@@ -1075,3 +1229,5 @@ const $$createType7 = HotkeyCombo.createFrom;
|
||||
const $$createType8 = KeyBinding.createFrom;
|
||||
const $$createType9 = $Create.Array($$createType8);
|
||||
const $$createType10 = KeyBindingMetadata.createFrom;
|
||||
const $$createType11 = GithubConfig.createFrom;
|
||||
const $$createType12 = GiteaConfig.createFrom;
|
||||
|
@@ -8,10 +8,10 @@ import * as ExtensionService from "./extensionservice.js";
|
||||
import * as HotkeyService from "./hotkeyservice.js";
|
||||
import * as KeyBindingService from "./keybindingservice.js";
|
||||
import * as MigrationService from "./migrationservice.js";
|
||||
import * as SelfUpdateService from "./selfupdateservice.js";
|
||||
import * as StartupService from "./startupservice.js";
|
||||
import * as SystemService from "./systemservice.js";
|
||||
import * as TrayService from "./trayservice.js";
|
||||
import * as UpdateService from "./updateservice.js";
|
||||
export {
|
||||
ConfigService,
|
||||
DialogService,
|
||||
@@ -20,10 +20,10 @@ export {
|
||||
HotkeyService,
|
||||
KeyBindingService,
|
||||
MigrationService,
|
||||
SelfUpdateService,
|
||||
StartupService,
|
||||
SystemService,
|
||||
TrayService,
|
||||
UpdateService
|
||||
TrayService
|
||||
};
|
||||
|
||||
export * from "./models.js";
|
||||
|
@@ -116,9 +116,9 @@ export enum MigrationStatus {
|
||||
};
|
||||
|
||||
/**
|
||||
* UpdateCheckResult 更新检查结果
|
||||
* SelfUpdateResult 自我更新结果
|
||||
*/
|
||||
export class UpdateCheckResult {
|
||||
export class SelfUpdateResult {
|
||||
/**
|
||||
* 是否有更新
|
||||
*/
|
||||
@@ -127,57 +127,73 @@ export class UpdateCheckResult {
|
||||
/**
|
||||
* 当前版本
|
||||
*/
|
||||
"currentVer": string;
|
||||
"currentVersion": string;
|
||||
|
||||
/**
|
||||
* 最新版本
|
||||
*/
|
||||
"latestVer": string;
|
||||
"latestVersion": string;
|
||||
|
||||
/**
|
||||
* 是否已应用更新
|
||||
*/
|
||||
"updateApplied": boolean;
|
||||
|
||||
/**
|
||||
* 下载链接
|
||||
*/
|
||||
"assetURL": string;
|
||||
|
||||
/**
|
||||
* 发布说明
|
||||
*/
|
||||
"releaseNotes": string;
|
||||
|
||||
/**
|
||||
* 发布页面URL
|
||||
*/
|
||||
"releaseURL": string;
|
||||
|
||||
/**
|
||||
* 错误信息
|
||||
*/
|
||||
"error": string;
|
||||
|
||||
/** Creates a new UpdateCheckResult instance. */
|
||||
constructor($$source: Partial<UpdateCheckResult> = {}) {
|
||||
/**
|
||||
* 更新源(github/gitea)
|
||||
*/
|
||||
"source": string;
|
||||
|
||||
/** Creates a new SelfUpdateResult instance. */
|
||||
constructor($$source: Partial<SelfUpdateResult> = {}) {
|
||||
if (!("hasUpdate" in $$source)) {
|
||||
this["hasUpdate"] = false;
|
||||
}
|
||||
if (!("currentVer" in $$source)) {
|
||||
this["currentVer"] = "";
|
||||
if (!("currentVersion" in $$source)) {
|
||||
this["currentVersion"] = "";
|
||||
}
|
||||
if (!("latestVer" in $$source)) {
|
||||
this["latestVer"] = "";
|
||||
if (!("latestVersion" in $$source)) {
|
||||
this["latestVersion"] = "";
|
||||
}
|
||||
if (!("updateApplied" in $$source)) {
|
||||
this["updateApplied"] = false;
|
||||
}
|
||||
if (!("assetURL" in $$source)) {
|
||||
this["assetURL"] = "";
|
||||
}
|
||||
if (!("releaseNotes" in $$source)) {
|
||||
this["releaseNotes"] = "";
|
||||
}
|
||||
if (!("releaseURL" in $$source)) {
|
||||
this["releaseURL"] = "";
|
||||
}
|
||||
if (!("error" in $$source)) {
|
||||
this["error"] = "";
|
||||
}
|
||||
if (!("source" in $$source)) {
|
||||
this["source"] = "";
|
||||
}
|
||||
|
||||
Object.assign(this, $$source);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new UpdateCheckResult instance from a string or object.
|
||||
* Creates a new SelfUpdateResult instance from a string or object.
|
||||
*/
|
||||
static createFrom($$source: any = {}): UpdateCheckResult {
|
||||
static createFrom($$source: any = {}): SelfUpdateResult {
|
||||
let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source;
|
||||
return new UpdateCheckResult($$parsedSource as Partial<UpdateCheckResult>);
|
||||
return new SelfUpdateResult($$parsedSource as Partial<SelfUpdateResult>);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,51 @@
|
||||
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
|
||||
// This file is automatically generated. DO NOT EDIT
|
||||
|
||||
/**
|
||||
* SelfUpdateService 自我更新服务
|
||||
* @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 $models from "./models.js";
|
||||
|
||||
/**
|
||||
* ApplyUpdate 应用更新
|
||||
*/
|
||||
export function ApplyUpdate(): Promise<$models.SelfUpdateResult | null> & { cancel(): void } {
|
||||
let $resultPromise = $Call.ByID(2009328394) as any;
|
||||
let $typingPromise = $resultPromise.then(($result: any) => {
|
||||
return $$createType1($result);
|
||||
}) as any;
|
||||
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
|
||||
return $typingPromise;
|
||||
}
|
||||
|
||||
/**
|
||||
* CheckForUpdates 检查更新
|
||||
*/
|
||||
export function CheckForUpdates(): Promise<$models.SelfUpdateResult | null> & { cancel(): void } {
|
||||
let $resultPromise = $Call.ByID(438757208) as any;
|
||||
let $typingPromise = $resultPromise.then(($result: any) => {
|
||||
return $$createType1($result);
|
||||
}) as any;
|
||||
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
|
||||
return $typingPromise;
|
||||
}
|
||||
|
||||
/**
|
||||
* RestartApplication 重启应用程序
|
||||
*/
|
||||
export function RestartApplication(): Promise<void> & { cancel(): void } {
|
||||
let $resultPromise = $Call.ByID(3341481538) as any;
|
||||
return $resultPromise;
|
||||
}
|
||||
|
||||
// Private type creation functions
|
||||
const $$createType0 = $models.SelfUpdateResult.createFrom;
|
||||
const $$createType1 = $Create.Nullable($$createType0);
|
@@ -1,30 +0,0 @@
|
||||
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
|
||||
// This file is automatically generated. DO NOT EDIT
|
||||
|
||||
/**
|
||||
* UpdateService 更新服务
|
||||
* @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 $models from "./models.js";
|
||||
|
||||
/**
|
||||
* CheckForUpdates 检查更新
|
||||
*/
|
||||
export function CheckForUpdates(): Promise<$models.UpdateCheckResult> & { cancel(): void } {
|
||||
let $resultPromise = $Call.ByID(3024322786) as any;
|
||||
let $typingPromise = $resultPromise.then(($result: any) => {
|
||||
return $$createType0($result);
|
||||
}) as any;
|
||||
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
|
||||
return $typingPromise;
|
||||
}
|
||||
|
||||
// Private type creation functions
|
||||
const $$createType0 = $models.UpdateCheckResult.createFrom;
|
Reference in New Issue
Block a user