diff --git a/NOTE.txt b/NOTE.txt index 7cd0fd2..b21bc68 100755 --- a/NOTE.txt +++ b/NOTE.txt @@ -1,5 +1,5 @@ -======================================= - LuminPro V2.3 — 日用屏幕亮度强化 +======================================= + LuminPro — 日用屏幕亮度强化 作者: 酷安@Yule ======================================= diff --git a/webui/index.html b/webui/index.html index 3bc5fe8..5727580 100644 --- a/webui/index.html +++ b/webui/index.html @@ -2,7 +2,7 @@ - + LuminPro diff --git a/webui/src/api/ksu.js b/webui/src/api/ksu.js index 8f4500c..f794f22 100644 --- a/webui/src/api/ksu.js +++ b/webui/src/api/ksu.js @@ -1,4 +1,4 @@ -import { exec, moduleInfo } from 'kernelsu' +import { exec, moduleInfo, enableEdgeToEdge } from 'kernelsu' import { devMock } from './devMock.js' export const MODULE_DIR = '/data/adb/modules/LuminPro' @@ -41,6 +41,19 @@ export function shellQuote(value) { return `'${String(value).replace(/'/g, "'\\''")}'` } +/** + * 启用 edge-to-edge:内容延伸至状态栏/手势条区域, + * insets.css 的 --window-inset-* 随之生效,顶栏/底栏据此避让。 + * 不同 KernelSU 版本的命名不同,逐个尝试,全部不可用则忽略。 + */ +export function applyEdgeToEdge() { + try { + enableEdgeToEdge(true) + } catch { + /* 老版本没有该 API:布局仍可用,只是安全区取 0 */ + } +} + /** 读取模块版本(module.prop 的 version) */ export function moduleVersion() { try { diff --git a/webui/src/main.js b/webui/src/main.js index 88b4de0..99b22ab 100644 --- a/webui/src/main.js +++ b/webui/src/main.js @@ -1,4 +1,5 @@ import { createApp } from 'vue' +import { applyEdgeToEdge } from './api/ksu.js' import './mwc.js' import './theme/tokens.css' @@ -8,4 +9,5 @@ import './theme/app.css' import App from './App.vue' +applyEdgeToEdge() createApp(App).mount('#app') diff --git a/webui/src/views/AboutView.vue b/webui/src/views/AboutView.vue index 58267f0..d88a3f3 100644 --- a/webui/src/views/AboutView.vue +++ b/webui/src/views/AboutView.vue @@ -12,11 +12,58 @@ let renderMarkdown = null async function ensureMarkdown() { if (renderMarkdown) return renderMarkdown const { default: MarkdownIt } = await import('markdown-it') - const md = new MarkdownIt({ html: false, linkify: true, breaks: true }) + // README 使用了 HTML 与 GitHub 提示块(> [!TIP]),需要一并支持 + const md = new MarkdownIt({ html: true, linkify: true, breaks: true }) + + md.core.ruler.push('github-alerts', (state) => { + const tokens = state.tokens + for (let i = 0; i < tokens.length; i++) { + const token = tokens[i] + if (token.type !== 'blockquote_open') continue + const inline = tokens[i + 2] + if (!inline || inline.type !== 'inline') continue + const match = /^\[!([A-Z]+)\]\s*/.exec(inline.content) + if (!match) continue + const kind = match[1].toLowerCase() + const label = ALERT_LABELS[kind] + if (!label) continue + token.attrJoin('class', `md-alert md-alert--${kind}`) + inline.content = inline.content.replace(match[0], '') + inline.children[0].content = inline.children[0].content.replace(match[0], '') + const marker = new state.Token('html_block', '', 0) + marker.content = `

${label}

` + const closeIdx = findBlockquoteClose(tokens, i) + if (closeIdx > 0) tokens.splice(closeIdx, 0, marker) + } + return true + }) + renderMarkdown = (text) => md.render(text) return renderMarkdown } +/** GitHub 提示块的标题文案 */ +const ALERT_LABELS = { + note: '备注', + tip: '提示', + important: '重要', + warning: '警告', + caution: '注意', +} + +/** 找到与 openIdx 配对的 blockquote_close 下标 */ +function findBlockquoteClose(tokens, openIdx) { + let depth = 0 + for (let i = openIdx; i < tokens.length; i++) { + if (tokens[i].type === 'blockquote_open') depth++ + else if (tokens[i].type === 'blockquote_close') { + depth-- + if (depth === 0) return i + } + } + return -1 +} + const docs = [ { key: 'README.md', label: '模块说明', icon: BookOpen }, { key: 'changelog.md', label: '更新日志', icon: ScrollText }, @@ -144,6 +191,57 @@ async function openLink(url) {