dsh-foxy-game 0.1.32 → 0.1.34

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.
Files changed (3) hide show
  1. package/README.md +3 -0
  2. package/lib/client.js +106 -2
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -166,4 +166,7 @@ test/ Node 内置测试
166
166
 
167
167
  MIT
168
168
 
169
+ ## 遇到问题
169
170
 
171
+ - 提交 [GitHub Issue](https://github.com/Kun-Fox/dsh-foxy-game/issues/new/choose)
172
+ - 或直接联系作者 QQ:**2242711967**
package/lib/client.js CHANGED
@@ -6,6 +6,110 @@ window.__ModuleLoader__.load({
6
6
  const React = require('react')
7
7
  const h = React.createElement
8
8
  const PANEL_ID = 'dsh-foxy-game'
9
+ // ---- 问题反馈(GitHub issue + QQ)------------------------------------
10
+ // 这份实现分布在 dsh-foxy / dsh-foxy-bili / -game / -memory / -oopz / -weibo
11
+ // 六个仓库里,内容一致,只有 FEEDBACK_REPO 不同;改动时请一并同步。
12
+ const FEEDBACK_REPO = 'dsh-foxy-game'
13
+ const FEEDBACK_QQ = '2242711967'
14
+
15
+ function FeedbackCard() {
16
+ const [copied, setCopied] = React.useState(false)
17
+ const copyQQ = () => {
18
+ const done = () => {
19
+ setCopied(true)
20
+ setTimeout(() => setCopied(false), 1600)
21
+ }
22
+ const fallback = () => {
23
+ try {
24
+ const field = document.createElement('textarea')
25
+ field.value = FEEDBACK_QQ
26
+ document.body.appendChild(field)
27
+ field.select()
28
+ document.execCommand('copy')
29
+ document.body.removeChild(field)
30
+ } catch {
31
+ // 复制失败也把号码显示出来,用户可手动抄写
32
+ }
33
+ done()
34
+ }
35
+ if (navigator.clipboard && navigator.clipboard.writeText) {
36
+ navigator.clipboard.writeText(FEEDBACK_QQ).then(done, fallback)
37
+ } else {
38
+ fallback()
39
+ }
40
+ }
41
+ const issueUrl = 'https://github.com/Kun-Fox/' + FEEDBACK_REPO + '/issues/new/choose'
42
+ const btnStyle = {
43
+ display: 'inline-flex',
44
+ alignItems: 'center',
45
+ gap: '6px',
46
+ padding: '7px 12px',
47
+ border: '1px solid rgba(127,127,127,.34)',
48
+ borderRadius: '7px',
49
+ background: 'transparent',
50
+ color: 'inherit',
51
+ font: 'inherit',
52
+ fontSize: '12px',
53
+ textDecoration: 'none',
54
+ cursor: 'pointer',
55
+ }
56
+ return h(
57
+ 'section',
58
+ {
59
+ style: {
60
+ margin: '12px 0 4px',
61
+ flex: '0 0 auto',
62
+ padding: '16px 18px',
63
+ border: '1px solid rgba(127,127,127,.26)',
64
+ borderRadius: '10px',
65
+ },
66
+ },
67
+ h('div', { style: { fontSize: '13px', fontWeight: 600, marginBottom: '4px' } }, '遇到问题?'),
68
+ h(
69
+ 'div',
70
+ { style: { fontSize: '12px', opacity: 0.75, lineHeight: 1.7 } },
71
+ '反馈时请附上 DSH 版本、插件版本和报错截图,能快很多。',
72
+ ),
73
+ h(
74
+ 'div',
75
+ { style: { display: 'flex', flexWrap: 'wrap', gap: '10px', marginTop: '12px' } },
76
+ h('a', { href: issueUrl, target: '_blank', rel: 'noreferrer noopener', style: btnStyle }, '提交 GitHub Issue'),
77
+ h(
78
+ 'button',
79
+ { type: 'button', onClick: copyQQ, style: btnStyle },
80
+ copied ? '已复制:' + FEEDBACK_QQ : '复制 QQ:' + FEEDBACK_QQ,
81
+ ),
82
+ ),
83
+ )
84
+ }
85
+
86
+ function withFeedback(Component) {
87
+ // 子插件的面板根节点是 height:100% + overflow:auto 的滚动容器,
88
+ // 必须用 flex 列布局给它一个确定高度,否则会失去滚动能力。
89
+ function FoxyPanelWithFeedback() {
90
+ return h(
91
+ 'div',
92
+ {
93
+ style: {
94
+ height: '100%',
95
+ minHeight: 0,
96
+ display: 'flex',
97
+ flexDirection: 'column',
98
+ overflow: 'hidden',
99
+ },
100
+ },
101
+ h(
102
+ 'div',
103
+ { style: { flex: '1 1 auto', minHeight: 0, display: 'flex', flexDirection: 'column' } },
104
+ h(Component),
105
+ ),
106
+ h(FeedbackCard),
107
+ )
108
+ }
109
+ FoxyPanelWithFeedback.displayName = 'FoxyPanelWithFeedback'
110
+ return FoxyPanelWithFeedback
111
+ }
112
+
9
113
 
10
114
  function GameIcon({ size = 18 }) {
11
115
  return h('svg', {
@@ -522,7 +626,7 @@ window.__ModuleLoader__.load({
522
626
  const root = window.__FOXY_CONSOLE__ || (window.__FOXY_CONSOLE__ = { pages: [], listeners: new Set() })
523
627
  if (!Array.isArray(root.pages)) root.pages = []
524
628
  if (!(root.listeners instanceof Set)) root.listeners = new Set()
525
- const entry = { id: PANEL_ID, label: '游戏', order: 18, Component: GamePage }
629
+ const entry = { id: PANEL_ID, label: '游戏', order: 18, Component: withFeedback(GamePage) }
526
630
  const index = root.pages.findIndex((page) => page.id === entry.id)
527
631
  if (index >= 0) root.pages[index] = entry
528
632
  else root.pages.push(entry)
@@ -538,7 +642,7 @@ window.__ModuleLoader__.load({
538
642
  function apply(ctx) {
539
643
  registerConsolePage()
540
644
  ctx.slots.inject('main', () =>
541
- ctx.slots.register({ name: 'main', key: PANEL_ID, inject: () => ({ workbench: true }) }, GamePage),
645
+ ctx.slots.register({ name: 'main', key: PANEL_ID, inject: () => ({ workbench: true }) }, () => h(withFeedback(GamePage))),
542
646
  )
543
647
  }
544
648
  exports.name = name
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-foxy-game",
3
- "version": "0.1.32",
3
+ "version": "0.1.34",
4
4
  "description": "Let Foxy play games with DSH: window capture, vision decisions, background input, local voice overlay and optional memory adapters.",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",