@hyzyn/dsh-docker 0.8.1 → 0.9.0-rc.2

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.
@@ -30,11 +30,17 @@ export function reconnectTail(initialTail, isReconnect) {
30
30
  * onEnd?: (payload: Record<string, unknown> | null, controls: { reconnect: () => void }) => void,
31
31
  * onError?: (message: string, controls: { close: () => void, reconnect: () => void }) => void,
32
32
  * onStatus?: (status: 'connecting' | 'open' | 'reconnecting' | 'closed') => void,
33
+ * t?: (key: string) => string,
33
34
  * }} options
34
35
  * @returns {{ close: () => void, reconnect: () => void }}
35
36
  */
36
37
  export function subscribeLogStream(options) {
37
38
  const { buildUrl, tail } = options
39
+ /*
40
+ * 翻译函数由调用方**当参数传进来**(见 docs/i18n.md):目录内联在 client-src/index.js,
41
+ * 兄弟模块 import 它就会成环。没有传(离线冒烟)时退回「键名原样」,不抛错。
42
+ */
43
+ const t = typeof options.t === 'function' ? options.t : (key) => key
38
44
  let source = null
39
45
  let closed = false
40
46
  let attempt = 0
@@ -116,7 +122,7 @@ export function subscribeLogStream(options) {
116
122
  if (source !== next) return
117
123
  // 服务端 event:error 是带 data 的 MessageEvent;连接层错误是普通 Event
118
124
  if (typeof event.data === 'string' && event.data !== '') {
119
- let message = '日志流异常'
125
+ let message = t('error.logStream')
120
126
  try {
121
127
  const payload = JSON.parse(event.data)
122
128
  if (payload !== null && typeof payload.message === 'string') message = payload.message