@telosmaylx/dsh-session-notify 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/client.js +20 -21
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -646,7 +646,7 @@ window.__ModuleLoader__.load({
|
|
|
646
646
|
* - denied:浏览器已屏蔽(如 Edge 对"不熟悉"站点的自动阻止),引导到地址栏手动允许;
|
|
647
647
|
* - undefined:非安全上下文(http://IP)或浏览器不支持,引导改用页内提示。
|
|
648
648
|
*/
|
|
649
|
-
function notificationPermissionRow(t) {
|
|
649
|
+
function notificationPermissionRow(t, onRequest) {
|
|
650
650
|
var statusText, hintText, statusColor = SUBTLE
|
|
651
651
|
var hasApi = typeof Notification !== 'undefined'
|
|
652
652
|
if (!hasApi) {
|
|
@@ -664,7 +664,6 @@ window.__ModuleLoader__.load({
|
|
|
664
664
|
statusText = t.permDefault
|
|
665
665
|
hintText = t.permDefaultHint
|
|
666
666
|
}
|
|
667
|
-
void permTick // 依赖刷新计数:授权后重渲染读取最新状态
|
|
668
667
|
return h('div', {
|
|
669
668
|
key: 'perm',
|
|
670
669
|
style: { display: 'flex', flexDirection: 'column', gap: '6px', padding: '12px 0', borderTop: DIVIDER },
|
|
@@ -674,7 +673,7 @@ window.__ModuleLoader__.load({
|
|
|
674
673
|
h('span', { style: { fontSize: '12px', color: statusColor } }, statusText),
|
|
675
674
|
hasApi && Notification.permission === 'default'
|
|
676
675
|
? h('button', {
|
|
677
|
-
type: 'button', onClick:
|
|
676
|
+
type: 'button', onClick: onRequest,
|
|
678
677
|
style: { appearance: 'none', font: 'inherit', fontSize: '12px', cursor: 'pointer', padding: '2px 10px', borderRadius: '999px', border: '1px solid var(--dsw-alias-border-l2, rgba(127,127,127,0.35))', background: 'none', color: 'var(--dsw-alias-label-secondary, inherit)' },
|
|
679
678
|
}, t.permRequest)
|
|
680
679
|
: null,
|
|
@@ -685,23 +684,6 @@ window.__ModuleLoader__.load({
|
|
|
685
684
|
)
|
|
686
685
|
}
|
|
687
686
|
|
|
688
|
-
/** 用户手势内请求通知权限(Chromium 忽略非手势的自动请求,必须由点击触发)。 */
|
|
689
|
-
function requestPermissionNow() {
|
|
690
|
-
try {
|
|
691
|
-
if (typeof Notification !== 'undefined' && Notification.permission === 'default') {
|
|
692
|
-
var req = Notification.requestPermission()
|
|
693
|
-
if (req && typeof req.then === 'function') {
|
|
694
|
-
req.then(function (p) {
|
|
695
|
-
log('user-gesture notification permission → ' + p)
|
|
696
|
-
setPermTick(permTick + 1)
|
|
697
|
-
}).catch(function () { setPermTick(permTick + 1) })
|
|
698
|
-
} else {
|
|
699
|
-
setPermTick(permTick + 1)
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
} catch (e) { /* noop */ }
|
|
703
|
-
}
|
|
704
|
-
|
|
705
687
|
/**
|
|
706
688
|
* Chip 模板编辑器(contentEditable):
|
|
707
689
|
* - 普通文字就是文字,动态信息渲染成内联胶囊({duration} 等代码永不露出);
|
|
@@ -947,6 +929,23 @@ window.__ModuleLoader__.load({
|
|
|
947
929
|
var permTick = permTickState[0]
|
|
948
930
|
var setPermTick = permTickState[1]
|
|
949
931
|
|
|
932
|
+
/** 用户手势内请求通知权限(Chromium 忽略非手势的自动请求,必须由点击触发);授权结果经重渲染刷新状态区。 */
|
|
933
|
+
function requestPermissionNow() {
|
|
934
|
+
try {
|
|
935
|
+
if (typeof Notification !== 'undefined' && Notification.permission === 'default') {
|
|
936
|
+
var req = Notification.requestPermission()
|
|
937
|
+
if (req && typeof req.then === 'function') {
|
|
938
|
+
req.then(function (p) {
|
|
939
|
+
log('user-gesture notification permission → ' + p)
|
|
940
|
+
setPermTick(permTick + 1)
|
|
941
|
+
}).catch(function () { setPermTick(permTick + 1) })
|
|
942
|
+
} else {
|
|
943
|
+
setPermTick(permTick + 1)
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
} catch (e) { /* noop */ }
|
|
947
|
+
}
|
|
948
|
+
|
|
950
949
|
var ready = snap.status === 'ready'
|
|
951
950
|
var value = (snap && snap.value) || {}
|
|
952
951
|
var cur = draft === null ? value : draft
|
|
@@ -1258,7 +1257,7 @@ window.__ModuleLoader__.load({
|
|
|
1258
1257
|
})))
|
|
1259
1258
|
})
|
|
1260
1259
|
// 通知权限状态区(footer 之上):授权状态 + 引导(Edge 自动屏蔽等场景一目了然)
|
|
1261
|
-
rows.push(notificationPermissionRow(t))
|
|
1260
|
+
rows.push(notificationPermissionRow(t, requestPermissionNow))
|
|
1262
1261
|
rows.push(h('div', {
|
|
1263
1262
|
key: 'footer',
|
|
1264
1263
|
style: { borderTop: DIVIDER, display: 'flex', justifyContent: 'flex-end', alignItems: 'center', gap: '8px', padding: '12px 0 4px' },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@telosmaylx/dsh-session-notify",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "DSH session completion notifier: appends a plugin system message to the session log on turn/end and pushes browser notifications (Web Notification + toast), with a fully customizable official settings panel (presets, 5-language templates, cache-hit rate & tok/s from official projections).",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|