Compare commits

..
Author SHA1 Message Date
a149fe3973 chore(mobile): 将安卓/苹果应用标识统一为 cn.solsum.jinxunda
后续极光与厂商推送将使用该包名;旧测试版需卸载重装。

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: multica-agent <github@multica.ai>
2026-08-30 18:30:17 +08:00
83 changed files with 168 additions and 1785 deletions
-11
View File
@@ -84,14 +84,3 @@ ALERTMANAGER_PORT=19093
GRAFANA_PORT=13000
NODE_EXPORTER_PORT=19100
GRAFANA_URL="http://127.0.0.1:13000/"
# ===== 极光离线推送(OpenIM push)=====
# AppKey 可以进配置;Master Secret 禁止写在本文件、Git、日志或客户端。
# 公网部署时由 scripts/load-jpush-secret.sh 从
# /root/.config/jinxunda/jpush_master_secret 注入 JPUSH_MASTER_SECRET。
OPENIM_PUSH_ENABLE=
JPUSH_APPKEY=95fc2352648a7d4568ac8d72
JPUSH_PUSH_URL=https://api.jpush.cn/v3/push
# 必须加引号:值含分号。compose 读 .env 无妨;不要用 shell source/. 加载未加引号的副本。
JPUSH_PUSH_INTENT="intent:#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;component=cn.solsum.jinxunda/cn.solsum.jinxunda.MainActivity;end"
-3
View File
@@ -5,7 +5,4 @@
# 不匹配 pc-client/src/components 等源码子目录,保证其可入库
/components/
.selftest/
pc-client/dist-portal/
data/
**/agconnect-services.json
+2 -4
View File
@@ -77,13 +77,11 @@ docker compose up -d # 再启动
## 客户端接入参数(自测通过后)
- OpenIM API: `http://<服务器IP>:10002`(公网测试见 `deploy/public/README.md`:`https://jxd.jinniu.ink`)
- OpenIM WebSocket: `ws://<服务器IP>:10001`(公网:`wss://jxd.jinniu.ink/msg_gateway`)
- OpenIM API: `http://<服务器IP>:10002`
- OpenIM WebSocket: `ws://<服务器IP>:10001`
- LiveKit: `ws://<服务器IP>:17880`(17880 为默认信令端口;改端口时必须 `.env` 的 `LIVEKIT_PORT`、`config/livekit.yaml` 的 `port`、`docker-compose.yaml` 的容器侧端口三者一起改),API Key/Secret 见 `.env` 的 `LIVEKIT_API_KEY` / `LIVEKIT_API_SECRET`
- 测试账号:`test001` / `test002`(由自测脚本注册);语音通话时两名用户以各自 identity 进同一房间即可
公网测试部署(不改本机内网步骤):见 `deploy/public/README.md`。施工员不执行该部署。
## 常见问题
- **文件/语音能发但打不开**:`MINIO_EXTERNAL_ADDRESS` 没写成客户端能访问的 IP。改 `.env` 后 `docker compose up -d` 重建 openim-server。
+1 -1
View File
@@ -1,6 +1,6 @@
FROM node:20-alpine
WORKDIR /app
COPY server.js portal-sso.js admin.html ./
COPY server.js admin.html ./
ENV PORT=10010 DATA_FILE=/app/data/employees.json
EXPOSE 10010
CMD ["node", "server.js"]
+1 -7
View File
@@ -41,7 +41,7 @@ POST /api/login
| POST | `/api/admin/reset_password` | 重置密码 `{staffNo, password}` |
| POST | `/api/admin/delete` | 删除 `{staffNo}`,立即无法登录并被踢下线(OpenIM 侧同名用户保留但本服务不再为其签发令牌,等于不可用) |
管理页:浏览器打开 `http://<服务器IP>:10010/`(公网反代场景为 `https://<域名>/account/`),输入管理口令即可操作,无需写接口。页面会按当前地址自动带上部署前缀请求 `/api/admin/...`,不要改成以 `/` 开头的绝对路径,否则公网会被 OpenIM 根路由接走。
管理页:浏览器打开 `http://<服务器IP>:10010/`,输入管理口令即可操作,无需写接口。
## 部署
@@ -57,9 +57,3 @@ docker compose up -d --build account-server
- `ACCOUNT_ADMIN_TOKEN`:管理口令,**部署时务必改掉默认值**
重启/升级:改代码后 `docker compose up -d --build account-server`;数据在 `./data/account/employees.json`,重建容器不丢。
管理页热修自测(不连现网、不读真实员工数据):
```bash
node account-service/test-admin-page.js
```
-79
View File
@@ -1,79 +0,0 @@
/**
* 员工管理页前端请求辅助(与 admin.html 内联函数保持一致,供自动化检查引用)。
* 零 npm 依赖。
*/
'use strict';
function adminApiUrl(apiPath, pagePath) {
const pathname = pagePath != null
? pagePath
: (typeof location !== 'undefined' ? location.pathname : '/');
let prefix = String(pathname || '/');
if (prefix.length > 1 && prefix.endsWith('/')) prefix = prefix.slice(0, -1);
if (prefix === '/admin' || prefix.endsWith('/admin')) {
prefix = prefix.slice(0, -6);
}
if (prefix === '/') prefix = '';
const route = apiPath.charAt(0) === '/' ? apiPath : '/' + apiPath;
return prefix + route;
}
function httpStatusHint(status) {
const n = Number(status);
if (n === 401) return '管理口令错误或未提供';
if (n === 403) return '没有权限执行此操作';
if (n === 404) return '接口地址不正确,请从管理页重新打开';
if (n === 502 || n === 503 || n === 504) return '服务暂时不可用,请稍后重试';
if (n >= 500) return '服务暂时出错,请稍后重试';
if (n >= 400) return '请求失败,请稍后重试';
return '';
}
function toUserMessage(err) {
const raw = err && typeof err === 'object' && err.message != null
? String(err.message)
: String(err || '');
const s = raw.trim();
if (!s) return '请求失败,请稍后重试';
if (/unexpected end of json|failed to execute ['"]json['"]|json parse|not valid json|unexpected token/i.test(s)) {
return '服务器返回了无法识别的内容';
}
if (/failed to fetch|networkerror|load failed|network request failed/i.test(s)) {
return '网络异常,请检查连接后重试';
}
return s;
}
async function readAdminJson(res) {
const status = res.status;
const ctype = String((res.headers && res.headers.get && res.headers.get('content-type')) || '').toLowerCase();
let text = '';
try {
text = await res.text();
} catch {
throw new Error(httpStatusHint(status) || '无法读取服务器响应');
}
const trimmed = (text || '').trim();
if (!trimmed) {
throw new Error(httpStatusHint(status) || '服务器没有返回内容');
}
const looksJson = ctype.indexOf('json') !== -1 || trimmed.charAt(0) === '{' || trimmed.charAt(0) === '[';
if (!looksJson) {
throw new Error(httpStatusHint(status) || '服务器返回了无法识别的内容');
}
let j;
try {
j = JSON.parse(trimmed);
} catch {
throw new Error(httpStatusHint(status) || '服务器返回了无法识别的内容');
}
if (!j || typeof j !== 'object') {
throw new Error(httpStatusHint(status) || '服务器返回了无法识别的内容');
}
if (j.code !== 0) {
throw new Error(j.msg || httpStatusHint(status) || '请求失败');
}
return j.data;
}
module.exports = { adminApiUrl, httpStatusHint, toUserMessage, readAdminJson };
+15 -94
View File
@@ -87,94 +87,15 @@ $('token').value = localStorage.getItem('adminToken') || '';
function saveToken() { localStorage.setItem('adminToken', $('token').value.trim()); show('口令已保存', true); loadList(); }
function show(text, ok) { const m = $('msg'); m.textContent = text; m.className = 'msg ' + (ok ? 'okm' : 'err'); }
function adminApiUrl(apiPath, pagePath) {
const pathname = pagePath != null
? pagePath
: (typeof location !== 'undefined' ? location.pathname : '/');
let prefix = String(pathname || '/');
if (prefix.length > 1 && prefix.endsWith('/')) prefix = prefix.slice(0, -1);
if (prefix === '/admin' || prefix.endsWith('/admin')) {
prefix = prefix.slice(0, -6);
}
if (prefix === '/') prefix = '';
const route = apiPath.charAt(0) === '/' ? apiPath : '/' + apiPath;
return prefix + route;
}
function httpStatusHint(status) {
const n = Number(status);
if (n === 401) return '管理口令错误或未提供';
if (n === 403) return '没有权限执行此操作';
if (n === 404) return '接口地址不正确,请从管理页重新打开';
if (n === 502 || n === 503 || n === 504) return '服务暂时不可用,请稍后重试';
if (n >= 500) return '服务暂时出错,请稍后重试';
if (n >= 400) return '请求失败,请稍后重试';
return '';
}
function toUserMessage(err) {
const raw = err && typeof err === 'object' && err.message != null
? String(err.message)
: String(err || '');
const s = raw.trim();
if (!s) return '请求失败,请稍后重试';
if (/unexpected end of json|failed to execute ['"]json['"]|json parse|not valid json|unexpected token/i.test(s)) {
return '服务器返回了无法识别的内容';
}
if (/failed to fetch|networkerror|load failed|network request failed/i.test(s)) {
return '网络异常,请检查连接后重试';
}
return s;
}
async function readAdminJson(res) {
const status = res.status;
const ctype = String((res.headers && res.headers.get && res.headers.get('content-type')) || '').toLowerCase();
let text = '';
try {
text = await res.text();
} catch {
throw new Error(httpStatusHint(status) || '无法读取服务器响应');
}
const trimmed = (text || '').trim();
if (!trimmed) {
throw new Error(httpStatusHint(status) || '服务器没有返回内容');
}
const looksJson = ctype.indexOf('json') !== -1 || trimmed.charAt(0) === '{' || trimmed.charAt(0) === '[';
if (!looksJson) {
throw new Error(httpStatusHint(status) || '服务器返回了无法识别的内容');
}
let j;
try {
j = JSON.parse(trimmed);
} catch {
throw new Error(httpStatusHint(status) || '服务器返回了无法识别的内容');
}
if (!j || typeof j !== 'object') {
throw new Error(httpStatusHint(status) || '服务器返回了无法识别的内容');
}
if (j.code !== 0) {
throw new Error(j.msg || httpStatusHint(status) || '请求失败');
}
return j.data;
}
async function api(path, body) {
let res;
try {
res = await fetch(adminApiUrl(path), {
method: body ? 'POST' : 'GET',
headers: { 'Content-Type': 'application/json', 'admin-token': $('token').value.trim() },
body: body ? JSON.stringify(body) : undefined,
});
} catch (e) {
throw new Error(toUserMessage(e));
}
try {
return await readAdminJson(res);
} catch (e) {
throw new Error(toUserMessage(e));
}
const res = await fetch(path, {
method: body ? 'POST' : 'GET',
headers: { 'Content-Type': 'application/json', 'admin-token': $('token').value.trim() },
body: body ? JSON.stringify(body) : undefined,
});
const j = await res.json();
if (j.code !== 0) throw new Error(j.msg || '请求失败');
return j.data;
}
async function loadList() {
@@ -194,7 +115,7 @@ async function loadList() {
<button class="danger" onclick="deleteEmp('${e.staffNo}')">删除</button>
</td>
</tr>`).join('') || '<tr><td colspan="5" style="color:#98a2b3">暂无员工,请先导入</td></tr>';
} catch (e) { show(toUserMessage(e), false); }
} catch (e) { show(e.message, false); }
}
async function toggle(staffNo, enable) {
@@ -202,7 +123,7 @@ async function toggle(staffNo, enable) {
await api('/api/admin/' + (enable ? 'enable' : 'disable'), { staffNo });
show((enable ? '已启用 ' : '已停用 ') + staffNo, true);
loadList();
} catch (e) { show(toUserMessage(e), false); }
} catch (e) { show(e.message, false); }
}
async function resetPwd(staffNo) {
@@ -212,7 +133,7 @@ async function resetPwd(staffNo) {
await api('/api/admin/reset_password', { staffNo, password: pwd });
show('已重置 ' + staffNo + ' 的密码', true);
loadList();
} catch (e) { show(toUserMessage(e), false); }
} catch (e) { show(e.message, false); }
}
async function addEmp() {
@@ -221,7 +142,7 @@ async function addEmp() {
show('已添加 ' + $('addNo').value.trim(), true);
$('addNo').value = $('addName').value = $('addPwd').value = '';
loadList();
} catch (e) { show(toUserMessage(e), false); }
} catch (e) { show(e.message, false); }
}
async function doImport() {
@@ -230,7 +151,7 @@ async function doImport() {
const bad = d.results.filter(r => !r.ok);
show('导入完成:成功 ' + d.imported + ' / ' + d.total + (bad.length ? '\n失败明细:\n' + bad.map(b => b.line + ' → ' + b.msg).join('\n') : ''), bad.length === 0);
loadList();
} catch (e) { show(toUserMessage(e), false); }
} catch (e) { show(e.message, false); }
}
// 直接选择模板 CSV 文件导入,不用复制粘贴
@@ -245,7 +166,7 @@ async function importFile(input) {
const bad = d.results.filter(r => !r.ok);
show('文件「' + file.name + '」导入完成:成功 ' + d.imported + ' / ' + d.total + (bad.length ? '\n失败明细:\n' + bad.map(b => b.line + ' → ' + b.msg).join('\n') : ''), bad.length === 0);
loadList();
} catch (e) { show(toUserMessage(e), false); }
} catch (e) { show(e.message, false); }
}
async function deleteEmp(staffNo) {
@@ -254,7 +175,7 @@ async function deleteEmp(staffNo) {
await api('/api/admin/delete', { staffNo });
show('已删除 ' + staffNo, true);
loadList();
} catch (e) { show(toUserMessage(e), false); }
} catch (e) { show(e.message, false); }
}
// 下载 CSV 导入模板(加 BOM 让 Excel 正确识别中文)
-142
View File
@@ -1,142 +0,0 @@
'use strict';
const crypto = require('crypto');
const fs = require('fs');
const path = require('path');
const digest = s => crypto.createHash('sha256').update(s).digest('hex');
const hex = s => typeof s === 'string' && /^[a-f0-9]{64}$/.test(s);
// Browser-bound portal tickets. OpenIM user IDs are permanent empids, not mutable staff numbers.
module.exports = function createPortalBridge(deps, env = process.env) {
const enabled = env.PORTAL_SSO_ENABLED === '1';
if (!enabled) return { handle: async () => false };
const portal = new URL(env.PORTAL_PUBLIC_URL);
const internal = new URL(env.PORTAL_INTERNAL_URL);
const secret = env.PORTAL_SSO_SECRET || '';
if (!['http:', 'https:'].includes(internal.protocol) || portal.protocol !== 'https:' || secret.length < 32)
throw new Error('Invalid portal configuration');
const file = path.join(path.dirname(env.DATA_FILE), 'portal-sessions.json');
let sessions = fs.existsSync(file) ? JSON.parse(fs.readFileSync(file, 'utf8')) : {};
const cookieFlags = '; HttpOnly; Secure; SameSite=Lax; Path=/';
const cookieName = '__Host-jxd_portal_sid';
const save = () => {
fs.mkdirSync(path.dirname(file), { recursive: true });
fs.writeFileSync(file + '.tmp', JSON.stringify(sessions), { mode: 0o600 });
fs.renameSync(file + '.tmp', file);
};
const cookies = req => Object.fromEntries(String(req.headers.cookie || '').split(';').map(p => {
const n = p.indexOf('='); return [p.slice(0, n).trim(), p.slice(n + 1)];
}));
async function call(operation, payload) {
const response = await fetch(new URL('/api/sso/apps/jinxunda/' + operation, internal), {
method: 'POST', redirect: 'error', signal: AbortSignal.timeout(5000),
headers: { Authorization: 'Bearer ' + secret, 'Content-Type': 'application/json' },
body: JSON.stringify(payload),
});
if (!response.ok) throw new Error('Portal unavailable');
return response.json();
}
function reply(res, status, value) {
res.writeHead(status, { 'Content-Type': 'application/json; charset=utf-8',
'Cache-Control': 'no-store', 'Referrer-Policy': 'no-referrer' });
res.end(JSON.stringify(value));
}
function redirect(res, location, cookie) {
res.writeHead(303, { Location: location, 'Set-Cookie': cookie,
'Cache-Control': 'no-store', 'Referrer-Policy': 'no-referrer' }); res.end();
}
async function valid(row) {
const r = await call('introspect', { session_handle: row.handle });
return r.active && r.identity?.empid === row.empid && r.identity?.local_uid === row.localUid;
}
async function revoke(key) {
const row = sessions[key];
if (!row) return;
row.revoked = true;
save();
// Persist revocation before kicking; failed kicks are retried by the sweep.
const token = await deps.getAdminToken();
const result = await deps.imApi('/auth/force_logout', { platformID: 5, userID: row.imUid }, token);
if (result.errCode !== 0) throw new Error('IM revocation pending');
delete sessions[key]; save();
}
let sweeping = false;
const timer = setInterval(async () => {
if (sweeping) return;
sweeping = true;
try {
for (const [key, row] of Object.entries(sessions)) {
let active = false;
try { active = !row.revoked && await valid(row); } catch { /* fail closed */ }
if (!active) { try { await revoke(key); } catch { /* retry next sweep */ } }
}
} finally { sweeping = false; }
}, 10000);
timer.unref();
return {
close: () => clearInterval(timer),
async handle(req, res) {
const url = new URL(req.url, 'http://localhost');
const route = url.pathname;
if (route === '/portal-sso') {
if (req.method !== 'GET') { reply(res, 405, { message: 'Method not allowed' }); return true; }
try {
const ticket = url.searchParams.get('ticket');
if (!ticket) {
const verifier = crypto.randomBytes(32).toString('hex');
const theme = url.searchParams.get('theme') === 'night' ? 'night' : 'day';
const value = [verifier, Date.now(), theme].join('.');
redirect(res, new URL('/api/sso/apps/jinxunda/authorize?challenge=' + digest(verifier), portal).href,
'__Host-jxd_proof=' + value + cookieFlags + '; Max-Age=120');
return true;
}
const [verifier, timestamp, theme] = (cookies(req)['__Host-jxd_proof'] || '').split('.');
if (!hex(ticket) || !hex(verifier) || !Number.isFinite(Number(timestamp))
|| Date.now() - Number(timestamp) > 120000 || Number(timestamp) > Date.now())
throw new Error('Invalid browser proof');
const result = await call('exchange', { ticket, verifier });
const who = result.identity;
if (!hex(result.session_handle) || !/^[a-f0-9-]{36}$/.test(who?.empid || '')
|| !Number.isSafeInteger(who?.local_uid) || who.local_uid < 1)
throw new Error('Invalid identity');
// OpenIM rejects UUID hyphens. Preserve empid and derive its lossless 32-hex representation.
const imUid = who.empid.replace(/-/g, '');
if (!/^[a-f0-9]{32}$/.test(imUid)) throw new Error('Invalid permanent identity');
if (!await deps.ensureImUser(imUid, who.display_name)) throw new Error('IM unavailable');
const token = await deps.getImUserToken(imUid, 5);
const sid = crypto.randomBytes(32).toString('hex');
sessions[digest(sid)] = { handle: result.session_handle, empid: who.empid, imUid,
localUid: who.local_uid, staffNo: who.username, name: who.display_name,
token: token.token, theme: theme === 'night' ? 'night' : 'day' };
save();
redirect(res, '/#/chat', [cookieName + '=' + sid + cookieFlags + '; Max-Age=28800',
'__Host-jxd_proof=' + cookieFlags + '; Max-Age=0']);
} catch (error) {
console.error('Portal SSO failed:', String(error.message).replace(/[a-f0-9]{32,}/gi, '[redacted]').slice(0, 180));
reply(res, 401, { message: '统一登录未完成,请返回门户重新进入。', portal: portal.origin });
}
return true;
}
if (route === '/api/portal/session') {
if (req.method !== 'GET') { reply(res, 405, {}); return true; }
const sid = cookies(req)[cookieName];
const key = hex(sid) ? digest(sid) : '';
const row = sessions[key];
try {
if (!row || row.revoked || !await valid(row)) throw new Error('Invalid session');
reply(res, 200, { userID: row.imUid, imToken: row.token, chatToken: row.token,
displayName: row.name, staffNo: row.staffNo, theme: row.theme, portal: portal.origin });
} catch {
if (row) { try { await revoke(key); } catch { /* retry */ }
}
reply(res, 401, { message: '请从统一门户进入金讯达', portal: portal.origin });
}
return true;
}
// The existing app must not retain a parallel password/admin entry.
if (route === '/api/login' || route === '/' || route === '/admin' || route.startsWith('/api/admin/')) {
reply(res, 403, { message: '账号及登录统一由门户管理', portal: portal.origin }); return true;
}
return false;
},
};
};
-2
View File
@@ -357,10 +357,8 @@ const routes = {
},
};
const portalBridge = require('./portal-sso')({ getAdminToken, imApi, ensureImUser, getImUserToken });
const server = http.createServer(async (req, res) => {
try {
if (await portalBridge.handle(req, res)) return;
const url = new URL(req.url, 'http://localhost');
req.urlObj = url;
if (req.method === 'OPTIONS') return send(res, 204, {});
-365
View File
@@ -1,365 +0,0 @@
/**
* 员工管理页热修检查(零 npm 依赖)
*
* 覆盖:
* - /account/ 与直连根路径下的接口地址
* - 页面所有管理操作都走同一套请求封装
* - 正确口令能加载列表;错误口令显示中文
* - 添加合法员工返回 JSON
* - 上游非 JSON / 空响应时页面有中文兜底
*
* 运行:node test-admin-page.js
* 不打印口令或员工密码。
*/
'use strict';
const assert = require('assert');
const fs = require('fs');
const http = require('http');
const os = require('os');
const path = require('path');
const { spawn } = require('child_process');
const { adminApiUrl, httpStatusHint, toUserMessage, readAdminJson } = require('./admin-client');
const DIR = __dirname;
let passed = 0;
const failures = [];
function ok(name) {
passed += 1;
console.log(' pass ' + name);
}
function fail(name, err) {
failures.push(name + ': ' + (err && err.message ? err.message : String(err)));
console.log(' FAIL ' + name);
}
async function check(name, fn) {
try {
await fn();
ok(name);
} catch (e) {
fail(name, e);
}
}
function sliceHelpers(src) {
const start = src.indexOf('function adminApiUrl');
if (start < 0) throw new Error('找不到 adminApiUrl');
let end = src.indexOf('async function api(');
if (end < 0) end = src.indexOf('module.exports');
if (end < 0) throw new Error('找不到辅助函数结束位置');
return src.slice(start, end).replace(/\s+/g, ' ').trim();
}
function hasCjk(s) {
return /[\u4e00-\u9fff]/.test(String(s || ''));
}
function hasEnglishTechError(s) {
return /unexpected end of json|failed to execute ['"]json['"]|unexpected token/i.test(String(s || ''));
}
function listen(server) {
return new Promise((resolve, reject) => {
server.listen(0, '127.0.0.1', () => resolve(server.address().port));
server.on('error', reject);
});
}
function waitHealth(url, timeoutMs) {
const start = Date.now();
return new Promise((resolve, reject) => {
const tick = () => {
fetch(url).then((r) => {
if (r.ok) return resolve();
throw new Error(String(r.status));
}).catch((e) => {
if (Date.now() - start > timeoutMs) return reject(new Error('服务未就绪'));
setTimeout(tick, 80);
});
};
tick();
});
}
async function main() {
console.log('account-service admin page checks');
const html = fs.readFileSync(path.join(DIR, 'admin.html'), 'utf8');
const clientSrc = fs.readFileSync(path.join(DIR, 'admin-client.js'), 'utf8');
await check('页面不再无条件 res.json()', () => {
assert.ok(!/\.json\s*\(/.test(html), 'admin.html 仍调用 res.json()');
});
await check('所有管理操作走 api() 封装', () => {
const ops = [
'/api/admin/employees',
'/api/admin/import',
'/api/admin/enable',
'/api/admin/disable',
'/api/admin/reset_password',
'/api/admin/delete',
];
for (const op of ops) {
assert.ok(html.includes("api('" + op) || html.includes('api(\'' + op) || html.includes('/api/admin/\' +'), '缺少 ' + op);
}
assert.ok(html.includes("api('/api/admin/' + (enable ? 'enable' : 'disable')"));
assert.ok((html.match(/await api\(/g) || []).length >= 7);
});
await check('html 与 admin-client.js 辅助函数一致', () => {
const a = sliceHelpers(html);
const b = sliceHelpers(clientSrc);
assert.ok(a.length > 80 && b.length > 80);
assert.strictEqual(a, b, 'admin.html 内联辅助函数与 admin-client.js 不一致');
});
await check('直连根路径与 /account/ 前缀地址', () => {
const route = '/api/admin/employees';
assert.strictEqual(adminApiUrl(route, '/'), '/api/admin/employees');
assert.strictEqual(adminApiUrl(route, '/admin'), '/api/admin/employees');
assert.strictEqual(adminApiUrl(route, '/account/'), '/account/api/admin/employees');
assert.strictEqual(adminApiUrl(route, '/account'), '/account/api/admin/employees');
assert.strictEqual(adminApiUrl(route, '/account/admin'), '/account/api/admin/employees');
assert.strictEqual(adminApiUrl(route, '/account/admin/'), '/account/api/admin/employees');
assert.strictEqual(adminApiUrl('/api/admin/import', '/account/'), '/account/api/admin/import');
assert.strictEqual(adminApiUrl('/api/admin/enable', '/account/'), '/account/api/admin/enable');
assert.strictEqual(adminApiUrl('/api/admin/disable', '/account/'), '/account/api/admin/disable');
assert.strictEqual(adminApiUrl('/api/admin/reset_password', '/account/'), '/account/api/admin/reset_password');
assert.strictEqual(adminApiUrl('/api/admin/delete', '/account/'), '/account/api/admin/delete');
});
await check('错误口令 / 404 / 空响应 / 非 JSON 均为中文兜底', async () => {
const cases = [
{
name: '401 json',
res: new Response(JSON.stringify({ code: 1, msg: '管理口令错误或未提供' }), {
status: 401,
headers: { 'content-type': 'application/json; charset=utf-8' },
}),
expect: '管理口令错误或未提供',
},
{
name: '404 text',
res: new Response('404 page not found', {
status: 404,
headers: { 'content-type': 'text/plain' },
}),
expect: httpStatusHint(404),
},
{
name: 'empty 404',
res: new Response('', { status: 404, headers: { 'content-type': 'text/plain' } }),
expect: httpStatusHint(404),
},
{
name: '500 html',
res: new Response('<html>oops</html>', {
status: 500,
headers: { 'content-type': 'text/html' },
}),
expect: httpStatusHint(500),
},
{
name: 'broken json',
res: new Response('{', { status: 200, headers: { 'content-type': 'application/json' } }),
expect: '服务器返回了无法识别的内容',
},
];
for (const c of cases) {
let msg = '';
try {
await readAdminJson(c.res);
throw new Error(c.name + ' 应当失败');
} catch (e) {
msg = toUserMessage(e);
}
assert.ok(hasCjk(msg), c.name + ' 不是中文: ' + msg);
assert.ok(!hasEnglishTechError(msg), c.name + ' 泄漏英文: ' + msg);
if (c.expect) assert.strictEqual(msg, c.expect, c.name);
}
const english = toUserMessage(new Error("Failed to execute 'json' on 'Response': Unexpected end of JSON input"));
assert.strictEqual(english, '服务器返回了无法识别的内容');
assert.ok(hasCjk(english));
});
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'acct-admin-'));
const dataFile = path.join(tmpDir, 'employees.json');
fs.writeFileSync(dataFile, '{}');
const mockIm = http.createServer((req, res) => {
res.setHeader('Content-Type', 'application/json; charset=utf-8');
let buf = '';
req.on('data', (c) => { buf += c; });
req.on('end', () => {
if ((req.url || '').includes('/auth/get_admin_token')) {
return res.end(JSON.stringify({ errCode: 0, data: { token: 'mock', expireTimeSeconds: 3600 } }));
}
if ((req.url || '').includes('/user/user_register')) {
return res.end(JSON.stringify({ errCode: 0 }));
}
if ((req.url || '').includes('/user/get_users_info')) {
return res.end(JSON.stringify({ errCode: 0, data: { usersInfo: [{ userID: 't10001' }] } }));
}
res.statusCode = 404;
res.end(JSON.stringify({ errCode: 1 }));
});
});
const imPort = await listen(mockIm);
const acctPort = 18000 + Math.floor(Math.random() * 2000);
const adminToken = 'unit-test-admin';
const child = spawn(process.execPath, ['server.js'], {
cwd: DIR,
env: {
...process.env,
PORT: String(acctPort),
DATA_FILE: dataFile,
ADMIN_TOKEN: adminToken,
OPENIM_API_URL: 'http://127.0.0.1:' + imPort,
OPENIM_SECRET: 'mock',
LIVEKIT_API_KEY: '',
LIVEKIT_API_SECRET: '',
},
stdio: ['ignore', 'pipe', 'pipe'],
});
const secretRe = new RegExp(adminToken + '|initpass123', 'g');
const scrub = (s) => String(s || '').replace(secretRe, '[redacted]');
child.stdout.on('data', (d) => {
const t = scrub(d);
if (t.trim()) console.log(' [server] ' + t.trim());
});
child.stderr.on('data', (d) => {
const t = scrub(d);
if (t.trim()) console.log(' [server-err] ' + t.trim());
});
const stop = () => {
try { child.kill('SIGTERM'); } catch { /* ignore */ }
try { mockIm.close(); } catch { /* ignore */ }
try { fs.rmSync(tmpDir, { recursive: true, force: true }); } catch { /* ignore */ }
};
try {
await waitHealth('http://127.0.0.1:' + acctPort + '/api/health', 8000);
await check('正确口令能加载列表', async () => {
const res = await fetch('http://127.0.0.1:' + acctPort + '/api/admin/employees', {
headers: { 'admin-token': adminToken },
});
const data = await readAdminJson(res);
assert.ok(data && typeof data.total === 'number');
assert.ok(Array.isArray(data.employees));
});
await check('错误口令显示中文', async () => {
const res = await fetch('http://127.0.0.1:' + acctPort + '/api/admin/employees', {
headers: { 'admin-token': 'wrong-token' },
});
let msg = '';
try {
await readAdminJson(res);
} catch (e) {
msg = toUserMessage(e);
}
assert.ok(msg);
assert.ok(hasCjk(msg), '不是中文: ' + msg);
assert.ok(!hasEnglishTechError(msg));
assert.ok(/口令|未提供|没有权限/.test(msg), msg);
});
await check('添加合法员工返回 JSON', async () => {
const res = await fetch('http://127.0.0.1:' + acctPort + '/api/admin/employees', {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'admin-token': adminToken },
body: JSON.stringify({ staffNo: 't10001', name: '测试员', password: 'initpass123' }),
});
const ctype = String(res.headers.get('content-type') || '');
assert.ok(ctype.indexOf('json') !== -1, 'content-type=' + ctype);
const data = await readAdminJson(res);
assert.strictEqual(data.staffNo, 't10001');
assert.strictEqual(data.name, '测试员');
assert.strictEqual(data.status, 'active');
assert.ok(!JSON.stringify(data).includes('initpass123'));
assert.ok(!('hash' in data) && !('salt' in data) && !('password' in data));
});
await check('启停/重置/删除走同一解析且成功返回 JSON', async () => {
const tokenHeader = { 'Content-Type': 'application/json', 'admin-token': adminToken };
const disableRes = await fetch('http://127.0.0.1:' + acctPort + '/api/admin/disable', {
method: 'POST',
headers: tokenHeader,
body: JSON.stringify({ staffNo: 't10001' }),
});
const disabled = await readAdminJson(disableRes);
assert.strictEqual(disabled.status, 'disabled');
const enableRes = await fetch('http://127.0.0.1:' + acctPort + '/api/admin/enable', {
method: 'POST',
headers: tokenHeader,
body: JSON.stringify({ staffNo: 't10001' }),
});
const enabled = await readAdminJson(enableRes);
assert.strictEqual(enabled.status, 'active');
const resetRes = await fetch('http://127.0.0.1:' + acctPort + '/api/admin/reset_password', {
method: 'POST',
headers: tokenHeader,
body: JSON.stringify({ staffNo: 't10001', password: 'initpass123' }),
});
const reset = await readAdminJson(resetRes);
assert.strictEqual(reset.staffNo, 't10001');
const delRes = await fetch('http://127.0.0.1:' + acctPort + '/api/admin/delete', {
method: 'POST',
headers: tokenHeader,
body: JSON.stringify({ staffNo: 't10001' }),
});
const del = await readAdminJson(delRes);
assert.strictEqual(del.deleted, true);
});
await check('上游非 JSON 时页面中文兜底(模拟公网误入 OpenIM)', async () => {
const upstream = http.createServer((req, res) => {
res.writeHead(404, { 'Content-Type': 'text/plain' });
res.end('404 page not found');
});
const upPort = await listen(upstream);
try {
const res = await fetch('http://127.0.0.1:' + upPort + '/api/admin/employees');
let msg = '';
try {
await readAdminJson(res);
} catch (e) {
msg = toUserMessage(e);
}
assert.ok(hasCjk(msg));
assert.ok(!hasEnglishTechError(msg));
assert.strictEqual(msg, '接口地址不正确,请从管理页重新打开');
} finally {
upstream.close();
}
});
} finally {
stop();
await new Promise((r) => setTimeout(r, 150));
}
console.log('');
if (failures.length) {
console.log(failures.length + ' failed, ' + passed + ' passed');
for (const f of failures) console.log(' - ' + f);
process.exit(1);
}
console.log('all ' + passed + ' passed');
}
main().catch((e) => {
console.error('test crashed (no secrets printed)');
console.error(e && e.message ? e.message : 'unknown error');
process.exit(1);
});
-65
View File
@@ -1,65 +0,0 @@
'use strict';
const test = require('node:test');
const assert = require('node:assert/strict');
const http = require('http');
const fs = require('fs');
const os = require('os');
const path = require('path');
const createBridge = require('./portal-sso');
test('portal proof, exchange, active session, revocation, and legacy login closure', async () => {
const temp = fs.mkdtempSync(path.join(os.tmpdir(), 'jinniu-sso-test-'));
let active = true, exchanges = 0, kicks = 0;
const identity = { empid: 'fefafefa-1234-1234-1234-123456789abc', local_uid: 1, username: '019999', display_name: '管理员' };
const portal = http.createServer(async (req, res) => {
assert.equal(req.headers.authorization, 'Bearer ' + 's'.repeat(32));
res.setHeader('Content-Type', 'application/json');
if (req.url.endsWith('/exchange')) {
exchanges++;
res.end(JSON.stringify({ identity, session_handle: 'c'.repeat(64) }));
} else res.end(JSON.stringify({active, identity}));
});
await new Promise(r => portal.listen(0,'127.0.0.1',r));
const bridge = createBridge({
ensureImUser: async (uid) => { assert.equal(uid, identity.empid.replace(/-/g,'')); return true; },
getImUserToken: async (uid, pid) => { assert.equal(pid, 5); return {token:'private-im-token'}; },
getAdminToken: async () => 'private-admin-token',
imApi: async (route, body) => { assert.equal(body.userID, identity.empid.replace(/-/g,'')); kicks++; return {errCode:0}; },
}, {PORTAL_SSO_ENABLED:'1', PORTAL_SSO_SECRET:'s'.repeat(32), PORTAL_PUBLIC_URL:'https://bg.example.test',
PORTAL_INTERNAL_URL:'http://127.0.0.1:'+portal.address().port, DATA_FILE:path.join(temp,'employees.json')});
const server = http.createServer(async (req,res) => { if (!await bridge.handle(req,res)) { res.writeHead(404);res.end(); } });
await new Promise(r => server.listen(0,'127.0.0.1',r));
const base = 'http://127.0.0.1:'+server.address().port;
try {
assert.equal((await fetch(base+'/api/login',{method:'POST'})).status,403);
assert.equal((await fetch(base+'/api/admin/employees')).status,403);
assert.equal((await fetch(base+'/api/portal/session')).status,401);
assert.equal((await fetch(base+'/portal-sso?ticket='+'a'.repeat(64))).status,401);
assert.equal(exchanges,0);
const start = await fetch(base+'/portal-sso?theme=night',{redirect:'manual'});
assert.equal(start.status,303);
assert.match(start.headers.get('location'),/^https:\/\/bg\.example\.test\/api\/sso\/apps\/jinxunda\/authorize\?challenge=[a-f0-9]{64}$/);
const proof = start.headers.get('set-cookie').split(';')[0];
const finish = await fetch(base+'/portal-sso?ticket='+'a'.repeat(64),{redirect:'manual',headers:{cookie:proof}});
assert.equal(finish.status,303);
const cookie = finish.headers.getSetCookie()[0].split(';')[0];
assert.match(finish.headers.getSetCookie()[0],/HttpOnly; Secure; SameSite=Lax/);
let r = await fetch(base+'/api/portal/session',{headers:{cookie}});
assert.equal(r.headers.get('cache-control'),'no-store');
const profile=await r.json();
assert.equal(profile.userID,identity.empid.replace(/-/g,''));
assert.equal(profile.staffNo,'019999');
assert.equal(profile.theme,'night');
active=false;
r = await fetch(base+'/api/portal/session',{headers:{cookie}});
assert.equal(r.status,401);
assert.equal(kicks,1);
assert.deepEqual(JSON.parse(fs.readFileSync(path.join(temp,'portal-sessions.json'))),{});
} finally {
bridge.close();
await new Promise(r=>server.close(r));
await new Promise(r=>portal.close(r));
assert.ok(path.resolve(temp).startsWith(path.resolve(os.tmpdir())+path.sep));
fs.rmSync(temp,{recursive:true});
}
});
Binary file not shown.
-14
View File
@@ -1,14 +0,0 @@
# LiveKit 公网测试配置(jxd.jinniu.ink)
# 仅由 deploy/public/docker-compose.public.yaml 挂载;内网仍用 livekit.yaml。
#
# 媒体候选地址走公网探测;信令经 Nginx 443 反代,UDP/TCP 媒体端口仍需对公网开放。
port: 17880
rtc:
tcp_port: 17881
udp_port: 17882
use_external_ip: true
room:
departure_timeout: 300
empty_timeout: 300
logging:
level: info
-17
View File
@@ -1,17 +0,0 @@
# 复制到仓库根目录的 .env 后按机填写。禁止把 Master Secret 写进本文件或 Git。
# 公网测试域名已解析到测试机;客户端只认域名,不认 IP。
# 本机公网 IP(LiveKit 媒体候选用)。在服务器上用 `curl -4 -s ifconfig.me` 查看,不要写进客户端。
SERVER_IP=
MINIO_EXTERNAL_ADDRESS="https://jxd.jinniu.ink/files"
OPENIM_PUSH_ENABLE=jpush
JPUSH_APPKEY=95fc2352648a7d4568ac8d72
JPUSH_PUSH_URL=https://api.jpush.cn/v3/push
# 必须加引号:值含分号。compose 读 .env 无妨;不要用 shell source/. 加载未加引号的副本。
JPUSH_PUSH_INTENT="intent:#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;component=cn.solsum.jinxunda/cn.solsum.jinxunda.MainActivity;end"
# Master Secret 由 scripts/load-jpush-secret.sh 从
# /root/.config/jinxunda/jpush_master_secret 注入为环境变量 JPUSH_MASTER_SECRET。
# JPUSH_MASTER_SECRET_FILE=/root/.config/jinxunda/jpush_master_secret
-68
View File
@@ -1,68 +0,0 @@
# 公网测试部署说明(jxd.jinniu.ink)
> **已过时,仅留档备查(2026-09-23)。** 当前 `154.37.220.158` 已由系统 Nginx 统一承接 80/443,`jxd-edge` 已移除。本页下方 edge 启停、证书和回滚步骤不能直接用于现网;先读 [最新交接](../../docs/项目交接-2026-09-23.md),核对现网配置与未合入 `main` 的部署变更,再制订新操作方案。
施工员本卡**不执行**本节命令、不 SSH 改测试机。由总工审核通过后再部署。
目标机:已解析到 `jxd.jinniu.ink` 的香港测试服务器。数据目录仍是仓库下的 `components/` 与 `data/`,回滚不删数据。
## 对外暴露与对内绑定
| 入口 | 协议 | 后端 | 说明 |
| --- | --- | --- | --- |
| `https://jxd.jinniu.ink/` | HTTPS | OpenIM API `:10002` | 客户端 `apiAddr` |
| `wss://jxd.jinniu.ink/msg_gateway` | WSS | OpenIM 网关 `:10001` | 客户端 `wsAddr` |
| `https://jxd.jinniu.ink/account/` | HTTPS | 账号服务 `:10010` | 客户端 `authApiBase` |
| `https://jxd.jinniu.ink/files/` | HTTPS | MinIO `:10005` | `MINIO_EXTERNAL_ADDRESS` |
| `wss://jxd.jinniu.ink/livekit/` | WSS | LiveKit 信令 `:17880` | 客户端 `livekitUrl` |
| `:17881/tcp` `:17882/udp` | 媒体 | LiveKit RTC | 必须对公网开放,不能只走 443 |
内部端口(10001/10002/10005/10010/17880/etcd)在 overlay 里绑 `127.0.0.1`。防火墙建议只放行 80/tcp、443/tcp、17881/tcp、17882/udp。
## 证书
1. 先把 `deploy/public/nginx.bootstrap.conf` 挂到 edge(只听 80)。
2. `certbot certonly --webroot -w deploy/public/acme -d jxd.jinniu.ink`
3. 确认 `/etc/letsencrypt/live/jxd.jinniu.ink/` 有 `fullchain.pem` 与 `privkey.pem`。
4. 改回 `nginx.conf` 后重载 edge。
私钥不得复制进 Git。
## 极光 Master Secret
文件在测试机 `/root/.config/jinxunda/jpush_master_secret`(权限 600)。部署前:
```bash
source ./scripts/load-jpush-secret.sh # 只导出环境变量,不打印内容
```
不要 `cat` 该文件,不要写进 `.env` 或 compose 明文。
## 启动(总工)
```bash
cd /path/to/tongxunruanjian
cp .env.example .env # 若还没有
# 按 deploy/public/.env.public.example 写入 SERVER_IP、MINIO_EXTERNAL_ADDRESS、JPUSH_*(不含 Master Secret)
source ./scripts/load-jpush-secret.sh
./scripts/deploy-public.sh
```
`SERVER_IP` 填本机公网 IP(LiveKit 媒体候选),不要写进手机/电脑客户端代码。
## 回滚
```bash
./scripts/rollback-public.sh
```
效果:停掉 nginx edge,按原来的 `docker-compose.yaml` 拉起;`components/` 与 `data/account` 不动。
## 客户端地址(已写进代码默认值)
- 手机:`mobile/lib/config.dart`,默认 `jxd.jinniu.ink` + TLS。内网回切:`--dart-define=SERVER_HOST=192.168.200.11 --dart-define=USE_TLS=false`
- 电脑:改 `pc-client/.env` 的 `VITE_*` 为 `https://` / `wss://` 路径,见该目录 `.env.example`
## 华为通道缺口
见 `mobile/android/app/README-agconnect.md`。缺 `agconnect-services.json` 时华为真机厂商通道不通,其余施工已完成。
View File
-59
View File
@@ -1,59 +0,0 @@
# 公网测试 overlay。用法(在仓库根目录,由总工执行,本卡不跑):
# ./scripts/load-jpush-secret.sh
# docker compose -f docker-compose.yaml -f deploy/public/docker-compose.public.yaml up -d
# 不要用 shell source/. 加载 .env:JPUSH_PUSH_INTENT 含分号,未加引号时会被拆成命令。
# compose 会自行读取仓库根目录 .env 做变量替换;Master Secret 只经 load-jpush-secret.sh 注入。
#
# 原则:内部端口只绑 127.0.0.1;对外只开 80/443 + LiveKit 媒体 17881/tcp、17882/udp。
# ports 使用 !override,避免与基础 compose 的 0.0.0.0 绑定叠加。
# 回滚:去掉本 overlay,改回 docker compose -f docker-compose.yaml up -d,数据目录 components/ 与 data/ 不动。
services:
openim-server:
ports: !override
- "127.0.0.1:${OPENIM_MSG_GATEWAY_PORT}:10001"
- "127.0.0.1:${OPENIM_API_PORT}:10002"
environment:
- IMENV_OPENIM_PUSH_ENABLE=${OPENIM_PUSH_ENABLE:-jpush}
- IMENV_OPENIM_PUSH_JPUSH_APPKEY=${JPUSH_APPKEY}
- IMENV_OPENIM_PUSH_JPUSH_MASTERSECRET=${JPUSH_MASTER_SECRET}
- IMENV_OPENIM_PUSH_JPUSH_PUSHURL=${JPUSH_PUSH_URL:-https://api.jpush.cn/v3/push}
- IMENV_OPENIM_PUSH_JPUSH_PUSHINTENT=${JPUSH_PUSH_INTENT}
minio:
ports: !override
- "127.0.0.1:${MINIO_PORT}:9000"
- "127.0.0.1:${MINIO_CONSOLE_PORT}:9090"
etcd:
ports: !override
- "127.0.0.1:12379:2379"
- "127.0.0.1:12380:2380"
livekit:
command: --config /etc/livekit.yaml --node-ip ${SERVER_IP}
ports: !override
- "127.0.0.1:${LIVEKIT_PORT:-17880}:17880"
- "${LIVEKIT_RTC_TCP_PORT:-17881}:17881"
- "${LIVEKIT_RTC_UDP_PORT:-17882}:17882/udp"
volumes:
- ./config/livekit.public.yaml:/etc/livekit.yaml
account-server:
ports: !override
- "127.0.0.1:${ACCOUNT_PORT:-10010}:10010"
edge:
image: nginx:1.27-alpine
container_name: jxd-edge
restart: always
network_mode: host
volumes:
- ./deploy/public/nginx.conf:/etc/nginx/nginx.conf:ro
- ./deploy/public/acme:/var/www/acme:ro
- /etc/letsencrypt:/etc/letsencrypt:ro
depends_on:
- openim-server
- account-server
- minio
- livekit
-30
View File
@@ -1,30 +0,0 @@
# 仅 80 端口:申请 Let's Encrypt 证书用。证书拿到后换成 nginx.conf。
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
sendfile on;
server_tokens off;
server {
listen 80;
listen [::]:80;
server_name jxd.jinniu.ink;
location /.well-known/acme-challenge/ {
root /var/www/acme;
}
location / {
return 200 'jxd.jinniu.ink bootstrap\n';
add_header Content-Type text/plain;
}
}
}
-120
View File
@@ -1,120 +0,0 @@
# 公网测试:jxd.jinniu.ink 终止 TLS,反代到本机回环上的 OpenIM / 账号 / 对象存储 / LiveKit。
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 4096;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
sendfile on;
server_tokens off;
client_max_body_size 100m;
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
upstream openim_api {
server 127.0.0.1:10002;
}
upstream openim_ws {
server 127.0.0.1:10001;
}
upstream account_api {
server 127.0.0.1:10010;
}
upstream minio_s3 {
server 127.0.0.1:10005;
}
upstream livekit_signal {
server 127.0.0.1:17880;
}
server {
listen 80;
listen [::]:80;
server_name jxd.jinniu.ink;
location /.well-known/acme-challenge/ {
root /var/www/acme;
}
location / {
return 301 https://$host$request_uri;
}
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name jxd.jinniu.ink;
ssl_certificate /etc/letsencrypt/live/jxd.jinniu.ink/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/jxd.jinniu.ink/privkey.pem;
ssl_session_timeout 1d;
ssl_session_cache shared:SSL:10m;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers off;
# OpenIM 消息长连接
location /msg_gateway {
proxy_pass http://openim_ws/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
}
# 公司账号服务(登录、管理页、rtc_token)
location /account/ {
proxy_pass http://account_api/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
# MinIO 对象(MINIO_EXTERNAL_ADDRESS=https://jxd.jinniu.ink/files)
location /files/ {
proxy_pass http://minio_s3/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_request_buffering off;
}
# LiveKit 信令(客户端 wss://jxd.jinniu.ink/livekit → 容器 /rtc 等)
location /livekit/ {
proxy_pass http://livekit_signal/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
}
# OpenIM REST API(catch-all,须放最后)
location / {
proxy_pass http://openim_api;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
}
-7
View File
@@ -358,13 +358,6 @@ services:
- IMENV_LOG_ISSTDOUT=${LOG_IS_STDOUT}
- IMENV_LOG_REMAINLOGLEVEL=${LOG_LEVEL}
- IMENV_OPENIM_API_PROMETHEUS_GRAFANAURL=${GRAFANA_URL}
# 离线推送(极光)。未启用时保持空,OpenIM 走 dummy pusher。
# Master Secret 只从环境变量注入,禁止写进仓库。
- IMENV_OPENIM_PUSH_ENABLE=${OPENIM_PUSH_ENABLE:-}
- IMENV_OPENIM_PUSH_JPUSH_APPKEY=${JPUSH_APPKEY:-}
- IMENV_OPENIM_PUSH_JPUSH_MASTERSECRET=${JPUSH_MASTER_SECRET:-}
- IMENV_OPENIM_PUSH_JPUSH_PUSHURL=${JPUSH_PUSH_URL:-https://api.jpush.cn/v3/push}
- IMENV_OPENIM_PUSH_JPUSH_PUSHINTENT=${JPUSH_PUSH_INTENT:-}
restart: always
depends_on:
- mongo
+5 -6
View File
@@ -1,10 +1,10 @@
# 金讯达项目手册
# 畅联项目手册
这是项目的交接首页。新接手的人先按下面顺序阅读,不要只凭旧文档或聊天记录判断项目状态。
1. 先读 [2026-09-23 项目交接](项目交接-2026-09-23.md):最新部署状态、风险和接下来的计划。
2. 再读 [项目需求](项目需求.md):弄清楚项目要做什么、不能碰什么。
3. [最新进度](最新进度.md)和[任务清单](任务清单.md)是精简索引;旧验收记录仅供追溯。
1. 先读 [项目需求](项目需求.md):弄清楚项目要做什么、不能碰什么。
2. 再读 [最新进度](最新进度.md):确认代码已经做到哪里、哪些结论已经被验证。
3. 最后读 [任务清单](任务清单.md):从“正在做”和“还没安排”里选择下一件事。
## 仓库里有什么
@@ -12,7 +12,6 @@
- `pc-client/`:电脑端,使用 Electron,Windows 是当前优先支持的平台。
- `account-service/`:公司账号服务,负责工号密码登录、管理员导入和管理名单。
- `docker-compose.yaml`、`config/`、`scripts/`:OpenIM、语音服务和内网环境的配置及维护脚本。
- `deploy/public/`:早期公网部署资料。旧 edge 操作不适用于当前系统 Nginx 统一入口,不要直接执行。
- `docs/`:本手册和以前留下的验收、回归、使用说明。
## 更新规矩
@@ -24,4 +23,4 @@
- 任务状态变化时,更新 `任务清单.md` 的三栏,并写明依据。
- 旧文档不能删除;如果它和当前事实不一致,在旧文档开头加“已过时,仅留档备查”提示,再在本目录写新版。
手册只记录已经确认的事实。拿不准的内容要写成“待确认”,不要当成已完成。
手册只记录已经确认的事实。拿不准的内容要写成“待确认”,不要当成已完成。
-24
View File
@@ -1,24 +0,0 @@
# 金讯达统一门户网页试运行
网页地址 https://jxd.jinniu.ink,唯一身份入口 https://bg.jinniu.ink。
account-service 设置 PORTAL_SSO_ENABLED=1、PORTAL_PUBLIC_URL、PORTAL_INTERNAL_URL 和独立不少于32字符的 PORTAL_SSO_SECRET。该密钥必须与门户 JINXUNDA_SSO_SECRET 一致。现有 OpenIM 管理服务密钥仍通过私有环境文件提供。
`/portal-sso` 使用浏览器 verifier 绑定的短期一次性票据。身份使用永久 empid,OpenIM UID 为去掉 UUID 连字符的32位十六进制表示。不能用工号改名重新创建聊天身份。
`/api/portal/session` 同源且禁止缓存;每次验证门户会话。后台每10秒撤销失效用户平台5会话,失败会重试。会话文件仅服务端可读,原口令登录和管理API在门户模式禁用。
构建 pc-client 网页版本时配置:
```
VITE_PORTAL_MODE=1
VITE_PORTAL_URL=https://bg.jinniu.ink
VITE_API_URL=https://jxd.jinniu.ink
VITE_WS_URL=wss://jxd.jinniu.ink/msg_gateway
VITE_ACCOUNT_URL=https://jxd.jinniu.ink/account
VITE_LIVEKIT_URL=wss://jxd.jinniu.ink/livekit/
```
执行 `npx vite build --config vite.portal.config.ts`,输出 dist-portal。Nginx 将根路径/资源指向该目录,SSO及会话接口代理账号服务;原OpenIM、对象存储、LiveKit路由保留。
验证:`node --test test-portal-sso.js test-admin-page.js`(在account-service目录);真实HTTPS兑换OpenIM凭证、浏览器进入聊天、返回门户、退出撤销已验收。
仅保留一个正式管理员,因此双人消息、音视频、附件尚未完成真实员工验收。原生Windows/Android客户端仍为历史登录机制,需要另行适配门户登录;不能视为本次网页交付已覆盖。
+20 -11
View File
@@ -1,17 +1,26 @@
# 任务清单
更新时间:2026-09-23。旧协调卡 HEL-4 及相关子卡收口后,以 [项目交接](项目交接-2026-09-23.md)为新任务依据。旧卡关闭不等于整个项目已验收。
更新时间:2026-08-23。任务状态以当前仓库和项目约束为准;没有证据的事项不写成“已完成”。
## 已交付
## 正在做
- Flutter 安卓端、Electron Windows 端、账号服务、OpenIM/LiveKit 集成与历史跨端回归记录。
- 安卓名称/图标/包名调整,极光和华为构建配置接入,测试包生成。
- 香港测试机系统 Nginx 统一入口;金讯达网页并入统一门户。网页单人登录、退出及入口可访问性已有记录。
目前没有已确认正在施工的业务代码任务。
## 下一步新开独立任务
本次已完成仓库交接手册整理,后续所有任务都应按 `docs/README.md` 的更新规矩同步维护本清单。
1. 审核并同步现网 Nginx 配置与仓库代码,补齐金讯达证书自动续期及回滚演练(原 HEL-554;到期风险优先)。
2. 两名真实员工跨安卓、Windows、网页验收消息、附件与一对一语音通话;华为真机验收离线推送。
3. 确定账号导入和原生端门户登录策略,准备安卓正式签名及安全保管。
4. 根据资质进展另行接其他安卓厂商推送与 iOS。
5. 如仍需 `solsum.cn` 根域名 HTTPS,另行处理证书域名不匹配(原 HEL-553;不属于金讯达当前域名接入阻塞)。
## 已做完
- 建立手机端 Flutter 工程和 Windows 优先的 Electron 电脑端工程。
- 接入公司工号加密码登录,以及管理员导入、管理员工账号的账号服务。
- 完成聊天、通讯录、同事申请、语音消息、文件/图片消息和一对一语音通话的相关代码接入。
- 完成一轮手机与电脑的跨端回归记录;其中已通过的项目见旧档 `phase4-regression-2026-08-16.md`。
- 将 LiveKit 的信令/媒体端口统一为 `17880`、`17881`、`17882`,并提供可重复执行的修复脚本。
- 建立本目录四份交接手册,并为三份过时旧说明加上明确的留档提示。
## 还没安排
- 组织真实手机和 Windows 电脑的回归:重点确认文件传输和一对一语音通话。
- 明确手机正式签名的负责人和安全保管方式;不能把签名密钥提交进仓库。
- 获得负责人同意后,再导入真实员工名单并验证账号管理流程。
- 等负责人对三个公网问题拍板后,才安排公网 IP/域名、备案、反向代理和 HTTPS 的具体施工;当前禁止擅自开始。
- 公网方案获批后,重新评估电脑端 Electron、登录失败限制、令牌本地保存和跨域设置的安全风险。
+28 -6
View File
@@ -1,9 +1,31 @@
# 最新进度
更新时间:2026-09-23。详细事实、证据边界和下一步见 [项目交接](项目交接-2026-09-23.md)。
更新时间:2026-08-23。以下内容依据当前仓库代码和最新提交 `fa8584a` 整理。
- 最新测试服务器:`154.37.220.158`;系统 Nginx 统一承接 80/443,金讯达网页 `https://jxd.jinniu.ink` 已由负责人整合到统一门户 `https://bg.jinniu.ink`。
- 当日只读检查表明网页与账号健康检查可访问,安卓测试包可下载,OpenIM、账号服务、LiveKit 等服务运行;尚不能据此判定双人通讯和推送验收通过。
- 安卓代码版本 `1.0.9+10`,包名 `cn.solsum.jinxunda`,名称与图标已经调整;Windows 文档版本 `v1.0.2`。安卓极光和华为配置已有接入,真机到达率仍待验证。
- 门户网页已验证单人登录与退出;两个真实员工之间的消息、附件、语音通话仍待验收。Android/Windows 原生端还未适配门户登录;iOS、其他安卓厂商推送、正式签名尚未完成。
- 现网统一入口的变更尚未同步进仓库 `main`;旧 `jxd-edge` 部署指令不适用于现网。证书自动续期仍待补齐。
## 现在做到哪里
项目已经具备可继续测试的手机端、Windows 电脑端、账号服务和内网部署配置:
- 手机端在 `mobile/`,使用 OpenIM Flutter SDK `3.8.3+hotfix.12`,版本 `1.0.6+7`。
- 电脑端在 `pc-client/`,使用 Electron,显示版本 `v1.0.2`。
- 员工用工号和密码通过 `account-service/` 登录;管理员导入和管理账号的页面、接口已在仓库中。
- 手机和电脑端已接入聊天、通讯录、同事申请、语音消息、文件/图片消息和一对一语音通话相关代码。
- 语音服务 LiveKit 的信令和媒体端口已统一为 `17880`、`17881`、`17882`;仓库提供 `scripts/fix-livekit-ports.sh` 用于服务器已部署环境的端口修复。
## 已有验证记录
- `docs/phase4-regression-2026-08-16.md` 记录过手机与电脑之间的文字、同事申请、图片、语音消息等跨端回归结果。
- 该记录中的文件传输和一对一语音通话,曾因模拟器环境无法闭环,仍需要用真实设备再次确认。
- 旧记录使用的是更早的提交、安装包版本和端口状态;因此已保留为档案并在开头标明过时,不能当作当前验收结论。
## 当前停在哪
公网接入施工暂停,等待负责人对三个公网相关问题拍板后再恢复。现阶段没有把内网服务发布到公网的授权。
这意味着:代码可继续维护和内网验证,但公网 IP/域名、备案、反向代理和 HTTPS 等工作不能擅自启动。
## 已知风险和待验证事实
- 真机上的文件传输和一对一语音通话仍需实际设备验证,不能只根据模拟器结果宣称完成。
- 手机正式签名、真实员工名单导入和试用前的管理员安全设置,都需要负责人明确确认并由有权限的人执行。
- 电脑端使用较旧的 Electron,且历史记录提到内网场景的安全取舍;若未来获准公网接入,必须先重新评估 HTTPS、浏览器安全设置、登录限流和跨域策略。
-30
View File
@@ -1,30 +0,0 @@
# 金讯达项目交接(2026-09-23)
本页是旧协调卡 HEL-4 归档后的项目入口。它记录截至本日能核实的状态与下一步,不代表整个项目已经验收完成。后续请以新的、范围明确的任务卡推进,并在完成时更新本页。不得把密钥、员工资料或私钥写入仓库。
## 当前部署和入口
- 当前香港**测试**服务器公网地址:`154.37.220.158`;`jxd.jinniu.ink` 指向这台服务器。正式上线前仍需独立验收。
- 集团统一门户为 `https://bg.jinniu.ink`。负责人已自行把金讯达网页端整合进统一门户;网页地址为 `https://jxd.jinniu.ink`,网页身份入口以门户为准,详情见 [网页试运行说明](portal-web-trial.md)。
- 2026-09-23 只读核对:系统 Nginx 占用 80/443,配置检查通过;金讯达网页、账号健康检查均返回 HTTP 200,现有安卓测试包下载支持 HTTP 206 分段下载。OpenIM、账号服务、LiveKit、MinIO 及其依赖容器当时在运行。**这只证明服务和入口当时可用,不等于聊天、通话或推送已完成用户验收。**
- 现网由系统 Nginx 统一承接 80/443;原 `jxd-edge` 容器已移除。`deploy/public/README.md` 的 edge 启停步骤是旧方案,禁止直接照其操作现网。
## 代码与已经交付的能力
- 代码包含 Flutter 手机端、Electron/网页端、公司账号服务,以及 OpenIM、LiveKit 等部署配置。安卓包名 `cn.solsum.jinxunda`,版本 `1.0.9+10`;安卓名称为“金讯达”,已按系统自适应图标安全区调整图标。Windows 客户端当前文档版本为 `v1.0.2`。
- 手机和电脑端已有工号密码登录、通讯录、聊天、图片/文件/语音消息及一对一语音通话相关代码;历史跨端测试记录见 [回归记录](phase4-regression-2026-08-16.md),不能拿历史记录代替当前版本的真机验收。
- 安卓已接入极光 SDK 与华为 AGConnect 构建配置;华为配置文件及极光 Master Secret 均为私有材料,不入库。其他安卓厂商通道与苹果推送尚未完成。
- 网页端已接入统一门户单点登录。现有网页试运行记录覆盖登录、会话兑换与退出;当时仅有一个正式管理员,尚无两个真实员工之间的消息、音视频、附件完整验收。原生 Android/Windows 客户端仍使用旧登录机制,尚未统一为门户登录。
- 本仓库 `main` 已含网页门户整合代码;服务器 Nginx 统一入口相关改动曾交付于另一个分支,**截至本日尚未合入 `main`**。后续部署前要先审查并同步该分支及现网配置,不能直接用 `main` 的旧 edge 脚本覆盖现网。
## 尚未完成、按优先级推进
1. **P0:统一部署基线与证书。** 审查并合入系统 Nginx 统一入口相关代码,核对现网配置、备份和回滚路径;补齐 `jxd.jinniu.ink` 证书自动续期。现有证书到期日记录为 2026-11-28,应在 2026-11-14 前完成自动续期及演练。原 HEL-554 尚未执行,不得因旧卡归档误认为已完成。
2. **P1:真实员工验收。** 准备两个获授权的测试员工账号,在安卓、Windows、网页之间验证登录、双向消息、附件、语音消息与一对一语音通话;华为真机验证前台、后台和被系统结束后的通知到达与点击。记录设备、版本、时间和失败现象;不得以健康检查代替这些测试。
3. **P1:账号及发布安全。** 负责人确认员工名单导入与权限边界;安卓正式发布前改用受保护的正式签名,不能把签名密钥入库。评估网页门户身份与原生客户端旧登录并存的期限,以及原生端是否改用门户登录。
4. **P2:其余平台。** 其他安卓厂商通道待各厂商资质完成后再接;iOS 的 Apple 开发者账号、推送凭据、构建和真机验收另立任务,不视为本阶段已完成。
5. **P2:`solsum.cn` 证书问题。** 原 HEL-553 记录其根域名证书只覆盖 `www`,与金讯达当前 `jxd.jinniu.ink` 接入不是同一个阻塞;如仍需根域名 HTTPS,由该域名负责人另开独立任务处理。
## 旧任务卡收口说明
HEL-4 是跨阶段协调卡,不是“项目全部完工”的证明。归档时,已交付的子卡记为完成;未执行的 HEL-553、HEL-554 仅关闭旧卡、把风险迁入上方计划。以后请从此文档开新卡,不继续在旧长线程里追加施工。实际状态以当时运行环境和最新代码为准。
+7 -8
View File
@@ -2,7 +2,7 @@
## 项目是什么
“金讯达”是集团内部使用的通讯 App,也就是给员工聊天、找同事和语音通话的工具。项目以开源 OpenIM 为基础改造;员工使用的安卓应用已采用经负责人确认的“金讯达”名称和图标。OpenIM 的第三方标识、许可和署名仍须按其许可保留。
“畅联”是集团内部使用的通讯 App,也就是给员工聊天、找同事和语音通话的工具。项目以开源 OpenIM 为基础改造,保留 OpenIM 原有标识,不换品牌、不另起一套产品标识。
## 要解决什么
@@ -18,15 +18,14 @@
## 支持范围
- 手机端:Android 和 iPhone 工程都在仓库中;当前手机端版本号为 `1.0.9+10`。应用标识 `cn.solsum.jinxunda`。安卓桌面/最近任务/系统应用信息显示名称为「金讯达」。
- 手机端:Android 和 iPhone 工程都在仓库中;当前手机端版本号为 `1.0.6+7`。
- 电脑端:Windows 优先;当前电脑端显示版本为 `v1.0.2`。
- 网页端:已由负责人整合进统一门户,入口 `https://bg.jinniu.ink`,业务页面 `https://jxd.jinniu.ink`;网页身份以门户为准。原生 Android/Windows 尚未同步门户登录。
- 服务端:以 Docker Compose(把一组服务一起启动的工具)编排 OpenIM、账号服务和语音服务。当前香港测试机为 `154.37.220.158`,域名 `jxd.jinniu.ink`(HTTPS/WSS);系统 Nginx 承接 80/443。仓库旧 edge 部署资料不得直接用于现网。
- 服务端:以 Docker Compose(把一组服务一起启动的工具)编排 OpenIM、账号服务和语音服务。
## 当前边界
- 只做集团内部通讯,不改造成公开社交产品。
- 尊重 OpenIM 第三方许可与署名;用户可见应用品牌为“金讯达”,不据此改写 OpenIM 上游代码中的许可信息。
- 公网第一阶段:安卓极光 + 华为厂商通道(`agconnect-services.json` 只放构建机、不入库,见 `mobile/android/app/README-agconnect.md`);不接小米/OPPO/vivo/荣耀/魅族/FCM/苹果推送。
- 不把员工名单、密码、管理员口令、极光 Master Secret、华为 Secret、私钥或服务器私密配置写入仓库和文档。
- 本仓库的日常任务如无明确授权,不做发布、部署或改动生产环境。
- 保留 OpenIM 的现有标识,禁止替换品牌。
- 本项目当前只记录和维护内网环境;公网接入尚未获准施工。
- 不把员工名单、密码、管理员口令、密钥或服务器私密配置写入仓库和文档。
- 本仓库的日常任务如无明确授权,不做发布、部署或改动生产环境。
-3
View File
@@ -44,9 +44,6 @@ app.*.map.json
/android/app/profile
/android/app/release
# 华为 AppGallery Connect 客户端配置(含 client_secret,禁止入库)
/android/app/agconnect-services.json
# 本机路径与构建缓存(不入库)
**/android/local.properties
**/android/.gradle/
+8 -20
View File
@@ -16,32 +16,20 @@ iOS 需要一台 Mac 搭配 Xcode 与开发者证书,另按苹果流程打包
已声明的平台权限(勿删):
- `android/app/src/main/AndroidManifest.xml`:`INTERNET`、`RECORD_AUDIO`(语音消息/通话)、`MODIFY_AUDIO_SETTINGS`、存储/相册读取(发文件、发图片)、`POST_NOTIFICATIONS`(极光离线通知)。公网默认 HTTPS;内网联调 `--dart-define=USE_TLS=false` 时仍允许明文,故暂保留 `usesCleartextTraffic`。
- `android/app/src/main/AndroidManifest.xml`:`INTERNET`、`RECORD_AUDIO`(语音消息/通话)、`MODIFY_AUDIO_SETTINGS`、存储/相册读取(发文件、发图片);并开启了 `usesCleartextTraffic`(内网服务器暂用 http/ws 明文,开通外网改 HTTPS 后应移除)。
- `ios/Runner/Info.plist`:`NSMicrophoneUsageDescription`(语音消息与通话)、`NSPhotoLibraryUsageDescription`(发图片)、`NSAppTransportSecurity/NSAllowsArbitraryLoads`(同上,内网明文)。
- `android/build.gradle.kts` / `settings.gradle.kts` 把阿里云 Maven 镜像放在最前(本网络访问 maven.google.com 不稳定),并增加华为 Maven(厂商通道)。
- `android/build.gradle.kts` / `settings.gradle.kts` 把阿里云 Maven 镜像放在最前(本网络访问 maven.google.com 不稳定)。
## 修改服务器地址
所有服务器地址集中在 `lib/config.dart`。默认公网:`jxd.jinniu.ink` + HTTPS/WSS。
所有服务器地址集中在 `lib/config.dart`,改 `serverHost`(内网 IP/域名)和对应端口常量即可:
内网联调不要改文件,打包时覆盖:
```bash
flutter build apk --release \
--dart-define=SERVER_HOST=192.168.200.11 \
--dart-define=USE_TLS=false
```
仅覆盖登录服务:`--dart-define=AUTH_HOST=127.0.0.1`
| 常量 | 用途 | 公网默认 |
| 常量 | 用途 | 默认值 |
| --- | --- | --- |
| `apiAddr` | OpenIM API | `https://jxd.jinniu.ink` |
| `wsAddr` | OpenIM WebSocket | `wss://jxd.jinniu.ink/msg_gateway` |
| `livekitUrl` | LiveKit 语音通话 | `wss://jxd.jinniu.ink/livekit` |
| `authApiBase` | 公司账号登录后端 | `https://jxd.jinniu.ink/account` |
华为厂商通道需要本地放置 `android/app/agconnect-services.json`(与包名 `cn.solsum.jinxunda` 对应),取得方式见 `android/app/README-agconnect.md`。不要把该文件提交进 Git。
| `apiAddr` | OpenIM API | `http://192.168.200.11:10002` |
| `wsAddr` | OpenIM WebSocket | `ws://192.168.200.11:10001` |
| `livekitUrl` | LiveKit 语音通话 | `ws://192.168.200.11:17880`(注意已重映射,非默认 7880) |
| `authApiBase` | 公司账号登录后端 | `http://192.168.200.11:10010` |
## 登录接口契约(后端:任务 B-60 account-service,已上线)
-5
View File
@@ -7,11 +7,6 @@
# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
analyzer:
exclude:
- build/**
- android/**
- ios/**
include: package:flutter_lints/flutter.yaml
linter:
-20
View File
@@ -1,20 +0,0 @@
# 华为厂商通道配置文件
华为通道客户端依赖已接入。构建机需要一份本地文件:
`mobile/android/app/agconnect-services.json`
## 从哪里取得
1. 打开华为 [AppGallery Connect](https://developer.huawei.com/consumer/cn/service/josp/agc/index.html)
2. 选择与包名 `cn.solsum.jinxunda` 对应的应用
3. 项目设置 → 应用 → 下载 `agconnect-services.json`
4. 把文件放到本目录(与 `build.gradle.kts` 同级)
5. **不要提交进 Git**(文件含华为 client_secret)。仓库已忽略该路径。
没有这份文件时:
- AGConnect 插件不会启用,安卓包仍可走极光自有通道构建
- **华为真机的厂商通道无法接通**,杀进程后的到达率会明显下降
放入真实配置后,`:app` 会启用 AGConnect(agcp `1.9.5.301`,适配 AGP 9)。Gradle 会按包名 `cn.solsum.jinxunda` 校验该文件;校验失败则构建失败。
+17 -29
View File
@@ -1,33 +1,9 @@
buildscript {
repositories {
maven("https://maven.aliyun.com/repository/google")
maven("https://maven.aliyun.com/repository/central")
maven("https://developer.huawei.com/repo/")
google()
mavenCentral()
}
// agcp 1.9.x 用 apply() 时会检查 buildscript classpath 里有没有 AGP;
// 仅靠 plugins DSL 会报「com.android.tools.build:gradle is no set」。
dependencies {
classpath("com.android.tools.build:gradle:9.0.1")
classpath("com.huawei.agconnect:agcp:1.9.5.301")
}
}
plugins {
id("com.android.application")
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
id("dev.flutter.flutter-gradle-plugin")
}
// 华为 agconnect-services.json 到位后才启用 AGConnect 插件,避免缺文件时整包编不过。
// 文件从华为 AppGallery Connect 下载,放到本目录,不要提交进 Git。
// jpush_flutter_android 只在自己的 library 模块 apply 该插件,不会处理本 app 的配置文件,
// 所以这里仍要在 :app 上 apply,并不是重复。
if (file("agconnect-services.json").exists()) {
apply(plugin = "com.huawei.agconnect")
}
android {
namespace = "cn.solsum.jinxunda"
compileSdk = flutter.compileSdkVersion
@@ -39,15 +15,14 @@ android {
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId = "cn.solsum.jinxunda"
// 极光厂商通道插件要求 minSdk 24
minSdk = 24
// You can update the following values to match your application needs.
// For more information, see: https://flutter.dev/to/review-gradle-config.
minSdk = flutter.minSdkVersion
targetSdk = flutter.targetSdkVersion
versionCode = flutter.versionCode
versionName = flutter.versionName
manifestPlaceholders["JPUSH_PKGNAME"] = "cn.solsum.jinxunda"
manifestPlaceholders["JPUSH_APPKEY"] = "95fc2352648a7d4568ac8d72"
manifestPlaceholders["JPUSH_CHANNEL"] = "developer-default"
}
// 压缩打包 .so(默认未压缩存储,OpenIM/WebRTC 的 native 库让包多占近一倍体积);
@@ -81,3 +56,16 @@ kotlin {
flutter {
source = "../.."
}
// livekit_client 插件硬编码 compileSdk = 34,但它依赖的 flutter_webrtc 要求消费者 ≥36,
// AAR 元数据校验会因此失败。:app 先于各插件求值(根脚本有 evaluationDependsOn(":app")),
// 所以在插件求值完成后把它的 compileSdk 抬到 36。
rootProject.subprojects {
if (name == "livekit_client") {
afterEvaluate {
extensions.configure<com.android.build.gradle.LibraryExtension> {
compileSdk = 36
}
}
}
}
@@ -1,13 +1,9 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 网络(OpenIM / 登录 / LiveKit 都要) -->
<uses-permission android:name="android.permission.INTERNET"/>
<!-- OpenIM 插件注册网络状态监听必须要这个权限;插件自身 manifest 漏了声明,
缺它 release 包会 SecurityException 导致插件注册失败、SDK 全部调用无响应 -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<!-- Android 13+ 通知栏权限(极光离线推送) -->
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<!-- 语音消息录音与语音通话 -->
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
@@ -16,12 +12,10 @@
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="32"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28"/>
<application
android:label="@string/app_name"
android:label="畅联"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:usesCleartextTraffic="true"
tools:replace="android:label,android:icon">
android:usesCleartextTraffic="true">
<activity
android:name=".MainActivity"
android:exported="true"
@@ -39,10 +33,6 @@
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<!-- 关闭 Flutter 自动深链接,避免厂商通道点击拉起白屏 -->
<meta-data
android:name="flutter_deeplinking_enabled"
android:value="false" />
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
@@ -2,8 +2,4 @@ package cn.solsum.jinxunda
import io.flutter.embedding.android.FlutterActivity
class MainActivity : FlutterActivity() {
// Flutter 3.29+ 默认把启动 Intent 当深链接解析。华为等厂商通道点击拉起时
// intent 带 n_extra,路由表没有对应页会白屏。本应用不用官方深链接。
override fun shouldHandleDeeplinking(): Boolean = false
}
class MainActivity : FlutterActivity()
@@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
@@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 544 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 442 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 721 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 59 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 112 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

@@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">金讯达</string>
</resources>
@@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">金讯达</string>
</resources>
@@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">金讯达</string>
</resources>
@@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#B5312F</color>
</resources>
@@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">金讯达</string>
</resources>
-1
View File
@@ -4,7 +4,6 @@ allprojects {
maven("https://maven.aliyun.com/repository/google")
maven("https://maven.aliyun.com/repository/central")
maven("https://maven.aliyun.com/repository/public")
maven("https://developer.huawei.com/repo/")
google()
mavenCentral()
}
-4
View File
@@ -7,7 +7,3 @@ android.builtInKotlin=false
# 三方插件 Java/Kotlin 编译目标不一致时降级为警告(见 build.gradle.kts 注释)
kotlin.jvm.target.validation.mode=warning
# jpush_flutter_android 1.0.2 的 consumer ProGuard 含 -dontoptimize,AGP 9 默认拒绝合并。
# 本应用 release 已关闭混淆;该开关只让整包构建通过,不改变极光/华为通道行为。
android.r8.globalOptionsInConsumerRules.disallowed=false
-7
View File
@@ -1,7 +0,0 @@
[versions]
agp = "9.0.1"
agcp = "1.9.5.301"
[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }
huawei-agconnect = { id = "com.huawei.agconnect", version.ref = "agcp" }
-13
View File
@@ -15,29 +15,16 @@ pluginManagement {
maven("https://maven.aliyun.com/repository/google")
maven("https://maven.aliyun.com/repository/central")
maven("https://maven.aliyun.com/repository/gradle-plugin")
maven("https://developer.huawei.com/repo/")
google()
mavenCentral()
gradlePluginPortal()
}
// 华为插件发布在 Maven 的 agcp 构件上,没有 Plugin Portal 的
// com.huawei.agconnect.gradle.plugin 坐标。plugins DSL 必须映射过去,
// 否则放入 agconnect-services.json 后启用插件会解析失败。
resolutionStrategy {
eachPlugin {
if (requested.id.id == "com.huawei.agconnect") {
useModule("com.huawei.agconnect:agcp:1.9.5.301")
}
}
}
}
plugins {
id("dev.flutter.flutter-plugin-loader") version "1.0.0"
id("com.android.application") version "9.0.1" apply false
id("org.jetbrains.kotlin.android") version "2.3.20" apply false
id("com.huawei.agconnect") version "1.9.5.301" apply false
}
include(":app")
+14 -37
View File
@@ -1,24 +1,14 @@
/// 服务器地址集中配置。
///
/// 默认指向公网测试域名 `jxd.jinniu.ink`(HTTPS / WSS)。
/// 内网联调不要改本文件,打包时覆盖:
/// `--dart-define=SERVER_HOST=192.168.200.11 --dart-define=USE_TLS=false`
/// 仅覆盖登录服务:`--dart-define=AUTH_HOST=127.0.0.1`
/// 服务器换了地址只需要改这一个文件:
/// 1. 改下面的 [serverHost] 为新的服务器内网 IP(或域名);
/// 2. 如果端口也被重新映射,改对应端口常量即可。
library;
/// 公网测试域名(不带协议、不带端口)
const String defaultPublicHost = 'jxd.jinniu.ink';
/// 服务器内网地址(不带协议、不带端口)
const String serverHost = '192.168.200.11';
/// 服务器地址(不带协议、不带端口)
const String serverHost = String.fromEnvironment(
'SERVER_HOST',
defaultValue: defaultPublicHost,
);
/// 是否走 HTTPS/WSS(公网默认 true;内网联调传 false)
const bool useTls = bool.fromEnvironment('USE_TLS', defaultValue: true);
/// OpenIM API 端口(服务端 docker 映射,默认 10002;TLS 时由反向代理走 443)
/// OpenIM API 端口(服务端 docker 映射,默认 10002)
const int apiPort = 10002;
/// OpenIM WebSocket 端口(默认 10001)
@@ -30,30 +20,17 @@ const int livekitPort = 17880;
/// 公司账号登录后端端口(B-60 account-server,docker 默认映射 10010)
const int authApiPort = 10010;
const String _authHostOverride = String.fromEnvironment('AUTH_HOST', defaultValue: '');
/// OpenIM API 地址,例:http://192.168.200.11:10002
const String apiAddr = 'http://$serverHost:$apiPort';
/// OpenIM API 地址
String get apiAddr => useTls ? 'https://$serverHost' : 'http://$serverHost:$apiPort';
/// OpenIM 消息长连接地址,例:ws://192.168.200.11:10001
const String wsAddr = 'ws://$serverHost:$wsPort';
/// OpenIM 消息长连接地址
String get wsAddr => useTls ? 'wss://$serverHost/msg_gateway' : 'ws://$serverHost:$wsPort';
/// LiveKit 连接地址,例:ws://192.168.200.11:17880
const String livekitUrl = 'ws://$serverHost:$livekitPort';
/// LiveKit 连接地址
String get livekitUrl => useTls ? 'wss://$serverHost/livekit' : 'ws://$serverHost:$livekitPort';
/// 公司账号登录后端地址
/// 公司账号登录后端地址,例:http://192.168.200.11:10010
///
/// 仅本地联调用:`--dart-define=AUTH_HOST=127.0.0.1` 可覆盖登录服务地址(OpenIM/LiveKit
/// 仍走 [serverHost]),正式打包不带该参数则与 [serverHost] 一致。
String get authApiBase {
if (_authHostOverride.isNotEmpty) {
return 'http://$_authHostOverride:$authApiPort';
}
return useTls ? 'https://$serverHost/account' : 'http://$serverHost:$authApiPort';
}
/// 极光 AppKey(可进客户端;Master Secret 禁止出现在客户端或仓库)
const String jpushAppKey = '95fc2352648a7d4568ac8d72';
/// 登录页自检:探测消息长连接入口(TLS 走反向代理路径,明文走宿主端口)
String get wsProbeUrl => useTls ? 'https://$serverHost/msg_gateway' : 'http://$serverHost:$wsPort/';
const String authApiBase = 'http://${String.fromEnvironment('AUTH_HOST', defaultValue: serverHost)}:$authApiPort';
+1 -5
View File
@@ -7,12 +7,10 @@ import 'screens/home_screen.dart';
import 'screens/login_screen.dart';
import 'services/call_service.dart';
import 'services/im_service.dart';
import 'services/push_service.dart';
import 'theme.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
PushService.instance.init();
runApp(const ChanglianApp());
}
@@ -29,7 +27,6 @@ class _ChanglianAppState extends State<ChanglianApp> {
super.initState();
// 被踢下线 / token 失效:清凭证、回登录页
IMService.instance.onForceLogout = () async {
await PushService.instance.unbindUser();
await LoginScreen.clearCredential();
navigatorKey.currentState?.pushAndRemoveUntil(
MaterialPageRoute(builder: (_) => const LoginScreen()),
@@ -47,7 +44,7 @@ class _ChanglianAppState extends State<ChanglianApp> {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: '金讯达',
title: '畅联',
navigatorKey: navigatorKey,
theme: buildAppTheme(),
debugShowCheckedModeBanner: false,
@@ -93,7 +90,6 @@ class _SplashGateState extends State<SplashGate> {
await im.init().timeout(const Duration(seconds: 20));
await im.login(userID: credential.$1, token: credential.$2).timeout(const Duration(seconds: 20));
CallService.instance.start();
await PushService.instance.bindUser(credential.$1);
if (!mounted) return;
Navigator.of(context).pushReplacement(MaterialPageRoute(builder: (_) => const HomeScreen()));
return;
+2 -5
View File
@@ -6,7 +6,6 @@ import '../config.dart';
import '../services/auth_api.dart';
import '../services/call_service.dart';
import '../services/im_service.dart';
import '../services/push_service.dart';
import '../theme.dart';
import 'home_screen.dart';
@@ -93,9 +92,7 @@ class _LoginScreenState extends State<LoginScreen> {
);
// 3. 启动通话信令监听
CallService.instance.start();
// 4. 极光 alias = OpenIM userID,供服务端离线推送
await PushService.instance.bindUser(result.userID);
// 5. 存凭证用于下次自动登录
// 4. 存凭证用于下次自动登录
await LoginScreen.saveCredential(result.userID, result.token, result.nickname);
if (!mounted) return;
Navigator.of(context).pushReplacement(
@@ -153,7 +150,7 @@ class _LoginScreenState extends State<LoginScreen> {
final results = await Future.wait([
probe('账号服务', '$authApiBase/api/health'),
probe('消息接口', '$apiAddr/'),
probe('消息长连接', wsProbeUrl),
probe('消息长连接', 'http://$serverHost:$wsPort/'),
]);
return '自检:${results.join(',')}';
}
-2
View File
@@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
import '../services/im_service.dart';
import '../services/push_service.dart';
import '../theme.dart';
import '../widgets/avatar.dart';
import 'login_screen.dart';
@@ -167,7 +166,6 @@ class _MineScreenState extends State<MineScreen> {
onPressed: () async {
Navigator.of(ctx).pop();
await LoginScreen.clearCredential();
await PushService.instance.unbindUser();
await IMService.instance.logout();
if (!mounted) return;
Navigator.of(context).pushAndRemoveUntil(
+2 -2
View File
@@ -190,7 +190,7 @@ class CallService extends ChangeNotifier {
speakerOn = !speakerOn;
notifyListeners();
try {
await AudioManager.instance.setSpeakerOutputPreferred(speakerOn);
await Hardware.instance.setSpeakerphoneOn(speakerOn);
} catch (_) {
speakerOn = !speakerOn;
notifyListeners();
@@ -369,7 +369,7 @@ class CallService extends ChangeNotifier {
}
// 复位免提
if (speakerOn) {
AudioManager.instance.setSpeakerOutputPreferred(false).catchError((_) {});
Hardware.instance.setSpeakerphoneOn(false).catchError((_) {});
speakerOn = false;
}
micOn = true;
@@ -50,12 +50,7 @@ class MessageSendService {
message: message,
userID: isGroup ? null : peer,
groupID: isGroup ? groupID : null,
offlinePushInfo: OfflinePushInfo(
title: '畅联',
desc: '你收到一条新消息',
iOSBadgeCount: true,
iOSPushSound: '+1',
),
offlinePushInfo: OfflinePushInfo(),
);
return sent;
} catch (e) {
-103
View File
@@ -1,103 +0,0 @@
import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:jpush_flutter/jpush_flutter.dart';
import 'package:jpush_flutter/jpush_interface.dart';
import 'package:permission_handler/permission_handler.dart';
import '../config.dart';
import '../nav.dart';
import '../screens/home_screen.dart';
import 'im_service.dart';
/// 极光推送封装:初始化、通知权限、Registration ID、把 OpenIM userID 设为 alias。
///
/// OpenIM 服务端 JPUSH 离线推送按 alias=userID 下发,因此登录后必须 setAlias。
/// 本阶段只接安卓;iOS 不调用 setup。
class PushService {
PushService._();
static final PushService instance = PushService._();
final JPushFlutterInterface _jpush = JPush.newJPush();
bool _ready = false;
String? _boundAlias;
Future<void> init() async {
if (_ready) return;
if (kIsWeb || !Platform.isAndroid) return;
try {
_jpush.addEventHandler(
onReceiveNotification: (message) async {},
onOpenNotification: (message) async {
_onNotificationClick();
},
onReceiveMessage: (message) async {},
onReceiveNotificationAuthorization: (message) async {},
onConnected: (message) async {},
onCommandResult: (message) async {},
);
_jpush.setAuth(enable: true);
_jpush.setup(
appKey: jpushAppKey,
channel: 'developer-default',
production: true,
debug: false,
);
_jpush.applyPushAuthority(
const NotificationSettingsIOS(sound: true, alert: true, badge: true),
);
await _requestAndroidNotificationPermission();
_ready = true;
await _jpush.getRegistrationID();
} catch (_) {
// 推送失败不能挡住登录和聊天
}
}
Future<void> bindUser(String userID) async {
if (userID.isEmpty) return;
await init();
if (!_ready) return;
try {
await _jpush.setAlias(userID);
_boundAlias = userID;
} catch (_) {
// alias 失败时下次登录再试
}
}
Future<void> unbindUser() async {
if (!_ready) return;
try {
await _jpush.deleteAlias();
} catch (_) {
// 本地照常清理
}
_boundAlias = null;
}
String? get boundAlias => _boundAlias;
Future<void> _requestAndroidNotificationPermission() async {
try {
final status = await Permission.notification.status;
if (!status.isGranted) {
await Permission.notification.request();
}
} catch (_) {
// 权限申请失败不阻断
}
}
void _onNotificationClick() {
final nav = navigatorKey.currentState;
if (nav == null) return;
if (!IMService.instance.loggedIn) return;
nav.pushAndRemoveUntil(
MaterialPageRoute(builder: (_) => const HomeScreen()),
(route) => false,
);
}
}
+20 -76
View File
@@ -9,14 +9,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.7.0"
asn1lib:
dependency: transitive
description:
name: asn1lib
sha256: "9a8f69025044eb466b9b60ef3bc3ac99b4dc6c158ae9c56d25eeccf5bc56d024"
url: "https://pub.dev"
source: hosted
version: "1.6.5"
async:
dependency: transitive
description:
@@ -77,10 +69,10 @@ packages:
dependency: transitive
description:
name: connectivity_plus
sha256: "762c99f890ca8bf87f7337236f99edd42793843bc6c3631da294a76653a54bd0"
sha256: b5e72753cf63becce2c61fd04dfe0f1c430cc5278b53a1342dc5ad839eab29ec
url: "https://pub.dev"
source: hosted
version: "7.3.1"
version: "6.1.5"
connectivity_plus_platform_interface:
dependency: transitive
description:
@@ -89,14 +81,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.0"
convert:
dependency: transitive
description:
name: convert
sha256: b30acd5944035672bc15c6b7a8b47d773e41e2f17de064350988c5d02adb1c68
url: "https://pub.dev"
source: hosted
version: "3.1.2"
cross_file:
dependency: transitive
description:
@@ -121,14 +105,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.0.8"
dart_jsonwebtoken:
dependency: transitive
description:
name: dart_jsonwebtoken
sha256: ad84e60181696513d04d5f2078e0bbc20365b911f46f647797317414bdc88fbe
url: "https://pub.dev"
source: hosted
version: "3.4.1"
dart_webrtc:
dependency: transitive
description:
@@ -149,10 +125,10 @@ packages:
dependency: transitive
description:
name: device_info_plus
sha256: b4fed1b2835da9d670d7bed7db79ae2a94b0f5ad6312268158a9b5479abbacdd
sha256: "98f28b42168cc509abc92f88518882fd58061ea372d7999aecc424345c7bff6a"
url: "https://pub.dev"
source: hosted
version: "12.4.0"
version: "11.5.0"
device_info_plus_platform_interface:
dependency: transitive
description:
@@ -393,10 +369,10 @@ packages:
dependency: transitive
description:
name: intl
sha256: "1ca20c894b1717686a2319b8548763d812bc0aabdac580420a44c5178c57a867"
sha256: "3df61194eb431efc39c4ceba583b95633a403f46c9fd341e550ce0bfa50e9aa5"
url: "https://pub.dev"
source: hosted
version: "0.20.3"
version: "0.20.2"
jni:
dependency: transitive
description:
@@ -421,22 +397,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.0.0"
jpush_flutter:
dependency: "direct main"
description:
name: jpush_flutter
sha256: "5dcfcd553787db0c92a9b2f0898a6dbc053530c6636ed488416cd9edf12f08d3"
url: "https://pub.dev"
source: hosted
version: "3.5.6"
jpush_flutter_android:
dependency: "direct main"
description:
name: jpush_flutter_android
sha256: d2bae547aefb2ff5acf28badaf115bb358e9244b6acef84625d8db0228bbc0b2
url: "https://pub.dev"
source: hosted
version: "1.0.2"
js:
dependency: transitive
description:
@@ -445,14 +405,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.7.2"
json_annotation:
dependency: transitive
description:
name: json_annotation
sha256: "2a743920d81b7910627f68ee2c9ac1fc0bfee32b9fc3403587d7c6791ca12f80"
url: "https://pub.dev"
source: hosted
version: "4.12.0"
just_audio:
dependency: "direct main"
description:
@@ -513,10 +465,10 @@ packages:
dependency: "direct main"
description:
name: livekit_client
sha256: "9160950ff87d1946959e4911c16236ea7a3e74ac1987990b258132fd4ed0fca9"
sha256: "011affc0fca22b2f9b0e8827219dad9948f84f2bf057980693de13039de904c7"
url: "https://pub.dev"
source: hosted
version: "2.10.0"
version: "2.5.0+hotfix.3"
logger:
dependency: transitive
description:
@@ -537,10 +489,10 @@ packages:
dependency: transitive
description:
name: matcher
sha256: "31bd099b47c10cd1aeb55146a2d46ce0277630ecef3f7dae54ad7873f36696cd"
sha256: dc0b7dc7651697ea4ff3e69ef44b0407ea32c487a39fff6a4004fa585e901861
url: "https://pub.dev"
source: hosted
version: "0.12.20"
version: "0.12.19"
material_color_utilities:
dependency: transitive
description:
@@ -553,10 +505,10 @@ packages:
dependency: transitive
description:
name: meta
sha256: "307249ce4ff29d58a18e97f6345f539382eb9c9c29ecda628900f31de0443dd9"
sha256: "1741988757a65eb6b36abe716829688cf01910bbf91c34354ff7ec1c3de2b349"
url: "https://pub.dev"
source: hosted
version: "1.19.0"
version: "1.18.0"
mime:
dependency: transitive
description:
@@ -733,22 +685,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.8"
pointycastle:
dependency: transitive
description:
name: pointycastle
sha256: "92aa3841d083cc4b0f4709b5c74fd6409a3e6ba833ffc7dc6a8fee096366acf5"
url: "https://pub.dev"
source: hosted
version: "4.0.0"
protobuf:
dependency: transitive
description:
name: protobuf
sha256: "75ec242d22e950bdcc79ee38dd520ce4ee0bc491d7fadc4ea47694604d22bf06"
sha256: de9c9eb2c33f8e933a42932fe1dc504800ca45ebc3d673e6ed7f39754ee4053e
url: "https://pub.dev"
source: hosted
version: "6.0.0"
version: "4.2.0"
pub_semver:
dependency: transitive
description:
@@ -958,10 +902,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: "2a122cbe059f8b610d3a5415f42e255b6c17b1f21eee1d960f31080237fb4f11"
sha256: "949a932224383300f01be9221c39180316445ecb8e7547f70a41a35bf421fb9e"
url: "https://pub.dev"
source: hosted
version: "0.7.12"
version: "0.7.11"
typed_data:
dependency: transitive
description:
@@ -974,18 +918,18 @@ packages:
dependency: "direct main"
description:
name: uuid
sha256: "1fef9e8e11e2991bb773070d4656b7bd5d850967a2456cfc83cf47925ba79489"
sha256: a11b666489b1954e01d992f3d601b1804a33937b5a8fe677bd26b8a9f96f96e8
url: "https://pub.dev"
source: hosted
version: "4.5.3"
version: "4.5.2"
vector_math:
dependency: transitive
description:
name: vector_math
sha256: f36f9f3be64c6198714492bb455c11056e33e2f85d9a0b676a48301e44fdcf47
sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b
url: "https://pub.dev"
source: hosted
version: "2.4.2"
version: "2.2.0"
vm_service:
dependency: transitive
description:
+5 -16
View File
@@ -1,7 +1,7 @@
name: changlian
description: 畅联 —— 公司内部通讯 App(手机端)
publish_to: "none"
version: 1.0.9+10
version: 1.0.6+7
environment:
sdk: ">=3.6.0 <4.0.0"
@@ -29,25 +29,14 @@ dependencies:
file_picker: 10.3.3
# 发图片消息时选相册图片
image_picker: 1.1.2
# 一对一语音通话(LiveKit SFU)。2.10.0 起修复 Dart 3.13 空安全编译错误,
# 是当前 Flutter 3.47 / Dart 3.13 下改动最小的稳定版本。
livekit_client: 2.10.0
# 一对一语音通话(LiveKit SFU,版本取自官方样板工程 openim_live/pubspec.yaml)
livekit_client: 2.5.0+hotfix.3
# 麦克风权限申请
permission_handler: 11.4.0
# 打开收到的文件
open_filex: 4.7.0
# 通话房间号(livekit_client 2.10.0 要求 >=4.5.3)
uuid: 4.5.3
# 极光推送官方 Flutter 插件(MIT);厂商通道另见 jpush_flutter_android
jpush_flutter: 3.5.6
jpush_flutter_android: 1.0.2
# 极光安卓厂商通道:本阶段只开华为。AppKey 可进客户端;其余厂商密钥不要填。
jpush_android:
app_key: 95fc2352648a7d4568ac8d72
channel: developer-default
huawei:
enable: true
# 通话房间号
uuid: 4.5.2
dev_dependencies:
flutter_test:
-16
View File
@@ -1,16 +0,0 @@
import 'package:changlian/config.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
test('默认公网地址走 HTTPS/WSS 且不含测试 IP', () {
expect(serverHost, 'jxd.jinniu.ink');
expect(useTls, isTrue);
expect(apiAddr, 'https://jxd.jinniu.ink');
expect(wsAddr, 'wss://jxd.jinniu.ink/msg_gateway');
expect(livekitUrl, 'wss://jxd.jinniu.ink/livekit');
expect(authApiBase, 'https://jxd.jinniu.ink/account');
expect(apiAddr, isNot(contains('154.37')));
expect(wsAddr, isNot(contains('154.37')));
expect(jpushAppKey, '95fc2352648a7d4568ac8d72');
});
}
+7 -7
View File
@@ -1,7 +1,7 @@
# 公网测试环境(jxd.jinniu.ink)。内网联调请建 .env.local 覆盖为 http/ws + 内网 IP。
VITE_WS_URL=wss://jxd.jinniu.ink/msg_gateway
VITE_API_URL=https://jxd.jinniu.ink
# 自研公司账号服务(登录 + 通话令牌)。本地联调可覆盖为 mock:http://127.0.0.1:11010
VITE_ACCOUNT_URL=https://jxd.jinniu.ink/account
# LiveKit 语音通话信令(媒体走服务器 17881/17882,不经 443)
VITE_LIVEKIT_URL=wss://jxd.jinniu.ink/livekit
# 内网测试环境(192.168.200.11,见仓库根目录 README 端口表)
VITE_WS_URL=ws://192.168.200.11:10001
VITE_API_URL=http://192.168.200.11:10002
# 自研公司账号服务(登录 + 通话令牌)。本地联调可建 .env.local 覆盖为 mock:http://127.0.0.1:11010
VITE_ACCOUNT_URL=http://192.168.200.11:10010
# LiveKit 语音通话(宿主端口已改映射为 17880)
VITE_LIVEKIT_URL=ws://192.168.200.11:17880
+2 -3
View File
@@ -25,7 +25,6 @@ import { OverlayVisibleHandle } from "../../hooks/useOverlayVisible";
import About from "./About";
import styles from "./left-nav-bar.module.scss";
import PersonalSettings from "./PersonalSettings";
import { portalMode } from '@/portal';
const AppIcon = () => (
<div className="flex h-9 w-9 items-center justify-center rounded-lg bg-[var(--primary)]">
@@ -282,7 +281,7 @@ const LeftNavBar = memo(() => {
))}
</div>
{!portalMode && <Popover
<Popover
content={ProfileContent}
trigger="click"
placement="rightBottom"
@@ -298,7 +297,7 @@ const LeftNavBar = memo(() => {
src={selfInfo.faceURL}
text={selfInfo.nickname}
/>
</Popover>}
</Popover>
<PersonalSettings ref={personalSettingsRef} />
<About ref={aboutRef} />
</div>
+1 -3
View File
@@ -9,7 +9,6 @@ import { useUserStore } from "@/store";
import GlobalModals from "./GlobalModals";
import LeftNavBar from "./LeftNavBar";
import { useGlobalEvent } from "./useGlobalEvents";
import { portalMode, portalHome } from '@/portal';
export const MainContentLayout = () => {
useGlobalEvent();
@@ -36,8 +35,7 @@ export const MainContentLayout = () => {
return (
<Spin className="!max-h-none" spinning={showLockLoading} tip={loadingTip}>
{portalMode && <header className="portal-header jn-portal-bar"><strong>金讯达</strong><span>金牛集团 · 内部通讯</span><a className="jn-portal-return" title="返回统一门户" aria-label="返回统一门户" href={portalHome + '?theme=' + document.documentElement.dataset.theme}><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d="m3 10 9-7 9 7v10a1 1 0 0 1-1 1h-5v-7H9v7H4a1 1 0 0 1-1-1Z"/></svg><span>统一门户</span></a></header>}
<Layout className="relative h-full flex-row" style={portalMode ? {height: 'calc(100% - 56px)'} : undefined}>
<Layout className="relative h-full flex-row">
<LeftNavBar />
<Outlet />
{/* 悬浮窗口控制条:无边框窗口的拖动区 + 最小化/关闭 */}
+1 -20
View File
@@ -7,9 +7,6 @@ import ReactDOM from "react-dom/client";
import App from "./App";
import { isSaveLog } from "./config";
import { initializePortal, portalHome, portalMode } from './portal';
import './portal.scss';
import './portal-return.css';
if (window.electronAPI && isSaveLog) {
const sdkLogger = log.scope("openim-sdk-core");
@@ -19,22 +16,6 @@ if (window.electronAPI && isSaveLog) {
console.error = rendererLogger.error.bind(rendererLogger);
}
initializePortal().then(ready => {
const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement);
root.render(ready ? <App /> : <main style={{padding: 48}}><h1>金讯达</h1>
<p>请从统一门户登录并进入金讯达。</p><a href={portalHome}>返回统一门户</a></main>);
if (ready && portalMode) {
let checking = false;
setInterval(async () => {
if (checking) return;
checking = true;
try {
const response = await fetch('/api/portal/session', { cache: 'no-store' });
if (!response.ok) window.location.replace(portalHome);
} catch { window.location.replace(portalHome); }
finally { checking = false; }
}, 10000);
}
});
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(<App />);
postMessage({ payload: "removeLoading" }, "*");
+1 -2
View File
@@ -1,6 +1,5 @@
import { Layout } from "antd";
import { useTranslation } from "react-i18next";
import { portalMode } from "@/portal";
export const EmptyChat = () => {
const { t } = useTranslation();
@@ -16,7 +15,7 @@ export const EmptyChat = () => {
/>
</svg>
</div>
<div className="mt-4 text-base font-medium">{portalMode ? '金讯达' : t("placeholder.title")}</div>
<div className="mt-4 text-base font-medium">{t("placeholder.title")}</div>
<div className="mt-1 text-xs text-[var(--sub-text)]">
{t("placeholder.subTitle")}
</div>
-3
View File
@@ -8,13 +8,10 @@ import { feedbackToast } from "@/utils/common";
import styles from "./index.module.scss";
import LoginForm from "./LoginForm";
import { portalMode, portalHome } from '@/portal';
export const Login = () => {
const [_, copyToClipboard] = useCopyToClipboard();
if (portalMode) return <main style={{padding: 48}}><p>登录已失效,请返回门户重新进入。</p><a href={portalHome}>返回统一门户</a></main>;
const handleCopy = () => {
copyToClipboard(`${`${APP_NAME} ${APP_VERSION}`}/${SDK_VERSION}`);
feedbackToast({ msg: t("toast.copySuccess") });
-22
View File
@@ -1,22 +0,0 @@
/* Shared portal navigation: same geometry in all four applications. */
.jn-portal-bar { position: relative; min-height: 56px; box-sizing: border-box; padding-right: 160px !important; }
a.jn-portal-return, a.jn-portal-return:link, a.jn-portal-return:visited {
position: absolute; top: 10px; right: 16px; z-index: 2;
display: inline-flex; align-items: center; justify-content: center; gap: 8px;
box-sizing: border-box; height: 36px; min-width: 124px; padding: 0 12px;
border: 1px solid #e7c7c3; border-radius: 10px; margin: 0;
background: #fff7f5; color: #a92e24; box-shadow: 0 1px 2px rgba(64,25,20,.04);
font: 600 13px/1.2 -apple-system,BlinkMacSystemFont,"Segoe UI","Microsoft YaHei",sans-serif;
text-decoration: none; white-space: nowrap; cursor: pointer;
}
a.jn-portal-return svg { width: 18px; height: 18px; flex: none; }
a.jn-portal-return span { color: inherit !important; font: inherit; }
a.jn-portal-return:hover { background: #faeae6; color: #92251d; border-color: #d99c94; text-decoration: none; }
a.jn-portal-return:focus-visible { outline: 3px solid #b83a2d; outline-offset: 3px; }
[data-theme="night"] a.jn-portal-return { background: #382927; border-color: #70504b; color: #ffb4a8; }
[data-theme="night"] a.jn-portal-return:hover { background: #4a312c; color: #ffd0c7; }
@media (max-width: 600px) {
.jn-portal-bar { padding-right: 124px !important; }
a.jn-portal-return, a.jn-portal-return:link, a.jn-portal-return:visited { right: 12px; min-width: 102px; gap: 6px; padding: 0 9px; }
}
@media print { a.jn-portal-return { display: none !important; } }
-20
View File
@@ -1,20 +0,0 @@
html[data-portal='true'] {
--primary: #b32635;
--primary-active: #f6e8e9;
--top-search-bar: #b32635;
--chat-bubble-sender: #f4dfe1;
.portal-header { height: 56px; display: flex; align-items: center; gap: 20px; padding: 0 24px; border-bottom: 1px solid var(--gap-text); background: #fff; }
.portal-header strong { color: var(--primary); font-size: 20px; }
.portal-header span { color: var(--sub-text); }
@media (max-width: 600px) { .portal-header > span { display: none; } }
.ant-spin-nested-loading, .ant-spin-container { height: 100%; }
&[data-theme='night'] {
color-scheme: dark;
--primary: #e2737d; --primary-active: #35272a; --base-black: #e9e5df;
--sub-text: #a8a29a; --gap-text: #3b3634; --search-bg: #292626;
--chat-bg: #201e1d; --chat-bubble: #312d2b; --chat-bubble-sender: #4b3034;
background: #201e1d;
.portal-header, .bg-white, .ant-layout { background: #252221 !important; }
input, textarea, .ant-input, .ant-modal-content, .ant-popover-inner { background: #292626; color: #e9e5df; }
}
}
-20
View File
@@ -1,20 +0,0 @@
import { setIMProfile, clearIMProfile } from './utils/storage';
export const portalMode = import.meta.env.VITE_PORTAL_MODE === '1';
export const portalHome = import.meta.env.VITE_PORTAL_URL || '';
export async function initializePortal(): Promise<boolean> {
if (!portalMode) return true;
try {
const response = await fetch('/api/portal/session', { cache: 'no-store', credentials: 'same-origin' });
if (!response.ok) throw new Error('Session expired');
const profile = await response.json();
await setIMProfile(profile);
document.documentElement.dataset.theme = profile.theme === 'night' ? 'night' : 'day';
document.documentElement.dataset.portal = 'true';
document.title = '金讯达 · 金牛集团';
return true;
} catch {
clearIMProfile();
return false;
}
}
+3 -1
View File
@@ -25,7 +25,9 @@ export const setIMProfile = ({
imToken: string;
userID: string;
}) => {
return Promise.all([setTMToken(imToken), setChatToken(chatToken), setTMUserID(userID)]);
setTMToken(imToken);
setChatToken(chatToken);
setTMUserID(userID);
};
export const setLocale = (locale: string) => localStorage.setItem("IM_LOCALE", locale);
-9
View File
@@ -1,9 +0,0 @@
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import path from 'node:path';
export default defineConfig({
plugins: [react()],
resolve: { alias: { '@': path.resolve(__dirname, 'src') } },
build: { outDir: 'dist-portal', sourcemap: false },
});
-45
View File
@@ -1,45 +0,0 @@
#!/usr/bin/env bash
# 香港测试机公网部署入口(jxd.jinniu.ink)。由总工执行;施工员本卡不跑本脚本,也不 SSH 改现网。
# 用法: ./scripts/deploy-public.sh
# 回滚: ./scripts/rollback-public.sh
set -euo pipefail
cd "$(dirname "$0")/.."
if [ ! -f .env ]; then
echo "没有 .env。先从 .env.example 复制,再按 deploy/public/.env.public.example 补公网项。" >&2
exit 1
fi
# LiveKit --node-ip 依赖 SERVER_IP;空值时信令通、媒体宣告错误。
# 不 source .env(JPUSH_PUSH_INTENT 含分号);只抽取这一项。
if [ -z "${SERVER_IP:-}" ]; then
SERVER_IP="$(awk -F= '/^SERVER_IP=/{v=$2} END{print v}' .env | tr -d '[:space:]"')"
fi
if [ -z "${SERVER_IP}" ]; then
echo "SERVER_IP 为空,拒绝启动。请在 .env 填写本机公网 IP(LiveKit 媒体候选用)。" >&2
exit 1
fi
# 注入 Master Secret(失败则停,避免空密钥启动)
# shellcheck disable=SC1091
source ./scripts/load-jpush-secret.sh
if [ -z "${JPUSH_MASTER_SECRET:-}" ]; then
echo "Master Secret 未注入,拒绝启动" >&2
exit 1
fi
mkdir -p deploy/public/acme components/redis/config components/mnt/data components/mongodb components/etcd components/kafka
touch components/redis/config/redis.conf
docker compose \
-f docker-compose.yaml \
-f deploy/public/docker-compose.public.yaml \
pull
docker compose \
-f docker-compose.yaml \
-f deploy/public/docker-compose.public.yaml \
up -d
echo "已提交 compose 启动。检查: docker compose -f docker-compose.yaml -f deploy/public/docker-compose.public.yaml ps"
echo "证书未就绪时先用 nginx.bootstrap.conf 申请证书,见 deploy/public/README.md"
-27
View File
@@ -1,27 +0,0 @@
#!/usr/bin/env bash
# 从服务器安全文件注入极光 Master Secret 到环境变量。
# 不打印文件内容、不写入仓库。供总工部署时 source,本卡不执行。
set -euo pipefail
SECRET_FILE="${JPUSH_MASTER_SECRET_FILE:-/root/.config/jinxunda/jpush_master_secret}"
if [ ! -f "$SECRET_FILE" ]; then
echo "缺少极光 Master Secret 文件(已配置路径,不打印内容)" >&2
exit 1
fi
perm=$(stat -c '%a' "$SECRET_FILE" 2>/dev/null || stat -f '%OLp' "$SECRET_FILE")
if [ "$perm" != "600" ] && [ "$perm" != "400" ]; then
echo "Master Secret 文件权限应为 600 或 400(当前 $perm)" >&2
exit 1
fi
len=$(wc -c < "$SECRET_FILE" | tr -d ' ')
if [ "$len" -lt 16 ] || [ "$len" -gt 64 ]; then
echo "Master Secret 文件长度异常(不打印内容)" >&2
exit 1
fi
JPUSH_MASTER_SECRET="$(tr -d '\n\r' < "$SECRET_FILE")"
export JPUSH_MASTER_SECRET
# 有意不 echo 该变量
-12
View File
@@ -1,12 +0,0 @@
#!/usr/bin/env bash
# 公网 overlay 回滚到内网 compose:停掉 edge,按原 docker-compose.yaml 拉起。
# 不删除 components/ 与 data/,不改现网数据文件。
set -euo pipefail
cd "$(dirname "$0")/.."
docker compose -f docker-compose.yaml -f deploy/public/docker-compose.public.yaml stop edge || true
docker compose -f docker-compose.yaml -f deploy/public/docker-compose.public.yaml rm -f edge || true
docker compose -f docker-compose.yaml up -d
echo "已回到内网 compose。数据目录未动。检查: docker compose ps"