更新扩展

This commit is contained in:
Saul Hetherman
2024-09-29 15:58:33 +08:00
parent 90029f6a2f
commit a92d2229d6
13 changed files with 787 additions and 33 deletions

File diff suppressed because one or more lines are too long

View File

@@ -79,14 +79,25 @@ class RepTabList {
class HomeTabModel {
constructor() {
// 当前分类的链接
/**
* 当前分类的链接
**/
this.id = "";
// 分类名称
/**
* 分类名称
*/
this.name = "";
/**
* 是否是筛选列表
*/
this.isFilter = false;
/**
* 扩展运行标识 ** uzApp 运行时自动赋值,请勿修改 **
*/
this.uzTag = "";
}
}

View File

@@ -51,6 +51,49 @@ class UZUtils {
return str;
}
/**
* 计算最长公共子串
* @param {string} s1
* @param {string} s2
* @returns
*/
static lcs(s1, s2) {
const m = s1.length,
n = s2.length;
const dp = Array.from({ length: m + 1 }, () => Array(n + 1).fill(0));
let maxLength = 0,
endIndex = 0;
for (let i = 1; i <= m; i++) {
for (let j = 1; j <= n; j++) {
if (s1[i - 1] === s2[j - 1]) {
dp[i][j] = dp[i - 1][j - 1] + 1;
if (dp[i][j] > maxLength) {
maxLength = dp[i][j];
endIndex = i - 1;
}
}
}
}
return s1.substring(endIndex - maxLength + 1, endIndex + 1);
}
/**
* 查找元素在数组中的位置
* @param {Array} list
* @param {string} element
* @returns
*/
static findIndex(list, element) {
for (let i = 0; i < list.length; i++) {
if (list[i] === element) {
return i;
}
}
return -1;
}
/**
* 用于在 uz 扩展调试模式中展示 log 信息
*/
@@ -67,14 +110,21 @@ class ProData {
constructor() {
this.error = "";
this.data;
/**
* @type {object} 响应头
*/
this.headers;
/**
* @type {number} 状态码
*/
this.code;
/**
* @type {boolean} 是否成功
*/
this.ok = () => this.code === 200;
}
}
@@ -104,25 +154,31 @@ async function req(url, options) {
return pro;
}
// /**
// * 展示 toast
// */
// function toast() {
// sendMessage("toast", JSON.stringify([...arguments]));
// }
//
// /**
// * 读取环境变量
// */
// async function getEnv(key) {
// let res = await sendMessage("getEnv", JSON.stringify([key]));
// return JSON.parse(res);
// }
//
// /**
// * 写入环境变量
// */
// async function setEnv(key, value) {
// let res = await sendMessage("setEnv", JSON.stringify([key, value]));
// return JSON.parse(res);
// }
//MARK: - 环境变量(持久存储)
/**
* 读取环境变量
* @param {string} uzTag 直接传入扩展的 uzTag ,请勿修改
* @param {string} key
* @returns {@Promise<string>}
*/
async function getEnv(uzTag, key) {
let res = await sendMessage(
"getEnv",
JSON.stringify({ uzTag: uzTag, key: key })
);
return res;
}
/**
* 写入环境变量
* @param {string} uzTag 直接传入扩展的 uzTag ,请勿修改
* @param {string} key
* @param {string} value
* @param {string} summary 描述,新增时建议传入。修改时不必传入
*/
async function setEnv(uzTag, key, value, summary) {
let res = await sendMessage(
"setEnv",
JSON.stringify({ uzTag: uzTag, key: key, value: value, summary: summary })
);
}

View File

@@ -116,8 +116,11 @@ class VideoDetail {
this.vod_content = "";
// 地区
this.vod_area = "";
// 夸克网盘链接 暂未实现
this.quarkUrl = "";
/**
* 网盘分享链接列表
* @type {string[]}
*/
this.panUrls = [];
}
}
@@ -241,8 +244,18 @@ class UZSubclassVideoListArgs extends UZArgs {
* 扩展基类
*/
class WebApiBase {
// 网站主页
webSite = "";
constructor() {
/**
* 网站主页
**/
this.webSite = "";
/**
* 扩展运行标识 ** uzApp 运行时自动赋值,请勿修改 **
*/
this.uzTag = "";
}
/**
* 异步获取分类列表的方法。
* @param {UZArgs} args