dsh-pick 0.7.3 → 0.7.4
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/package.json +1 -1
- package/plugin/client.js +40 -0
package/package.json
CHANGED
package/plugin/client.js
CHANGED
|
@@ -59,6 +59,45 @@ window.__ModuleLoader__.load({
|
|
|
59
59
|
}, children)
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
const REPO = 'AIcivilization/dsh-pick'
|
|
63
|
+
const STAR_KEY = 'dsh-pick-stars-v1'
|
|
64
|
+
|
|
65
|
+
/** 「⭐ Star」:打开 GitHub 仓库页,用户在那里点星。顺带显示现有星数(取不到就不显示) */
|
|
66
|
+
function StarLink() {
|
|
67
|
+
const [stars, setStars] = useState(() => {
|
|
68
|
+
try { const c = JSON.parse(sessionStorage.getItem(STAR_KEY) || 'null'); return c ? c.n : null } catch { return null }
|
|
69
|
+
})
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
let alive = true
|
|
72
|
+
try { if (sessionStorage.getItem(STAR_KEY)) return } catch {}
|
|
73
|
+
fetch('https://api.github.com/repos/' + REPO, { headers: { accept: 'application/vnd.github+json' } })
|
|
74
|
+
.then(r => (r.ok ? r.json() : null))
|
|
75
|
+
.then(j => {
|
|
76
|
+
if (!alive || !j || typeof j.stargazers_count !== 'number') return
|
|
77
|
+
setStars(j.stargazers_count)
|
|
78
|
+
try { sessionStorage.setItem(STAR_KEY, JSON.stringify({ n: j.stargazers_count })) } catch {}
|
|
79
|
+
})
|
|
80
|
+
.catch(() => {})
|
|
81
|
+
return () => { alive = false }
|
|
82
|
+
}, [])
|
|
83
|
+
return h('a', {
|
|
84
|
+
href: 'https://github.com/' + REPO,
|
|
85
|
+
target: '_blank',
|
|
86
|
+
rel: 'noopener',
|
|
87
|
+
title: L('觉得好用?到 GitHub 给 dsh-pick 点个星', 'Like it? Star dsh-pick on GitHub'),
|
|
88
|
+
style: {
|
|
89
|
+
display: 'inline-flex', alignItems: 'center', gap: 4, textDecoration: 'none',
|
|
90
|
+
fontSize: 12, lineHeight: '18px', padding: '2px 10px', borderRadius: 6, whiteSpace: 'nowrap',
|
|
91
|
+
border: '1px solid ' + C.border, color: C.text,
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
h('span', { 'aria-hidden': true }, '⭐'),
|
|
95
|
+
'Star',
|
|
96
|
+
typeof stars === 'number' && stars > 0
|
|
97
|
+
? h('span', { style: { color: C.sub, fontVariantNumeric: 'tabular-nums', borderLeft: '1px solid ' + C.border, paddingLeft: 6, marginLeft: 2 } }, stars.toLocaleString())
|
|
98
|
+
: null)
|
|
99
|
+
}
|
|
100
|
+
|
|
62
101
|
/** 一条给用户自己在终端执行的命令:等宽显示,旁边一个「复制」 */
|
|
63
102
|
function CommandLine({ command }) {
|
|
64
103
|
const [copied, setCopied] = useState(false)
|
|
@@ -156,6 +195,7 @@ window.__ModuleLoader__.load({
|
|
|
156
195
|
h('span', { style: { fontSize: 15, fontWeight: 650 } }, 'dsh-pick'),
|
|
157
196
|
info && info.running ? h('span', { style: { fontSize: 12, color: C.sub, fontVariantNumeric: 'tabular-nums' } }, 'v' + info.running) : null,
|
|
158
197
|
h(Btn, { onClick: upd.onClick, disabled: upd.disabled || busy, primary: upd.primary, title: upd.title }, upd.label),
|
|
198
|
+
h(StarLink),
|
|
159
199
|
h('span', { style: { flex: 1 } }),
|
|
160
200
|
phase === 'removed'
|
|
161
201
|
? h('span', { style: { fontSize: 12, color: C.sub } }, L('已卸载,重启 DSH 后彻底移除', 'Uninstalled; restart DSH to finish'))
|