@lzpenguin/server 1.1.5 → 1.1.6

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 (2) hide show
  1. package/index.js +5 -9
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -85,18 +85,14 @@ export class RiffleServer {
85
85
  throw new Error('timestamp is required');
86
86
  }
87
87
 
88
- // 从浏览器 URL 参数中读取 post_id 和 token
88
+ // 从全局变量或浏览器 URL 参数中读取 post_id 和 token
89
89
  let postId;
90
90
  let token;
91
91
 
92
- if (isBrowser && typeof window !== 'undefined' && window.location) {
93
- const urlParams = new URLSearchParams(window.location.search);
94
- if (urlParams.has('post_id')) {
95
- postId = parseInt(urlParams.get('post_id'), 10);
96
- }
97
- if (urlParams.has('token')) {
98
- token = urlParams.get('token');
99
- }
92
+ if (isBrowser && typeof window !== 'undefined') {
93
+ const postIdRaw = window.__RIFFLE_POST_ID__ || new URLSearchParams(location.search).get('post_id');
94
+ postId = postIdRaw ? parseInt(postIdRaw, 10) : undefined;
95
+ token = window.__RIFFLE_TOKEN__ || new URLSearchParams(location.search).get('token');
100
96
  }
101
97
 
102
98
  if (!postId) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lzpenguin/server",
3
- "version": "1.1.5",
3
+ "version": "1.1.6",
4
4
  "description": "Riffle 游戏服务器 WebSocket 客户端 SDK",
5
5
  "license": "ISC",
6
6
  "author": "lzpenguin",