refactor(config): 配置文件改为单文件 JSON

This commit is contained in:
YuleBest committed 2026-04-09 08:11:37 +08:00
1 parent 74f37460b4
commit 6a4db6d9c1
23 files changed
+782 -256

No files matched your search

+6 -7
View File
@@ -2,7 +2,7 @@
import { listPackages, getPackagesInfo } from 'kernelsu';
import { createIcons, Eye, EyeOff } from 'lucide';
import PinyinMatch from 'pinyin-match';
import { CONFIG_DIR, showToast, runCmd, writeFile } from './utils.js';
import { CONFIG_DIR, showToast, runCmd, readConfig, updateConfig } from './utils.js';
let showingSystemApps = true;
let savedBlacklist = new Set();
@@ -93,9 +93,9 @@ export async function loadApps() {
container.innerHTML = '<div style="text-align:center;padding:20px;color:var(--md-sys-color-on-surface-variant);">加载中...</div>';
try {
// 读取已保存的黑名单(包名条目 + 活动条目分开存储)
const blRes = await runCmd(`cat "${CONFIG_DIR}/blacklist_apps.txt"`);
const allSaved = blRes.errno === 0 ? blRes.stdout.trim().split('\n').filter(Boolean) : [];
// 读取已保存的黑名单(从 JSON 配置读取)
const cfg = await readConfig();
const allSaved = Array.isArray(cfg.blacklist_apps) ? cfg.blacklist_apps : [];
savedBlacklist = new Set(allSaved);
const savedPkgEntries = new Set(allSaved.filter(e => !e.includes('/')));
activityEntries = new Set(allSaved.filter(e => e.includes('/')));
@@ -463,9 +463,8 @@ export function setupAppsEvents() {
const selectedPkgs = [];
document.querySelectorAll('.app-checkbox').forEach(cb => { if (cb.checked) selectedPkgs.push(cb.dataset.pkg); });
const allEntries = [...selectedPkgs, ...activityEntries];
const content = allEntries.join('\n');
const res = await writeFile(`${CONFIG_DIR}/blacklist_apps.txt`, content);
if (res.errno === 0 || res.stdout.includes('OK')) {
const res = await updateConfig({ blacklist_apps: allEntries });
if (res.errno === 0 || res.stdout?.includes('OK')) {
showToast('黑名单保存成功');
savedBlacklist = new Set(allEntries);
updateUnsavedStyling();
+64 -72
View File
@@ -1,7 +1,7 @@
import { ref } from 'vue';
import {
runCmd, writeFile,
CONFIG_DIR, PATH_CONFIG_DIR, BACKUP_DIR, PID_FILE, FLAG_FILE,
runCmd, readConfig, writeConfig, updateConfig,
CONFIG_FILE, BACKUP_CONFIG_FILE, PID_FILE, FLAG_FILE,
DEFAULT_NOW_BRI_FILE, DEFAULT_SYS_MAX_BRI_FILE,
} from '../utils.js';
@@ -37,42 +37,27 @@ export function useConfig() {
const themeMode = ref(localStorage.getItem('themeMode') || 'system');
async function load() {
const [pathNowRes, pathMaxRes, eventsRes] = await Promise.all([
runCmd(`cat "${PATH_CONFIG_DIR}/now_bri_file.txt"`),
runCmd(`cat "${PATH_CONFIG_DIR}/max_bri_file.txt"`),
runCmd(`cat "${CONFIG_DIR}/inotify_events.txt"`),
]);
if (pathNowRes.errno === 0 && pathNowRes.stdout.trim()) nowBriFile.value = pathNowRes.stdout.trim();
if (pathMaxRes.errno === 0 && pathMaxRes.stdout.trim()) sysMaxBriFile.value = pathMaxRes.stdout.trim();
inotifyEvents.value = (eventsRes.errno === 0 && eventsRes.stdout.trim()) ? eventsRes.stdout.trim() : 'c';
const cfg = await readConfig();
if (!cfg || Object.keys(cfg).length === 0) return;
const [uiRes, maxRes, sleepRes, autoRes, stepsRes, logSizeRes, hdrRes] = await Promise.all([
runCmd(`cat "${CONFIG_DIR}/ui_max_bri.txt"`),
runCmd(`cat "${CONFIG_DIR}/max_bri.txt"`),
runCmd(`cat "${CONFIG_DIR}/sleep_time.txt"`),
runCmd(`cat "${CONFIG_DIR}/auto_bri_sleep.txt"`),
runCmd(`cat "${CONFIG_DIR}/steps_num.txt"`),
runCmd(`cat "${CONFIG_DIR}/log_max_size.txt"`),
runCmd(`cat "${CONFIG_DIR}/display_hdr_sleep.txt"`),
]);
uiMaxBri.value = cfg.ui_max_bri != null ? String(cfg.ui_max_bri) : '';
maxBri.value = cfg.max_bri != null ? String(cfg.max_bri) : '';
stepsNum.value = cfg.steps_num != null ? String(cfg.steps_num) : '50';
logMaxSize.value = cfg.log_max_size != null ? String(cfg.log_max_size) : '500';
autoBriSleep.value = cfg.auto_bri_sleep === 1;
displayHdrSleep.value = cfg.display_hdr_sleep === 1;
nowBriFile.value = cfg.now_bri_file || DEFAULT_NOW_BRI_FILE;
sysMaxBriFile.value = cfg.max_bri_file || DEFAULT_SYS_MAX_BRI_FILE;
inotifyEvents.value = cfg.inotify_events || 'c';
if (uiRes.errno === 0) uiMaxBri.value = uiRes.stdout.trim();
if (maxRes.errno === 0) maxBri.value = maxRes.stdout.trim();
if (autoRes.errno === 0) autoBriSleep.value = autoRes.stdout.trim() === '1';
if (hdrRes.errno === 0) displayHdrSleep.value = hdrRes.stdout.trim() === '1';
stepsNum.value = (stepsRes.errno === 0 && stepsRes.stdout.trim()) ? stepsRes.stdout.trim() : '50';
logMaxSize.value = (logSizeRes.errno === 0 && logSizeRes.stdout.trim()) ? logSizeRes.stdout.trim() : '500';
if (sleepRes.errno === 0) {
const tv = sleepRes.stdout.trim();
if (tv && tv.includes('-')) {
sleepMode.value = true;
const [s, e] = tv.split('-');
if (s.length === 4) { sleepStartH.value = s.slice(0, 2); sleepStartM.value = s.slice(2); }
if (e.length === 4) { sleepEndH.value = e.slice(0, 2); sleepEndM.value = e.slice(2); }
} else {
sleepMode.value = false;
}
const st = cfg.sleep_time || '';
if (st && st.includes('-')) {
sleepMode.value = true;
const [s, e] = st.split('-');
if (s.length === 4) { sleepStartH.value = s.slice(0, 2); sleepStartM.value = s.slice(2); }
if (e.length === 4) { sleepEndH.value = e.slice(0, 2); sleepEndM.value = e.slice(2); }
} else {
sleepMode.value = false;
}
}
@@ -83,60 +68,66 @@ export function useConfig() {
}
async function save(toast) {
if (!uiMaxBri.value || !maxBri.value) { toast('亮度值不能为空'); return; }
if (!uiMaxBri.value || !maxBri.value) { toast('亮度値不能为空'); return; }
toast('保存中...');
await Promise.all([
writeFile(`${CONFIG_DIR}/ui_max_bri.txt`, uiMaxBri.value),
writeFile(`${CONFIG_DIR}/max_bri.txt`, maxBri.value),
writeFile(`${CONFIG_DIR}/sleep_time.txt`, getSleepTimeStr()),
writeFile(`${CONFIG_DIR}/auto_bri_sleep.txt`, autoBriSleep.value ? '1' : '0'),
writeFile(`${CONFIG_DIR}/display_hdr_sleep.txt`, displayHdrSleep.value ? '1' : '0'),
writeFile(`${CONFIG_DIR}/steps_num.txt`, stepsNum.value || '50'),
writeFile(`${CONFIG_DIR}/log_max_size.txt`, logMaxSize.value || '500'),
]);
// 读取当前配置(保留 blacklist_apps 等其他字段)
const current = await readConfig();
await writeConfig({
...current,
ui_max_bri: parseInt(uiMaxBri.value) || 0,
max_bri: parseInt(maxBri.value) || 0,
steps_num: parseInt(stepsNum.value) || 50,
log_max_size: parseInt(logMaxSize.value) || 500,
auto_bri_sleep: autoBriSleep.value ? 1 : 0,
display_hdr_sleep: displayHdrSleep.value ? 1 : 0,
sleep_time: getSleepTimeStr(),
});
await runCmd(`rm -f "${FLAG_FILE}"`);
const pidRes = await runCmd(`cat "${PID_FILE}"`);
toast(pidRes.errno === 0 && pidRes.stdout.trim() ? '配置已保存 (下次调整时生效)' : '配置已保存 (服务未运行)');
}
async function saveAdvanced(toast, onPathsChanged) {
const nowV = nowBriFile.value || DEFAULT_NOW_BRI_FILE;
const maxV = sysMaxBriFile.value || DEFAULT_SYS_MAX_BRI_FILE;
const evtV = inotifyEvents.value || 'c';
toast('保存中...');
await Promise.all([
writeFile(`${PATH_CONFIG_DIR}/now_bri_file.txt`, nowV),
writeFile(`${PATH_CONFIG_DIR}/max_bri_file.txt`, maxV),
writeFile(`${CONFIG_DIR}/inotify_events.txt`, evtV),
]);
await updateConfig({
now_bri_file: nowBriFile.value || DEFAULT_NOW_BRI_FILE,
max_bri_file: sysMaxBriFile.value || DEFAULT_SYS_MAX_BRI_FILE,
inotify_events: inotifyEvents.value || 'c',
});
onPathsChanged?.();
toast('高级设置已保存,需重启服务生效');
}
async function resetToDefaults(toast) {
toast('正在恢复默认配置...');
const [uiRes, maxRes, sleepRes, autoRes, stepsRes, logSizeRes] = await Promise.all([
runCmd(`cat "${BACKUP_DIR}/ui_max_bri.txt"`),
runCmd(`cat "${BACKUP_DIR}/max_bri.txt"`),
runCmd(`cat "${BACKUP_DIR}/sleep_time.txt"`),
runCmd(`cat "${BACKUP_DIR}/auto_bri_sleep.txt"`),
runCmd(`cat "${BACKUP_DIR}/steps_num.txt"`),
runCmd(`cat "${BACKUP_DIR}/log_max_size.txt"`),
]);
if (uiRes.errno === 0) uiMaxBri.value = uiRes.stdout.trim();
if (maxRes.errno === 0) maxBri.value = maxRes.stdout.trim();
autoBriSleep.value = autoRes.errno === 0 ? autoRes.stdout.trim() === '1' : true;
stepsNum.value = stepsRes.errno === 0 ? stepsRes.stdout.trim() : '50';
logMaxSize.value = logSizeRes.errno === 0 ? logSizeRes.stdout.trim() : '500';
if (sleepRes.errno === 0 && sleepRes.stdout.trim().includes('-')) {
const backupRes = await runCmd(`cat "${BACKUP_CONFIG_FILE}"`);
if (backupRes.errno !== 0 || !backupRes.stdout.trim()) {
toast('备份文件不存在,无法恢复');
return;
}
let backup;
try { backup = JSON.parse(backupRes.stdout); } catch { toast('备份文件损坏'); return; }
uiMaxBri.value = backup.ui_max_bri != null ? String(backup.ui_max_bri) : '';
maxBri.value = backup.max_bri != null ? String(backup.max_bri) : '';
autoBriSleep.value = backup.auto_bri_sleep === 1;
displayHdrSleep.value = backup.display_hdr_sleep === 1;
stepsNum.value = backup.steps_num != null ? String(backup.steps_num) : '50';
logMaxSize.value = backup.log_max_size != null ? String(backup.log_max_size) : '500';
nowBriFile.value = backup.now_bri_file || DEFAULT_NOW_BRI_FILE;
sysMaxBriFile.value = backup.max_bri_file || DEFAULT_SYS_MAX_BRI_FILE;
inotifyEvents.value = backup.inotify_events || 'c';
const st = backup.sleep_time || '';
if (st && st.includes('-')) {
sleepMode.value = true;
const [s, e] = sleepRes.stdout.trim().split('-');
const [s, e] = st.split('-');
if (s.length === 4) { sleepStartH.value = s.slice(0, 2); sleepStartM.value = s.slice(2); }
if (e.length === 4) { sleepEndH.value = e.slice(0, 2); sleepEndM.value = e.slice(2); }
if (e.length === 4) { sleepEndH.value = e.slice(0, 2); sleepEndM.value = e.slice(2); }
} else {
sleepMode.value = true;
sleepStartH.value = '19'; sleepStartM.value = '00';
sleepEndH.value = '06'; sleepEndM.value = '00';
sleepEndH.value = '06'; sleepEndM.value = '00';
}
await save(toast);
}
@@ -167,7 +158,6 @@ export function useConfig() {
html.classList.remove('light', 'dark');
if (mode === 'light') html.classList.add('light');
else if (mode === 'dark') html.classList.add('dark');
// 'system': no class, CSS @media handles it
}
return {
@@ -180,3 +170,5 @@ export function useConfig() {
saveWebUIConfig, applyZoom, applyTheme,
};
}
+9 -13
View File
@@ -1,8 +1,7 @@
import { ref, computed } from 'vue';
import {
runCmd,
CONFIG_DIR, PATH_CONFIG_DIR, PID_FILE,
STOP_FLAG_FILE,
runCmd, readConfig,
PID_FILE, STOP_FLAG_FILE,
DEFAULT_NOW_BRI_FILE, DEFAULT_SYS_MAX_BRI_FILE,
} from '../utils.js';
@@ -40,12 +39,9 @@ export function useStatus() {
async function _ensurePaths() {
if (_nowBriFile && _sysMaxBriFile) return;
const [r1, r2] = await Promise.all([
runCmd(`cat "${PATH_CONFIG_DIR}/now_bri_file.txt"`),
runCmd(`cat "${PATH_CONFIG_DIR}/max_bri_file.txt"`),
]);
_nowBriFile = (r1.errno === 0 && r1.stdout.trim()) ? r1.stdout.trim() : DEFAULT_NOW_BRI_FILE;
_sysMaxBriFile = (r2.errno === 0 && r2.stdout.trim()) ? r2.stdout.trim() : DEFAULT_SYS_MAX_BRI_FILE;
const cfg = await readConfig();
_nowBriFile = cfg.now_bri_file || DEFAULT_NOW_BRI_FILE;
_sysMaxBriFile = cfg.max_bri_file || DEFAULT_SYS_MAX_BRI_FILE;
}
function invalidatePaths() {
@@ -65,13 +61,14 @@ export function useStatus() {
sysMaxBri.value = sRes.errno === 0 ? sRes.stdout.trim() : '255';
}
const [pidRes, stopRes, autoBriRes, hdrRes, sleepRes] = await Promise.all([
const [pidRes, stopRes, autoBriRes, hdrRes] = await Promise.all([
runCmd(`cat "${PID_FILE}"`),
runCmd(`[ -f "${STOP_FLAG_FILE}" ] && echo "1" || echo "0"`),
runCmd(`settings get system screen_brightness_mode`),
runCmd(`dumpsys display 2>/dev/null | sed -n 's/.*hdrSdrRatio \\([0-9.]*\\).*/\\1/p' | head -n 1`),
runCmd(`cat "${CONFIG_DIR}/sleep_time.txt"`),
]);
const cfgForSleep = await readConfig();
const sleepTimeStr = cfgForSleep.sleep_time || '';
isPaused.value = stopRes.errno === 0 && stopRes.stdout.trim() === '1';
const pidStr = pidRes.errno === 0 ? pidRes.stdout.trim() : '';
@@ -92,8 +89,7 @@ export function useStatus() {
hdrRatio.value = (hdrRaw && /^\d+(\.\d+)?$/.test(hdrRaw)) ? parseFloat(hdrRaw).toFixed(2) : '-';
// 计算睡眠状态
const sleepTime = sleepRes.errno === 0 ? sleepRes.stdout.trim() : '';
sleepStatus.value = _calcSleep(sleepTime);
sleepStatus.value = _calcSleep(sleepTimeStr);
}
function _calcSleep(sleepTime) {
+2
View File
@@ -128,6 +128,8 @@
}
.header-status.status-running .status-dot {
background-color: #4caf50;
box-shadow: 0 0 8px rgba(76, 175, 80, 0.6);
animation: status-pulse-green 2s infinite;
}
+46 -22
View File
@@ -1,12 +1,13 @@
import { exec } from 'kernelsu';
export const CONFIG_DIR = '/data/adb/modules/LuminPro/config';
export const PATH_CONFIG_DIR = '/data/adb/modules/LuminPro/config/path';
export const BACKUP_DIR = '/data/adb/modules/LuminPro/config/.backup';
export const PID_FILE = '/data/adb/modules/LuminPro/pid/inotifyd.pid';
export const FLAG_FILE = '/data/adb/modules/LuminPro/pid/up.flag';
export const STOP_FLAG_FILE = '/data/adb/modules/LuminPro/pid/stop.flag';
export const LOG_FILE = '/data/adb/modules/LuminPro/service.log';
export const MODULE_DIR = '/data/adb/modules/LuminPro';
export const CONFIG_DIR = `${MODULE_DIR}/config`;
export const CONFIG_FILE = `${MODULE_DIR}/config/config.json`;
export const BACKUP_CONFIG_FILE = `${MODULE_DIR}/config/.backup/config.json`;
export const PID_FILE = `${MODULE_DIR}/pid/inotifyd.pid`;
export const FLAG_FILE = `${MODULE_DIR}/pid/up.flag`;
export const STOP_FLAG_FILE = `${MODULE_DIR}/pid/stop.flag`;
export const LOG_FILE = `${MODULE_DIR}/service.log`;
export const DEFAULT_NOW_BRI_FILE = '/sys/class/backlight/panel0-backlight/brightness';
export const DEFAULT_SYS_MAX_BRI_FILE = '/sys/class/backlight/panel0-backlight/max_brightness';
@@ -22,38 +23,61 @@ export async function runCmd(cmd) {
const res = await exec(cmd);
return res;
} catch (e) {
// 调试模式数据模拟
console.warn(`[DEBUG] 执行命令失败 (可能是非 KSU 环境): ${cmd}`);
// 基础配置模拟
if (cmd.includes('cat') && cmd.includes('ui_max_bri.txt')) return { errno: 0, stdout: '4095', stderr: '' };
if (cmd.includes('cat') && cmd.includes('max_bri.txt')) return { errno: 0, stdout: '3500', stderr: '' };
if (cmd.includes('cat') && (cmd.includes('now_bri_file.txt') || cmd.includes('max_bri_file.txt'))) return { errno: 0, stdout: '/sys/mock/brightness', stderr: '' };
if (cmd.includes('cat') && cmd.includes('inotify_events.txt')) return { errno: 0, stdout: 'c', stderr: '' };
if (cmd.includes('cat') && cmd.includes('log_max_size.txt')) return { errno: 0, stdout: '1024', stderr: '' };
if (cmd.includes('cat') && cmd.includes('steps_num.txt')) return { errno: 0, stdout: '100', stderr: '' };
// JSON 配置模拟
if (cmd.includes('cat') && cmd.includes('config.json')) {
return { errno: 0, stdout: JSON.stringify({
ui_max_bri: 4095, max_bri: 3500, steps_num: 100, log_max_size: 1024,
auto_bri_sleep: 1, display_hdr_sleep: 0, sleep_time: '1900-0600',
inotify_events: 'c',
now_bri_file: '/sys/mock/brightness',
max_bri_file: '/sys/mock/max_brightness',
blacklist_apps: ['com.example.app'],
}), stderr: '' };
}
// 状态模拟
if (cmd.includes('cat') && (cmd.includes('brightness') || cmd.includes('now_bri_file.txt'))) return { errno: 0, stdout: '1200', stderr: '' };
if (cmd.includes('cat') && (cmd.includes('max_brightness') || cmd.includes('max_bri_file.txt'))) return { errno: 0, stdout: '4095', stderr: '' };
if (cmd.includes('cat') && cmd.includes('inotifyd.pid')) return { errno: 0, stdout: '12345', stderr: '' };
if (cmd.includes('settings get system screen_brightness_mode')) return { errno: 0, stdout: '1', stderr: '' };
if (cmd.includes('[ -f') && cmd.includes('stop.flag')) return { errno: 0, stdout: '0', stderr: '' };
if (cmd.includes('cat') && (cmd.includes('brightness') || cmd.includes('now_bri'))) return { errno: 0, stdout: '1200', stderr: '' };
if (cmd.includes('cat') && (cmd.includes('max_brightness') || cmd.includes('max_bri'))) return { errno: 0, stdout: '4095', stderr: '' };
// 日志模拟
if (cmd.includes('tail') && cmd.includes('service.log')) {
return { errno: 0, stdout: '[2026-04-07 15:40:01] [INFO] 服务启动成功\n[2026-04-07 15:41:05] [DEBUG] 亮度调整: 1200 -> 1250\n[2026-04-07 15:42:10] [INFO] 切换至峰值亮度模式\n[2026-04-07 15:43:22] [WARN] 检测到极低亮度设定', stderr: '' };
return { errno: 0, stdout: '[04-07 15:40:01] [service] [INFO ] LuminPro 服务启动\n[04-07 15:41:05] [up] [INFO ] 触发提升: 当前亮度 1200 ≥ 阈値 1000\n[04-07 15:42:10] [up] [SUCCESS ] 亮度提升完成 (3500)', stderr: '' };
}
// 文档模拟
if (cmd.includes('cat') && cmd.includes('.md')) return { errno: 0, stdout: '# 调试模式说明\n\n当前处于 **Web 调试模式**,显示的是模拟出的测试数据。\n\n- 状态卡片:全部固定为运行中。\n- 应用列表:预设了 150 个常用模拟应用。\n- 按钮:所有变更仅在当前页面生效,不会写入手机文件系统。', stderr: '' };
if (cmd.includes('cat') && cmd.includes('.txt')) return { errno: 0, stdout: '这是 NOTE.txt 的模拟内容,用于测试纯文本渲染。', stderr: '' };
if (cmd.includes('cat') && cmd.includes('.md')) return { errno: 0, stdout: '# 调试模式\n\n当前处于 **Web 调试模式**,显示的是模拟测试数据。', stderr: '' };
if (cmd.includes('cat') && cmd.includes('.txt')) return { errno: 0, stdout: '这是 NOTE.txt 的模拟内容。', stderr: '' };
return { errno: -1, stdout: '', stderr: String(e) };
}
}
// 读取完整 JSON 配置
export async function readConfig() {
const res = await runCmd(`cat "${CONFIG_FILE}"`);
if (res.errno !== 0 || !res.stdout.trim()) return {};
try { return JSON.parse(res.stdout); } catch { return {}; }
}
// 写入完整 JSON 配置
export async function writeConfig(obj) {
const content = JSON.stringify(obj).replace(/'/g, "'\\''" );
return runCmd(`printf '%s' '${content}' > "${CONFIG_FILE}"`);
}
// 合并更新 JSON 配置(保留其他字段)
export async function updateConfig(updates) {
const current = await readConfig();
return writeConfig({ ...current, ...updates });
}
// 将文件内容写入指定路径
export async function writeFile(path, content) {
const safeContent = String(content).replace(/'/g, "'\\''");
return runCmd(`echo -n '${safeContent}' > "${path}"`);
const safeContent = String(content).replace(/'/g, "'\\''" );
return runCmd(`printf '%s' '${safeContent}' > "${path}"`);
}
+5 -70
View File
@@ -1,28 +1,16 @@
<script setup>
import { ref, onMounted } from "vue";
import { ref } from "vue";
import Button from "@/components/ui/Button.vue";
import { ExternalLink, FileText, BookOpen, ScrollText, StickyNote, X, Github } from "lucide-vue-next";
import { moduleInfo } from "kernelsu";
import { BookOpen, ScrollText, StickyNote, X, Github } from "lucide-vue-next";
import { runCmd } from "../utils.js";
const MODULE_DIR = '/data/adb/modules/LuminPro';
const moduleVersion = ref("");
const sheetOpen = ref(false);
const sheetTitle = ref("");
const sheetContent = ref("");
const sheetLoading = ref(false);
onMounted(() => {
try {
const info = JSON.parse(moduleInfo());
moduleVersion.value = info.version || '';
} catch {
moduleVersion.value = '[debug]';
}
});
// 通过 KernelSU runCmd 读取模块本地文件
const moduleDocs = [
{ title: "README", file: `${MODULE_DIR}/README.md`, icon: BookOpen, md: true },
{ title: "README (EN)", file: `${MODULE_DIR}/README_en.md`, icon: BookOpen, md: true },
@@ -30,12 +18,6 @@ const moduleDocs = [
{ title: "NOTE", file: `${MODULE_DIR}/NOTE.txt`, icon: StickyNote, md: false },
];
// 通过 fetch 读取 webroot/docs/
const webDocs = [
{ title: "Web UI 使用文档", path: "/docs/webui.md", icon: FileText },
{ title: "Web UI API 文档", path: "/docs/webui-api.md", icon: FileText },
];
function mdToHtml(text) {
return text
.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;")
@@ -63,22 +45,6 @@ async function openModuleDoc(doc) {
}
}
async function openWebDoc(doc) {
sheetTitle.value = doc.title;
sheetContent.value = "";
sheetLoading.value = true;
sheetOpen.value = true;
try {
const res = await fetch(doc.path);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
sheetContent.value = mdToHtml(await res.text());
} catch (e) {
sheetContent.value = `加载失败: ${e.message}`;
} finally {
sheetLoading.value = false;
}
}
function closeSheet() {
sheetOpen.value = false;
}
@@ -87,18 +53,6 @@ function closeSheet() {
<template>
<div style="display:contents">
<section class="card" id="about-section">
<!-- 项目信息 -->
<div class="about-hero">
<div class="about-logo">
<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<circle cx="12" cy="12" r="4"/><path d="M12 2v2"/><path d="M12 20v2"/><path d="m4.93 4.93 1.41 1.41"/><path d="m17.66 17.66 1.41 1.41"/><path d="M2 12h2"/><path d="M20 12h2"/><path d="m6.34 17.66-1.41 1.41"/><path d="m19.07 4.93-1.41 1.41"/>
</svg>
</div>
<h2 class="about-name">LuminPro</h2>
<p class="about-desc">日用屏幕亮度强化</p>
<span class="about-version-badge">{{ moduleVersion ? `v${moduleVersion}` : "V2.2" }}</span>
</div>
<!-- 模块文档 -->
<div class="about-section-title">模块文档</div>
<div class="about-list">
@@ -110,38 +64,19 @@ function closeSheet() {
>
<component :is="doc.icon" :size="18" class="about-list-icon" />
<span>{{ doc.title }}</span>
<ExternalLink :size="14" class="about-list-chevron" />
</button>
</div>
<!-- Web UI 文档 -->
<div class="about-section-title">Web UI 文档</div>
<div class="about-list">
<button
v-for="doc in webDocs"
:key="doc.path"
class="about-list-item"
@click="openWebDoc(doc)"
>
<component :is="doc.icon" :size="18" class="about-list-icon" />
<span>{{ doc.title }}</span>
<ExternalLink :size="14" class="about-list-chevron" />
</button>
</div>
<!-- 链接列表 -->
<div class="about-section-title">链接</div>
<div class="about-list">
<a
<button
class="about-list-item"
href="https://github.com/YuleBest/LuminPro"
target="_blank"
rel="noopener"
@click="runCmd('am start -a android.intent.action.VIEW -d \'https://github.com/YuleBest/LuminPro\'')"
>
<Github :size="18" class="about-list-icon" />
<span>GitHub 项目主页</span>
<ExternalLink :size="14" class="about-list-chevron" />
</a>
</button>
</div>
<p class="about-footer">Made with ❤ by Yule</p>