dsh-ponlay-erp 1.8.0 → 1.8.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.
Files changed (3) hide show
  1. package/client.js +11 -1
  2. package/index.js +16 -6
  3. package/package.json +1 -1
package/client.js CHANGED
@@ -26,6 +26,11 @@ window.__ModuleLoader__.load({
26
26
 
27
27
  const delay = (ms) => new Promise((resolve) => window.setTimeout(resolve, ms))
28
28
 
29
+ function activeLang(localeFace) {
30
+ const id = String(localeFace.getSnapshot().active || '').toLowerCase()
31
+ return id.startsWith('zh') ? 'zh' : 'en'
32
+ }
33
+
29
34
  // ---------------------------------------------------------------
30
35
  // Dictionaries
31
36
  // ---------------------------------------------------------------
@@ -204,6 +209,7 @@ window.__ModuleLoader__.load({
204
209
  const rect = useSyncExternalStore(store.subscribe, store.getRect, store.getRect)
205
210
  useSyncExternalStore(localeFace.subscribe, localeFace.getSnapshot, localeFace.getSnapshot)
206
211
 
212
+ const lang = activeLang(localeFace)
207
213
  const [started, setStarted] = useState(false)
208
214
  const [attempt, setAttempt] = useState(0)
209
215
  const [proxy, setProxy] = useState({ phase: 'loading', port: 0, target: DEFAULT_TARGET })
@@ -294,7 +300,7 @@ window.__ModuleLoader__.load({
294
300
  const ready = proxy.phase === 'ready'
295
301
  // A stale browser token must not outlive the server-side session: the
296
302
  // reset page clears the proxy origin's storage and forwards to /login.
297
- const targetPath = judged && !loggedIn ? '/_ponlay/reset' : '/'
303
+ const targetPath = judged && !loggedIn ? `/_ponlay/reset?ponlay_lang=${lang}` : '/'
298
304
  const src = ready && judged ? `http://${PROXY_HOST}:${proxy.port}${targetPath}` : ''
299
305
  const visible = active && Boolean(rect) && rect.width > 0 && rect.height > 0
300
306
  const style = {
@@ -524,6 +530,10 @@ window.__ModuleLoader__.load({
524
530
  // ---------------------------------------------------------------
525
531
 
526
532
  const CSS = `
533
+ /* DSH 0.2.2-rc.1 mounts the collapsed-sidebar reopen/New Session controls in
534
+ the leading seat (z-index 15), beneath shell.overlay (z-index 20). The ERP
535
+ surface lives in that overlay, so lift the native seat above it. */
536
+ [data-shell-leading]{z-index:25!important}
527
537
  .erp-anchor{width:100%;height:100%;min-height:0;background:var(--dsw-alias-bg-base)}
528
538
  .erp-surface{position:fixed;z-index:6;display:flex;flex-direction:column;overflow:hidden;background:var(--dsw-alias-bg-layer-1)}
529
539
  .erp-surface[data-hidden="true"]{visibility:hidden;pointer-events:none}
package/index.js CHANGED
@@ -24,12 +24,20 @@ const INFO_PATH = '/plugin/ponlay-erp/info'
24
24
  const STATE_PATH = '/plugin/ponlay-erp/state'
25
25
  const CONFIG_PATH = '/plugin/ponlay-erp/config'
26
26
  const RESET_PATH = '/_ponlay/reset'
27
- const RESET_HTML = `<!doctype html>
28
- <html lang="zh"><head><meta charset="utf-8"><title>Ponlay ERP</title></head>
27
+ /** Reset page: clear the stale ERP session but seed the UI language. */
28
+ function resetHtml(lang) {
29
+ const locale = lang === 'en' ? 'en' : 'zh'
30
+ return `<!doctype html>
31
+ <html lang="${locale}"><head><meta charset="utf-8"><title>Ponlay ERP</title></head>
29
32
  <body><script>
30
- try { localStorage.clear(); sessionStorage.clear(); } catch (error) {}
33
+ try {
34
+ localStorage.clear();
35
+ sessionStorage.clear();
36
+ localStorage.setItem('GlobalState', JSON.stringify({ language: '${locale}' }));
37
+ } catch (error) {}
31
38
  location.replace('/login');
32
39
  </script></body></html>`
40
+ }
33
41
  const PORT_CANDIDATES = [4317, 4318, 4319, 4320, 4321, 4322, 4323, 4324, 4325, 4326]
34
42
  const MAX_UPSTREAM_BYTES = 8 * 1024 * 1024
35
43
  const MAX_CONFIG_BODY_BYTES = 64 * 1024
@@ -248,13 +256,15 @@ function createProxyHandler(jar, port, target) {
248
256
 
249
257
  // A stale browser token must not outlive the server-side session: clear the
250
258
  // proxy origin's storage, then let the ERP show its own login page.
251
- if (req.url === RESET_PATH) {
259
+ const requestUrl = new URL(req.url || '/', 'http://127.0.0.1')
260
+ if (requestUrl.pathname === RESET_PATH) {
261
+ const html = resetHtml(requestUrl.searchParams.get('ponlay_lang') === 'en' ? 'en' : 'zh')
252
262
  res.writeHead(200, {
253
263
  'content-type': 'text/html; charset=utf-8',
254
264
  'cache-control': 'no-store',
255
- 'content-length': Buffer.byteLength(RESET_HTML),
265
+ 'content-length': Buffer.byteLength(html),
256
266
  })
257
- res.end(req.method === 'HEAD' ? undefined : RESET_HTML)
267
+ res.end(req.method === 'HEAD' ? undefined : html)
258
268
  return
259
269
  }
260
270
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-ponlay-erp",
3
- "version": "1.8.0",
3
+ "version": "1.8.2",
4
4
  "description": "Ponlay ERP system embedded in DeepSeek Harness: the ERP login page or signed-in layout fills the main area, with a configurable system address.",
5
5
  "type": "module",
6
6
  "license": "MIT",