From a0e3cc720acd70cc14c71b96ef27f18cb9d0294a Mon Sep 17 00:00:00 2001 From: nyne Date: Mon, 11 Nov 2024 17:36:42 +0800 Subject: [PATCH] add ImageLoadingConfig constructor --- assets/init.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/assets/init.js b/assets/init.js index 932590c..6d08177 100644 --- a/assets/init.js +++ b/assets/init.js @@ -940,6 +940,33 @@ function Comment({userName, avatar, content, time, replyCount, id, isLiked, scor this.voteStatus = voteStatus; } +/** + * Create image loading config + * @param url {string?} + * @param method {string?} - http method, uppercase + * @param data {any} - request data, may be null + * @param headers {Object?} - request headers + * @param onResponse {((ArrayBuffer) => ArrayBuffer)?} - modify response data + * @param modifyImage {string?} + * A js script string. + * The script will be executed in a new Isolate. + * A function named `modifyImage` should be defined in the script, which receives an [Image] as the only argument, and returns an [Image].. + * @param onLoadFailed {(() => ImageLoadingConfig)?} - called when the image loading failed + * @constructor + * @since 1.0.5 + * + * To keep the compatibility with the old version, do not use the constructor. Consider creating a new object with the properties directly. + */ +function ImageLoadingConfig({url, method, data, headers, onResponse, modifyImage, onLoadFailed}) { + this.url = url; + this.method = method; + this.data = data; + this.headers = headers; + this.onResponse = onResponse; + this.modifyImage = modifyImage; + this.onLoadFailed = onLoadFailed; +} + class ComicSource { name = ""