diff --git a/_template_.js b/_template_.js index bc63228..0ffb620 100644 --- a/_template_.js +++ b/_template_.js @@ -494,6 +494,10 @@ class NewComicSource extends ComicSource { loadNext: async (next, folder) => { }, + /** + * If the comic source only allows one comic in one folder, set this to true. + */ + singleFolderForSingleComic: false, } /// single comic related diff --git a/_venera_.js b/_venera_.js index e5cd807..553f404 100644 --- a/_venera_.js +++ b/_venera_.js @@ -496,7 +496,7 @@ let Network = { /** * [fetch] function for sending HTTP requests. Same api as the browser fetch. * @param url {string} - * @param options {{method: string, headers: Object, body: any}} + * @param [options] {{method?: string, headers?: Object, body?: any}} * @returns {Promise<{ok: boolean, status: number, statusText: string, headers: {}, arrayBuffer: (function(): Promise), text: (function(): Promise), json: (function(): Promise)}>} * @since 1.2.0 */ @@ -921,7 +921,7 @@ function Comic({id, title, subtitle, subTitle, cover, tags, description, maxPage * @param description {string?} * @param tags {Map | {} | null | undefined} * @param chapters {Map | {} | null | undefined} - key: chapter id, value: chapter title - * @param isFavorite {boolean | null | undefined} - favorite status. If the comic source supports multiple folders, this field should be null + * @param isFavorite {boolean | null | undefined} - favorite status. * @param subId {string?} - a param which is passed to comments api * @param thumbnails {string[]?} - for multiple page thumbnails, set this to null, and use `loadThumbnails` api to load thumbnails * @param recommend {Comic[]?} - related comics @@ -1086,6 +1086,19 @@ class ComicSource { }); } + translation = {} + + /** + * Translate given string with the current locale using the translation object. + * @param key {string} + * @returns {string} + * @since 1.2.5 + */ + translate(key) { + let locale = APP.locale; + return this.translation[locale]?.[key] ?? key; + } + init() { } static sources = {} @@ -1227,6 +1240,7 @@ let UI = { * @param title {string} * @param content {string} * @param actions {{text:string, callback: () => void | Promise, style: "text"|"filled"|"danger"}[]} - If callback returns a promise, the button will show a loading indicator until the promise is resolved. + * @returns {Promise} - Resolved when the dialog is closed. * @since 1.2.1 */ showDialog: (title, content, actions) => { @@ -1282,7 +1296,7 @@ let UI = { * Show an input dialog * @param title {string} * @param validator {(string) => string | null | undefined} - A function that validates the input. If the function returns a string, the dialog will show the error message. - * @returns {string | null} - The input value. If the dialog is canceled, return null. + * @returns {Promise} - The input value. If the dialog is canceled, return null. */ showInputDialog: (title, validator) => { return sendMessage({ @@ -1298,7 +1312,7 @@ let UI = { * @param title {string} * @param options {string[]} * @param initialIndex {number?} - * @returns {number | null} - The selected index. If the dialog is canceled, return null. + * @returns {Promise} - The selected index. If the dialog is canceled, return null. */ showSelectDialog: (title, options, initialIndex) => { return sendMessage({