Initial commit: kefu-server-saas v2.0

客服服务器完整源码,包含:
- Express HTTP服务 (port 9501)
- WebSocket服务 (port 9502)
- SaaS多租户认证
- 坐席管理、消息管理、连接管理
- SQLite数据库(5张核心表)
- 管理后台 (/admin)
- 坐席工作台 (/agent, /agent-mobile)
- 商城REST API (/plugin.yunqian-api)
- 消息推送API (/message/push)

技术栈:Node.js 18 + Express 4 + ws 8 + better-sqlite3 + EJS + PM2
This commit is contained in:
Kefu Admin
2026-08-23 21:22:34 +08:00
commit 5471eda6c1
25 changed files with 3477 additions and 0 deletions
+67
View File
@@ -0,0 +1,67 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>登录 - SaaS 客服服务器</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Microsoft YaHei", sans-serif;
background: linear-gradient(135deg, #1a73e8 0%, #0d47a1 100%);
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}
.login-card {
background: #fff;
border-radius: 16px;
box-shadow: 0 20px 60px rgba(0,0,0,0.3);
padding: 40px;
width: 400px;
max-width: 90vw;
}
.login-card h1 { text-align: center; color: #333; font-size: 22px; margin-bottom: 30px; }
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 13px; color: #555; margin-bottom: 6px; font-weight: 500; }
.form-group input { width: 100%; padding: 10px 14px; border: 1px solid #ddd; border-radius: 8px; font-size: 14px; outline: none; }
.form-group input:focus { border-color: #1a73e8; box-shadow: 0 0 0 3px rgba(26,115,232,0.15); }
.btn-login {
width: 100%; padding: 12px; background: linear-gradient(135deg, #1a73e8 0%, #0d47a1 100%);
color: #fff; border: none; border-radius: 8px; font-size: 16px; font-weight: 600;
cursor: pointer; margin-top: 10px;
}
.btn-login:hover { opacity: 0.9; }
.error-msg { background: #fff0f0; border: 1px solid #ffcccc; color: #cc3333;
padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 18px; display: none; }
.error-msg.show { display: block; }
</style>
</head>
<body>
<div class="login-card">
<h1>SaaS 客服服务器</h1>
<div class="error-msg" id="errorMsg"></div>
<div class="form-group">
<label>管理密码</label>
<input type="password" id="password" placeholder="请输入管理密码">
</div>
<button class="btn-login" id="btnLogin">登录</button>
</div>
<script>
document.getElementById('btnLogin').addEventListener('click', async () => {
const password = document.getElementById('password').value;
const res = await fetch('/admin/login', {
method: 'POST', headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ password })
});
const data = await res.json();
if (data.success) { location.href = '/admin'; }
else { document.getElementById('errorMsg').textContent = data.message; document.getElementById('errorMsg').classList.add('show'); }
});
document.getElementById('password').addEventListener('keypress', (e) => {
if (e.key === 'Enter') document.getElementById('btnLogin').click();
});
</script>
</body>
</html>