feat: add image optimization task model

This commit is contained in:
QiuSW
2026-07-09 00:47:35 +08:00
parent 7942add8b6
commit 3bd05b316e
16 changed files with 827 additions and 34 deletions
@@ -353,8 +353,277 @@ export class Hotkey {
}
}
export class ImageTask {
/**
* Creates a new ImageTask instance.
* @param {Partial<ImageTask>} [$$source = {}] - The source object to create the ImageTask.
*/
constructor($$source = {}) {
if (!("id" in $$source)) {
/**
* @member
* @type {number}
*/
this["id"] = 0;
}
if (!("sourcePath" in $$source)) {
/**
* @member
* @type {string}
*/
this["sourcePath"] = "";
}
if (!("status" in $$source)) {
/**
* @member
* @type {string}
*/
this["status"] = "";
}
if (!("operation" in $$source)) {
/**
* @member
* @type {string}
*/
this["operation"] = "";
}
if (!("durationMs" in $$source)) {
/**
* @member
* @type {number}
*/
this["durationMs"] = 0;
}
if (!("errorMessage" in $$source)) {
/**
* @member
* @type {string}
*/
this["errorMessage"] = "";
}
if (!("createdAt" in $$source)) {
/**
* @member
* @type {string}
*/
this["createdAt"] = "";
}
if (!("updatedAt" in $$source)) {
/**
* @member
* @type {string}
*/
this["updatedAt"] = "";
}
Object.assign(this, $$source);
}
/**
* Creates a new ImageTask instance from a string or object.
* @param {any} [$$source = {}]
* @returns {ImageTask}
*/
static createFrom($$source = {}) {
let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source;
return new ImageTask(/** @type {Partial<ImageTask>} */($$parsedSource));
}
}
export class ImageTaskDetail {
/**
* Creates a new ImageTaskDetail instance.
* @param {Partial<ImageTaskDetail>} [$$source = {}] - The source object to create the ImageTaskDetail.
*/
constructor($$source = {}) {
if (!("task" in $$source)) {
/**
* @member
* @type {ImageTask}
*/
this["task"] = (new ImageTask());
}
if (!("result" in $$source)) {
/**
* @member
* @type {ImageTaskResult}
*/
this["result"] = (new ImageTaskResult());
}
Object.assign(this, $$source);
}
/**
* Creates a new ImageTaskDetail instance from a string or object.
* @param {any} [$$source = {}]
* @returns {ImageTaskDetail}
*/
static createFrom($$source = {}) {
const $$createField0_0 = $$createType4;
const $$createField1_0 = $$createType5;
let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source;
if ("task" in $$parsedSource) {
$$parsedSource["task"] = $$createField0_0($$parsedSource["task"]);
}
if ("result" in $$parsedSource) {
$$parsedSource["result"] = $$createField1_0($$parsedSource["result"]);
}
return new ImageTaskDetail(/** @type {Partial<ImageTaskDetail>} */($$parsedSource));
}
}
export class ImageTaskFilter {
/**
* Creates a new ImageTaskFilter instance.
* @param {Partial<ImageTaskFilter>} [$$source = {}] - The source object to create the ImageTaskFilter.
*/
constructor($$source = {}) {
if (!("status" in $$source)) {
/**
* @member
* @type {string}
*/
this["status"] = "";
}
if (!("operation" in $$source)) {
/**
* @member
* @type {string}
*/
this["operation"] = "";
}
if (!("limit" in $$source)) {
/**
* @member
* @type {number}
*/
this["limit"] = 0;
}
if (!("offset" in $$source)) {
/**
* @member
* @type {number}
*/
this["offset"] = 0;
}
Object.assign(this, $$source);
}
/**
* Creates a new ImageTaskFilter instance from a string or object.
* @param {any} [$$source = {}]
* @returns {ImageTaskFilter}
*/
static createFrom($$source = {}) {
let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source;
return new ImageTaskFilter(/** @type {Partial<ImageTaskFilter>} */($$parsedSource));
}
}
export class ImageTaskInput {
/**
* Creates a new ImageTaskInput instance.
* @param {Partial<ImageTaskInput>} [$$source = {}] - The source object to create the ImageTaskInput.
*/
constructor($$source = {}) {
if (!("sourcePath" in $$source)) {
/**
* @member
* @type {string}
*/
this["sourcePath"] = "";
}
if (!("operation" in $$source)) {
/**
* @member
* @type {string}
*/
this["operation"] = "";
}
Object.assign(this, $$source);
}
/**
* Creates a new ImageTaskInput instance from a string or object.
* @param {any} [$$source = {}]
* @returns {ImageTaskInput}
*/
static createFrom($$source = {}) {
let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source;
return new ImageTaskInput(/** @type {Partial<ImageTaskInput>} */($$parsedSource));
}
}
export class ImageTaskResult {
/**
* Creates a new ImageTaskResult instance.
* @param {Partial<ImageTaskResult>} [$$source = {}] - The source object to create the ImageTaskResult.
*/
constructor($$source = {}) {
if (!("id" in $$source)) {
/**
* @member
* @type {number}
*/
this["id"] = 0;
}
if (!("taskId" in $$source)) {
/**
* @member
* @type {number}
*/
this["taskId"] = 0;
}
if (!("outputPath" in $$source)) {
/**
* @member
* @type {string}
*/
this["outputPath"] = "";
}
if (!("beforeSize" in $$source)) {
/**
* @member
* @type {number}
*/
this["beforeSize"] = 0;
}
if (!("afterSize" in $$source)) {
/**
* @member
* @type {number}
*/
this["afterSize"] = 0;
}
if (!("createdAt" in $$source)) {
/**
* @member
* @type {string}
*/
this["createdAt"] = "";
}
Object.assign(this, $$source);
}
/**
* Creates a new ImageTaskResult instance from a string or object.
* @param {any} [$$source = {}]
* @returns {ImageTaskResult}
*/
static createFrom($$source = {}) {
let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source;
return new ImageTaskResult(/** @type {Partial<ImageTaskResult>} */($$parsedSource));
}
}
// Private type creation functions
const $$createType0 = AppSettingOption.createFrom;
const $$createType1 = $Create.Array($$createType0);
const $$createType2 = AppSettingDefinition.createFrom;
const $$createType3 = $Create.Array($$createType2);
const $$createType4 = ImageTask.createFrom;
const $$createType5 = ImageTaskResult.createFrom;
@@ -0,0 +1,64 @@
// @ts-check
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
// This file is automatically generated. DO NOT EDIT
// 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$0 from "../models/models.js";
/**
* @param {number} id
* @returns {Promise<void> & { cancel(): void }}
*/
export function CancelTask(id) {
let $resultPromise = /** @type {any} */($Call.ByID(3767102380, id));
return $resultPromise;
}
/**
* @param {models$0.ImageTaskInput} input
* @returns {Promise<models$0.ImageTaskDetail> & { cancel(): void }}
*/
export function CreateTask(input) {
let $resultPromise = /** @type {any} */($Call.ByID(1860238962, input));
let $typingPromise = /** @type {any} */($resultPromise.then(($result) => {
return $$createType0($result);
}));
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
return $typingPromise;
}
/**
* @param {number} id
* @returns {Promise<models$0.ImageTaskDetail> & { cancel(): void }}
*/
export function GetTask(id) {
let $resultPromise = /** @type {any} */($Call.ByID(701224676, id));
let $typingPromise = /** @type {any} */($resultPromise.then(($result) => {
return $$createType0($result);
}));
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
return $typingPromise;
}
/**
* @param {models$0.ImageTaskFilter} filter
* @returns {Promise<models$0.ImageTask[]> & { cancel(): void }}
*/
export function ListTasks(filter) {
let $resultPromise = /** @type {any} */($Call.ByID(1714055147, filter));
let $typingPromise = /** @type {any} */($resultPromise.then(($result) => {
return $$createType2($result);
}));
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
return $typingPromise;
}
// Private type creation functions
const $$createType0 = models$0.ImageTaskDetail.createFrom;
const $$createType1 = models$0.ImageTask.createFrom;
const $$createType2 = $Create.Array($$createType1);
@@ -6,6 +6,7 @@ import * as AppConfigService from "./appconfigservice.js";
import * as AppService from "./appservice.js";
import * as AuthService from "./authservice.js";
import * as HotkeyService from "./hotkeyservice.js";
import * as ImageOptimizationService from "./imageoptimizationservice.js";
import * as OCRService from "./ocrservice.js";
import * as SystemInfo from "./systeminfo.js";
export {
@@ -13,6 +14,7 @@ export {
AppService,
AuthService,
HotkeyService,
ImageOptimizationService,
OCRService,
SystemInfo
};