feat: add notification-access setting item with jump

This commit is contained in:
2026-08-16 18:12:06 +08:00
parent 8e722dc545
commit e2a289a4b0
3 changed files with 64 additions and 2 deletions
+22 -2
View File
@@ -1,5 +1,5 @@
// 设置页:Miuix Preference 分组 + 玻璃条目(仅 UI 骨架,交互留后续
// Settings page: Miuix Preference groups + glass items (UI skeleton only; interactions later)
// 设置页:Miuix Preference 分组 + 玻璃条目(通知使用权为可用交互项
// Settings page: Miuix Preference groups + glass items (notification access is interactive)
window.loadSettings = function () {
const page = document.querySelector('[data-page="settings"]');
if (page.dataset.loaded) return; page.dataset.loaded = '1';
@@ -7,10 +7,30 @@ window.loadSettings = function () {
<div class="st-group">显示</div>
<div class="st-item"><span class="lbl">跟随系统主题</span><span class="sw on"><i></i></span></div>
<div class="st-item"><span class="lbl">屏幕亮度</span><span class="slider"><i></i></span></div>
<div class="st-group">权限</div>
<div class="st-item" id="notif-access">
<span class="lbl">通知使用权(媒体卡)</span>
<span class="arrow" id="notif-access-state"></span>
</div>
<div class="st-group">网络</div>
<div class="st-item"><span class="lbl">webAPP 服务器地址</span><span class="arrow"></span></div>
<div class="st-item"><span class="lbl">检查更新</span><span class="arrow"></span></div>
<div class="st-group">关于</div>
<div class="st-item"><span class="lbl">版本 0.1.0</span><span class="arrow"></span></div>
</div>`;
setupNotificationAccess(page);
};
// 通知使用权授权项:异步查状态,未授权点击跳转系统授权页
// Notification-access item: async state check, tap to open the system grant page
function setupNotificationAccess(page) {
const item = page.querySelector('#notif-access');
const state = page.querySelector('#notif-access-state');
bridge.call('getNotificationAccess').then(granted => {
state.textContent = granted ? '已开启 ✓' : '去开启 ';
if (granted) state.style.color = 'var(--accent)';
}).catch(() => {});
item.onclick = () => {
bridge.call('requestNotificationAccess').catch(() => {});
};
}