mirror of
https://github.com/YuleBest/FontMM.git
synced 2026-12-04 03:11:48 +08:00
feat(tools): 新增工具页「下载国际版小米主题字体」v1.0.0
- 底部导航新增「工具」页 (第 4 tab), 工具以页面形式呈现(列表->详情->返回) - 小米主题字体工具: 搜索(跨域走 root shell curl) + 预览图(thumbnail/webp 格式) + 分页 - 下载/解压由模块内置脚本 src/tools/mi-font-download.sh 完成: 后台运行 + 日志写入 webroot 文件 + 前端 1s 轮询展示日志 (__DONE__ 结束标记) (KernelSU 原生 exec 在主线程执行 shell, 长任务必须后台化, 避免 UI 卡死) - 下载后自动解压 mtz 提取 fonts/ 目录字体并显示路径 - dev mock 完整模拟搜索/详情/下载日志
This commit is contained in:
1 parent
ee5f8f6cec
commit
b9e68430d8
6 files changed
+494
-1
No files matched your search
@@ -0,0 +1,61 @@
|
||||
#!/system/bin/sh
|
||||
# FontMM 工具: 下载国际版小米主题字体并解压提取 (v1.0.0)
|
||||
# 用法: mi-font-download.sh "<标题>" "<主题ID>" "<URL编码标题>"
|
||||
# 流程: 详情API取下载地址 -> 下载 .mtz -> 解压提取 fonts/ 目录字体
|
||||
|
||||
DOWN_DIR="/storage/emulated/0/Download/xttdown"
|
||||
DETAILS_API="https://api.zhuti.intl.xiaomi.com/app/v9/uipages/theme/"
|
||||
DL_BASE="https://f17.market.xiaomi.com/issue/"
|
||||
|
||||
TITLE="$1"
|
||||
ID="$2"
|
||||
ENCODED="$3"
|
||||
|
||||
[ -z "$TITLE" ] || [ -z "$ID" ] || [ -z "$ENCODED" ] && {
|
||||
echo "[x] 参数不足: <标题> <主题ID> <URL编码标题>"
|
||||
echo "__DONE__"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# 文件名安全化
|
||||
SAFE_TITLE=$(printf "%s" "$TITLE" | tr -c 'A-Za-z0-9._-' '_')
|
||||
|
||||
echo "[*] 获取「$TITLE」下载链接..."
|
||||
DOWN_URL=$(curl -s "${DETAILS_API}${ID}" | sed -n 's/.*"downloadUrl":"\([^"]*\)".*/\1/p' | head -1)
|
||||
[ -z "$DOWN_URL" ] && {
|
||||
echo "[x] 获取下载链接失败"
|
||||
echo "__DONE__"
|
||||
exit 1
|
||||
}
|
||||
|
||||
DL_URL="${DL_BASE}${DOWN_URL}/${ENCODED}.mtz"
|
||||
SAVE="${DOWN_DIR}/${SAFE_TITLE}.mtz"
|
||||
echo "[*] 下载: ${DL_URL}"
|
||||
mkdir -p "$DOWN_DIR"
|
||||
if ! curl -sL -o "$SAVE" "$DL_URL" || [ ! -s "$SAVE" ]; then
|
||||
echo "[x] 下载失败"
|
||||
echo "__DONE__"
|
||||
exit 1
|
||||
fi
|
||||
echo "[✓] 下载完成: ${SAVE} ($(du -h "$SAVE" | cut -f1))"
|
||||
|
||||
EXTRACT_DIR="${DOWN_DIR}/extracted/${SAFE_TITLE}"
|
||||
echo "[*] 解压 mtz 并提取字体..."
|
||||
mkdir -p "$EXTRACT_DIR"
|
||||
unzip -o -j "$SAVE" 'fonts/*' -d "$EXTRACT_DIR" >/dev/null 2>&1
|
||||
|
||||
# 收集提取出的字体文件 (ttf/otf)
|
||||
FONTS=''
|
||||
for f in "$EXTRACT_DIR"/*.ttf "$EXTRACT_DIR"/*.otf; do
|
||||
[ -f "$f" ] && FONTS="${FONTS} $(basename "$f")"
|
||||
done
|
||||
|
||||
if [ -n "$FONTS" ]; then
|
||||
echo "[✓] 提取字体:"
|
||||
for f in $FONTS; do
|
||||
echo " ${EXTRACT_DIR}/${f}"
|
||||
done
|
||||
else
|
||||
echo "[-] 未在 mtz 中找到字体文件, 原始包保留在 ${SAVE}"
|
||||
fi
|
||||
echo "__DONE__"
|
||||
@@ -209,6 +209,46 @@
|
||||
</md-elevated-card>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 工具视图 -->
|
||||
<div id="tools-view" class="view view-tools">
|
||||
<!-- 工具列表 -->
|
||||
<div id="tools-list">
|
||||
<div class="home-title">工具</div>
|
||||
|
||||
<md-elevated-card class="home-card tool-card home-entry-card" id="mi-font-tool">
|
||||
<div class="home-entry-row">
|
||||
<div class="home-entry-icon">
|
||||
<md-icon>download</md-icon>
|
||||
</div>
|
||||
<div class="home-entry-text">
|
||||
<div class="home-entry-title">下载国际版小米主题字体</div>
|
||||
<div class="home-entry-sub">v1.0.0 · 搜索并下载国际版主题商店的字体 (.mtz)</div>
|
||||
</div>
|
||||
<md-icon class="home-entry-arrow">chevron_right</md-icon>
|
||||
</div>
|
||||
</md-elevated-card>
|
||||
</div>
|
||||
|
||||
<!-- 工具详情: 下载国际版小米主题字体 -->
|
||||
<div id="mi-font-page" class="tool-page" hidden>
|
||||
<div class="view-topbar">
|
||||
<md-icon-button id="mi-font-back" aria-label="返回">
|
||||
<md-icon>arrow_back</md-icon>
|
||||
</md-icon-button>
|
||||
<span class="view-topbar-title">下载国际版小米主题字体</span>
|
||||
</div>
|
||||
<div class="mi-search-row">
|
||||
<md-outlined-text-field
|
||||
id="mi-keyword"
|
||||
label="字体关键词"
|
||||
style="flex: 1"
|
||||
></md-outlined-text-field>
|
||||
<md-filled-button id="mi-search-btn">搜索</md-filled-button>
|
||||
</div>
|
||||
<div id="mi-result" class="mi-result"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 悬浮应用按钮 (仅配置页, 向下滚动时隐藏) -->
|
||||
@@ -274,6 +314,10 @@
|
||||
<md-icon slot="active-icon">text_fields</md-icon>
|
||||
<md-icon slot="inactive-icon">text_fields</md-icon>
|
||||
</md-navigation-tab>
|
||||
<md-navigation-tab label="工具">
|
||||
<md-icon slot="active-icon">build</md-icon>
|
||||
<md-icon slot="inactive-icon">build</md-icon>
|
||||
</md-navigation-tab>
|
||||
</md-navigation-bar>
|
||||
</nav>
|
||||
|
||||
|
||||
@@ -68,6 +68,56 @@ async function mockExec(command: string): Promise<ExecResult> {
|
||||
return slow('name=KernelSU MetaModule\nversion=v1.0\nauthor=KernelSU');
|
||||
}
|
||||
|
||||
// 小米主题字体工具: 搜索/详情/下载 (模拟)
|
||||
if (command.includes('thm.market.intl.xiaomi.com')) {
|
||||
return slow(
|
||||
JSON.stringify({
|
||||
apiData: {
|
||||
cards: [
|
||||
{
|
||||
items: [
|
||||
{
|
||||
schema: {
|
||||
clicks: [
|
||||
{ title: 'MiSans Global (模拟)', link: 'mock-font-1' },
|
||||
{ title: 'OPPO Sans (模拟)', link: 'mock-font-2' },
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
}),
|
||||
);
|
||||
}
|
||||
if (command.includes('api.zhuti.intl.xiaomi.com')) {
|
||||
return slow(
|
||||
JSON.stringify({
|
||||
apiData: { extraInfo: { themeDetail: { downloadUrl: 'mock/download/path' } } },
|
||||
}),
|
||||
);
|
||||
}
|
||||
// 下载: 后台启动脚本 (立即返回)
|
||||
if (command.includes('nohup sh') && command.includes('mi-font-download.sh')) {
|
||||
return fake('');
|
||||
}
|
||||
// 下载: 轮询日志文件 (模拟完整日志 + 结束标记)
|
||||
if (command.includes('mi-download.log')) {
|
||||
return slow(
|
||||
[
|
||||
'[*] 获取「MiSans Global (模拟)」下载链接...',
|
||||
'[*] 下载: https://f17.market.xiaomi.com/issue/mock/download/path/MiSans%20Global%20(模拟).mtz',
|
||||
'[✓] 下载完成: /storage/emulated/0/Download/xttdown/MiSans_Global_模拟_.mtz (23.3M)',
|
||||
'[*] 解压 mtz 并提取字体...',
|
||||
'[✓] 提取字体:',
|
||||
' /storage/emulated/0/Download/xttdown/extracted/MiSans_Global_模拟_/Roboto-Regular.ttf',
|
||||
' /storage/emulated/0/Download/xttdown/extracted/MiSans_Global_模拟_/MiSans-DemiBold.ttf',
|
||||
'__DONE__',
|
||||
].join('\n'),
|
||||
);
|
||||
}
|
||||
|
||||
if (command.includes('ro.product.model')) return slow('Pixel 8 Pro (模拟设备)');
|
||||
return slow(`(mock 未定义: ${command})`);
|
||||
}
|
||||
|
||||
+7
-1
@@ -16,6 +16,7 @@ import './style.scss';
|
||||
|
||||
import { amStart, exec, enableEdgeToEdge, getSystemInfo, moduleInfo, toast } from './ksu';
|
||||
import { FontFilePicker } from './fontPicker';
|
||||
import { MiFontTool } from './tools';
|
||||
import type { FontSlot } from './types';
|
||||
import * as opentype from 'opentype.js';
|
||||
|
||||
@@ -305,8 +306,9 @@ renderSlots();
|
||||
const homeView = document.getElementById('home-view')!;
|
||||
const configView = document.getElementById('config-view')!;
|
||||
const testView = document.getElementById('test-view')!;
|
||||
const toolsView = document.getElementById('tools-view')!;
|
||||
|
||||
const views = [homeView, configView, testView];
|
||||
const views = [homeView, configView, testView, toolsView];
|
||||
const navBar = document.getElementById('nav-bar') as any;
|
||||
// 悬浮应用按钮 (与配置页绑定, 仅配置页显示)
|
||||
const applyFab = document.getElementById('apply-btn') as HTMLElement;
|
||||
@@ -483,6 +485,10 @@ void document.getElementById('dev-entry')?.addEventListener('click', () => {
|
||||
void amStart(DEV_PROFILE_URL);
|
||||
});
|
||||
|
||||
// ---------------- 工具 ----------------
|
||||
const miFontTool = new MiFontTool();
|
||||
document.getElementById('mi-font-tool')?.addEventListener('click', () => miFontTool.open());
|
||||
|
||||
// ---------------- 测试文本编辑 ----------------
|
||||
// 点击可编辑测试卡片 (简体/繁体/英文) 修改测试文本
|
||||
let editTargetId: string | null = null;
|
||||
|
||||
@@ -560,6 +560,136 @@ md-dialog {
|
||||
}
|
||||
|
||||
// ---------------- 9. 字体测试视图 ----------------
|
||||
// 工具页: 返回栏 (工具详情页)
|
||||
.view-topbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
margin-bottom: 8px;
|
||||
|
||||
.view-topbar-title {
|
||||
font-size: var(--md-sys-typescale-title-medium-size);
|
||||
font-weight: var(--md-sys-typescale-title-medium-weight);
|
||||
color: var(--md-sys-color-on-surface);
|
||||
}
|
||||
}
|
||||
|
||||
// 工具页: 小米主题字体下载
|
||||
.tool-page {
|
||||
.mi-search-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
.mi-result {
|
||||
min-height: 120px;
|
||||
|
||||
.mi-status {
|
||||
padding: 24px 8px;
|
||||
text-align: center;
|
||||
font-size: var(--md-sys-typescale-body-medium-size);
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
white-space: pre-wrap;
|
||||
word-break: break-all;
|
||||
|
||||
&.mi-status-error {
|
||||
color: var(--md-sys-color-error);
|
||||
}
|
||||
|
||||
&.mi-status-done {
|
||||
color: var(--md-sys-color-primary);
|
||||
}
|
||||
}
|
||||
|
||||
.mi-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.mi-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 10px 12px;
|
||||
border-radius: var(--md-shape-corner-medium);
|
||||
background-color: var(--md-sys-color-surface-container-low);
|
||||
|
||||
.mi-item-pic {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
flex-shrink: 0;
|
||||
border-radius: var(--md-shape-corner-small);
|
||||
object-fit: cover;
|
||||
background-color: var(--md-sys-color-surface-container-high);
|
||||
}
|
||||
|
||||
.mi-item-title {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
font-size: var(--md-sys-typescale-body-medium-size);
|
||||
color: var(--md-sys-color-on-surface);
|
||||
word-break: break-all;
|
||||
}
|
||||
}
|
||||
|
||||
.mi-pager {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 16px;
|
||||
margin-top: 16px;
|
||||
|
||||
.mi-page {
|
||||
font-size: var(--md-sys-typescale-label-medium-size);
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
}
|
||||
}
|
||||
|
||||
// 下载日志 (等宽字体)
|
||||
.mi-log {
|
||||
margin: 0;
|
||||
padding: 12px;
|
||||
border-radius: var(--md-shape-corner-medium);
|
||||
background-color: var(--md-sys-color-surface-container-low);
|
||||
font-family: 'Roboto Mono', ui-monospace, monospace;
|
||||
font-size: var(--md-sys-typescale-body-small-size);
|
||||
line-height: 1.6;
|
||||
color: var(--md-sys-color-on-surface);
|
||||
white-space: pre-wrap;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
// 下载进度条 (M3 风格)
|
||||
.mi-progress {
|
||||
padding: 24px 8px;
|
||||
|
||||
.mi-progress-track {
|
||||
width: 100%;
|
||||
height: 4px;
|
||||
border-radius: var(--md-shape-corner-full);
|
||||
background-color: var(--md-sys-color-surface-container-high);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.mi-progress-bar {
|
||||
height: 100%;
|
||||
border-radius: var(--md-shape-corner-full);
|
||||
background-color: var(--md-sys-color-primary);
|
||||
transition: width var(--md-duration-standard) var(--md-easing-standard);
|
||||
}
|
||||
|
||||
.mi-progress-text {
|
||||
margin-top: 10px;
|
||||
text-align: center;
|
||||
font-size: var(--md-sys-typescale-body-small-size);
|
||||
color: var(--md-sys-color-on-surface-variant);
|
||||
}
|
||||
}
|
||||
}
|
||||
.view-test {
|
||||
gap: 16px;
|
||||
|
||||
|
||||
@@ -0,0 +1,202 @@
|
||||
import '@material/web/button/filled-button.js';
|
||||
import { exec } from './ksu';
|
||||
|
||||
// ---------------- 工具: 下载国际版小米主题字体 (v1.0.0) ----------------
|
||||
// 跨域请求与下载/解压全部由 root shell 完成: 前端调用模块内置脚本
|
||||
// mi-font-download.sh, 脚本输出完整日志, 前端只负责展示。
|
||||
|
||||
const SEARCH_API = 'https://thm.market.intl.xiaomi.com/thm/search/npage?category=Font&keywords=';
|
||||
// 搜索结果的图片路径前缀 (pic 字段为相对路径, 拼接此域名 + 处理参数)
|
||||
// 格式: thumbnail/{format}/{尺寸参数}/{pic}, 如 thumbnail/webp/w120q70/ThemeMarket/xxx
|
||||
const PIC_BASE = 'https://t17.market.mi-img.com/thumbnail/webp/w120q70/';
|
||||
// 模块内置下载脚本 (真机路径)
|
||||
const DL_SCRIPT = '/data/adb/modules/FontMM/tools/mi-font-download.sh';
|
||||
|
||||
interface MiFontItem {
|
||||
title: string;
|
||||
id: string;
|
||||
pic: string;
|
||||
}
|
||||
|
||||
// HTML 转义, 防止 API 返回的标题注入
|
||||
function escapeHtml(text: string): string {
|
||||
return text
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, ''');
|
||||
}
|
||||
|
||||
export class MiFontTool {
|
||||
private page!: HTMLElement;
|
||||
private list!: HTMLElement;
|
||||
private keywordInput!: HTMLInputElement;
|
||||
private resultEl!: HTMLElement;
|
||||
|
||||
private keyword = '';
|
||||
private pageNo = 0;
|
||||
private items: MiFontItem[] = [];
|
||||
private downloading = false;
|
||||
|
||||
constructor() {
|
||||
this.initPage();
|
||||
this.bindEvents();
|
||||
}
|
||||
|
||||
private initPage(): void {
|
||||
this.page = document.getElementById('mi-font-page')!;
|
||||
this.list = document.getElementById('tools-list')!;
|
||||
this.keywordInput = document.getElementById('mi-keyword') as HTMLInputElement;
|
||||
this.resultEl = document.getElementById('mi-result')!;
|
||||
document.getElementById('mi-font-back')?.addEventListener('click', () => this.back());
|
||||
}
|
||||
|
||||
private bindEvents(): void {
|
||||
document.getElementById('mi-search-btn')?.addEventListener('click', () => this.startSearch());
|
||||
// 回车触发搜索
|
||||
this.keywordInput?.addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Enter') this.startSearch();
|
||||
});
|
||||
}
|
||||
|
||||
/** 从工具列表进入工具详情页 */
|
||||
public open(): void {
|
||||
this.list.hidden = true;
|
||||
this.page.hidden = false;
|
||||
// 回到工具页顶部
|
||||
this.page.scrollIntoView();
|
||||
this.keywordInput?.focus?.();
|
||||
}
|
||||
|
||||
/** 返回工具列表 */
|
||||
public back(): void {
|
||||
this.page.hidden = true;
|
||||
this.list.hidden = false;
|
||||
}
|
||||
|
||||
private startSearch(): void {
|
||||
if (this.downloading) return; // 下载中禁止新搜索
|
||||
this.keyword = this.keywordInput.value.trim();
|
||||
if (!this.keyword) {
|
||||
this.renderError('请输入字体关键词');
|
||||
return;
|
||||
}
|
||||
this.pageNo = 0;
|
||||
void this.search(this.pageNo);
|
||||
}
|
||||
|
||||
private async search(page: number): Promise<void> {
|
||||
this.renderLoading('正在搜索...');
|
||||
const url = `${SEARCH_API}${encodeURIComponent(this.keyword)}&page=${page}`;
|
||||
try {
|
||||
const { errno, stdout } = await exec(`curl -s '${url}'`);
|
||||
if (errno !== 0) {
|
||||
this.renderError(`搜索请求失败 (errno=${errno})`);
|
||||
return;
|
||||
}
|
||||
const data = JSON.parse(stdout) as any;
|
||||
const cards = data?.apiData?.cards ?? [];
|
||||
this.items = cards.flatMap((c: any) =>
|
||||
(c?.items ?? []).flatMap((it: any) =>
|
||||
(it?.schema?.clicks ?? []).map((cl: any) => ({
|
||||
title: String(cl?.title ?? '未知字体'),
|
||||
id: String(cl?.link ?? ''),
|
||||
pic: String(cl?.pic ?? ''),
|
||||
})),
|
||||
),
|
||||
);
|
||||
if (this.items.length === 0) {
|
||||
this.renderError('未找到相关字体,换个关键词试试');
|
||||
return;
|
||||
}
|
||||
this.renderList();
|
||||
} catch (e) {
|
||||
this.renderError(`解析搜索结果失败: ${String(e)}`);
|
||||
}
|
||||
}
|
||||
|
||||
private async download(item: MiFontItem): Promise<void> {
|
||||
if (this.downloading) return;
|
||||
this.downloading = true;
|
||||
const logFile = '/data/adb/modules/FontMM/webroot/mi-download.log';
|
||||
const encodedTitle = encodeURIComponent(item.title);
|
||||
this.renderLog(`开始下载「${item.title}」...\n`);
|
||||
|
||||
// 后台运行脚本 (exec 立即返回, 不阻塞 UI), 日志重定向到 webroot 下的文件
|
||||
await exec(
|
||||
`rm -f '${logFile}' && nohup sh '${DL_SCRIPT}' '${item.title}' '${item.id}' '${encodedTitle}' > '${logFile}' 2>&1 &`,
|
||||
);
|
||||
|
||||
// 轮询日志文件直到出现结束标记 __DONE__ (最多 5 分钟)
|
||||
let lastLog = '';
|
||||
for (let i = 0; i < 300; i++) {
|
||||
await new Promise((r) => setTimeout(r, 1000));
|
||||
const { stdout } = await exec(`cat '${logFile}' 2>/dev/null || true`);
|
||||
if (stdout && stdout !== lastLog) {
|
||||
lastLog = stdout;
|
||||
this.renderLog(stdout);
|
||||
}
|
||||
if (stdout.includes('__DONE__')) break;
|
||||
}
|
||||
|
||||
this.downloading = false;
|
||||
if (!lastLog.includes('__DONE__')) {
|
||||
this.renderLog(`${lastLog || ''}\n[x] 下载超时或日志文件缺失`);
|
||||
}
|
||||
}
|
||||
|
||||
// ---------- 渲染 ----------
|
||||
|
||||
private renderLoading(text: string): void {
|
||||
this.resultEl.innerHTML = `<div class="mi-status">${escapeHtml(text)}</div>`;
|
||||
}
|
||||
|
||||
private renderError(text: string): void {
|
||||
this.resultEl.innerHTML = `<div class="mi-status mi-status-error">${escapeHtml(text)}</div>`;
|
||||
}
|
||||
|
||||
// 日志展示 (等宽字体, 保留换行)
|
||||
private renderLog(text: string): void {
|
||||
this.resultEl.innerHTML = `<pre class="mi-log">${escapeHtml(text)}</pre>`;
|
||||
}
|
||||
|
||||
private renderList(): void {
|
||||
this.resultEl.innerHTML = `
|
||||
<div class="mi-list">
|
||||
${this.items
|
||||
.map(
|
||||
(item, i) => `
|
||||
<div class="mi-item">
|
||||
<img class="mi-item-pic" src="${PIC_BASE}${escapeHtml(item.pic)}" alt="" onerror="this.style.display='none'">
|
||||
<span class="mi-item-title">${escapeHtml(item.title)}</span>
|
||||
<md-filled-button class="mi-item-dl" data-index="${i}">下载</md-filled-button>
|
||||
</div>`,
|
||||
)
|
||||
.join('')}
|
||||
</div>
|
||||
<div class="mi-pager">
|
||||
<md-text-button id="mi-prev" ${this.pageNo === 0 ? 'disabled' : ''}>上一页</md-text-button>
|
||||
<span class="mi-page">第 ${this.pageNo + 1} 页</span>
|
||||
<md-text-button id="mi-next">下一页</md-text-button>
|
||||
</div>
|
||||
`;
|
||||
this.resultEl.querySelectorAll<HTMLElement>('.mi-item-dl').forEach((btn) => {
|
||||
btn.addEventListener('click', () => {
|
||||
const idx = Number(btn.dataset.index);
|
||||
const item = this.items[idx];
|
||||
if (item) void this.download(item);
|
||||
});
|
||||
});
|
||||
document.getElementById('mi-prev')?.addEventListener('click', () => {
|
||||
if (this.pageNo > 0) {
|
||||
this.pageNo--;
|
||||
void this.search(this.pageNo);
|
||||
}
|
||||
});
|
||||
document.getElementById('mi-next')?.addEventListener('click', () => {
|
||||
this.pageNo++;
|
||||
void this.search(this.pageNo);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user