Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0a3b075644 | ||
|
|
437e707893 | ||
|
|
0ff0aff87b | ||
|
|
c03d6c3fe2 | ||
|
|
a122a498e1 |
@@ -52,6 +52,8 @@ DEFAULT_CONFIG = {
|
|||||||
], ensure_ascii=False),
|
], ensure_ascii=False),
|
||||||
"footer_text": "NBA球迷大全 · 数据为模拟演示数据(2025-26 赛季) · LLM: DeepSeek · 向量: Chroma + bge-large-zh",
|
"footer_text": "NBA球迷大全 · 数据为模拟演示数据(2025-26 赛季) · LLM: DeepSeek · 向量: Chroma + bge-large-zh",
|
||||||
"admin_password": "admin123",
|
"admin_password": "admin123",
|
||||||
|
"entity_mark_mode": "first", # 实体标记:first=只标记首次出现 / all=全部标记
|
||||||
|
"suggestion_count": "3", # 对话中底部快捷问题预测个数(默认3)
|
||||||
}
|
}
|
||||||
|
|
||||||
SEARCHABLE = { # 每个表可搜索的 TEXT 字段
|
SEARCHABLE = { # 每个表可搜索的 TEXT 字段
|
||||||
@@ -189,7 +191,15 @@ def list_rows(table):
|
|||||||
page = max(1, int(request.args.get("page", 1)))
|
page = max(1, int(request.args.get("page", 1)))
|
||||||
size = min(100, max(1, int(request.args.get("size", 20))))
|
size = min(100, max(1, int(request.args.get("size", 20))))
|
||||||
q = (request.args.get("q") or "").strip()
|
q = (request.args.get("q") or "").strip()
|
||||||
|
# 排序:字段白名单校验(防注入),默认 id 降序
|
||||||
cols = _columns(table)
|
cols = _columns(table)
|
||||||
|
valid_fields = {c["name"] for c in cols}
|
||||||
|
sort = request.args.get("sort", "") or "id"
|
||||||
|
if sort not in valid_fields:
|
||||||
|
sort = "id"
|
||||||
|
order = (request.args.get("order", "") or "desc").lower()
|
||||||
|
if order not in ("asc", "desc"):
|
||||||
|
order = "desc"
|
||||||
where, args = "", []
|
where, args = "", []
|
||||||
if q:
|
if q:
|
||||||
fields = SEARCHABLE.get(table) or ()
|
fields = SEARCHABLE.get(table) or ()
|
||||||
@@ -198,10 +208,11 @@ def list_rows(table):
|
|||||||
where = "WHERE " + " OR ".join(f"{f} LIKE ? ESCAPE '\\'" for f in fields)
|
where = "WHERE " + " OR ".join(f"{f} LIKE ? ESCAPE '\\'" for f in fields)
|
||||||
args = [like] * len(fields)
|
args = [like] * len(fields)
|
||||||
total = query_one(f"SELECT COUNT(*) AS c FROM {table} {where}", args)["c"]
|
total = query_one(f"SELECT COUNT(*) AS c FROM {table} {where}", args)["c"]
|
||||||
rows = query(f"SELECT * FROM {table} {where} ORDER BY id DESC LIMIT ? OFFSET ?",
|
rows = query(f"SELECT * FROM {table} {where} ORDER BY {sort} {order.upper()}, id {order.upper()} LIMIT ? OFFSET ?",
|
||||||
args + [size, (page - 1) * size])
|
args + [size, (page - 1) * size])
|
||||||
return jsonify({"table": table, "cn": TABLES[table], "columns": cols,
|
return jsonify({"table": table, "cn": TABLES[table], "columns": cols,
|
||||||
"total": total, "page": page, "size": size, "rows": rows})
|
"total": total, "page": page, "size": size, "rows": rows,
|
||||||
|
"sort": sort, "order": order})
|
||||||
|
|
||||||
|
|
||||||
def get_row(table, rid):
|
def get_row(table, rid):
|
||||||
|
|||||||
@@ -64,6 +64,22 @@ def boot():
|
|||||||
return jsonify(chat.boot_info())
|
return jsonify(chat.boot_info())
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/api/suggest", methods=["POST"])
|
||||||
|
def api_suggest():
|
||||||
|
"""基于对话历史预测底部快捷问题(个数后台可配,默认3)"""
|
||||||
|
body = request.get_json(force=True, silent=True) or {}
|
||||||
|
history = body.get("history") or []
|
||||||
|
try:
|
||||||
|
n = int(admin_mod.get_config().get("suggestion_count", "3") or "3")
|
||||||
|
except Exception:
|
||||||
|
n = 3
|
||||||
|
try:
|
||||||
|
return jsonify({"suggestions": chat.predict_suggestions(history, n)})
|
||||||
|
except Exception as e:
|
||||||
|
log.exception("suggest error")
|
||||||
|
return jsonify({"suggestions": chat.suggest_questions()[:n]}), 200
|
||||||
|
|
||||||
|
|
||||||
# ------------------------------------------------------------------ 对话
|
# ------------------------------------------------------------------ 对话
|
||||||
@app.route("/api/chat", methods=["POST"])
|
@app.route("/api/chat", methods=["POST"])
|
||||||
def api_chat():
|
def api_chat():
|
||||||
@@ -78,7 +94,8 @@ def api_chat():
|
|||||||
game_refs = [it for s in sources
|
game_refs = [it for s in sources
|
||||||
if s.get("tool") in ("search_games", "get_game_detail")
|
if s.get("tool") in ("search_games", "get_game_detail")
|
||||||
for it in s.get("items", [])]
|
for it in s.get("items", [])]
|
||||||
spans, cards = entity_linker.link_entities(reply, game_refs=game_refs)
|
mark_mode = admin_mod.get_config().get("entity_mark_mode", "first")
|
||||||
|
spans, cards = entity_linker.link_entities(reply, game_refs=game_refs, mark_mode=mark_mode)
|
||||||
return jsonify({"reply": reply, "sources": sources, "used_tools": used_tools,
|
return jsonify({"reply": reply, "sources": sources, "used_tools": used_tools,
|
||||||
"news_refs": news_refs, "entities": spans, "cards": cards})
|
"news_refs": news_refs, "entities": spans, "cards": cards})
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
@@ -272,3 +272,53 @@ def boot_info():
|
|||||||
"suggestions": suggest_questions(),
|
"suggestions": suggest_questions(),
|
||||||
"footer_text": cfg.get("footer_text", "NBA球迷大全 · 数据为模拟演示数据(2025-26 赛季)"),
|
"footer_text": cfg.get("footer_text", "NBA球迷大全 · 数据为模拟演示数据(2025-26 赛季)"),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def _parse_json_array(text):
|
||||||
|
"""从 LLM 输出中解析 JSON 数组(容错:直接 JSON / 提取中括号段)"""
|
||||||
|
if not text:
|
||||||
|
return []
|
||||||
|
text = text.strip()
|
||||||
|
try:
|
||||||
|
arr = json.loads(text)
|
||||||
|
if isinstance(arr, list):
|
||||||
|
return arr
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
m = re.search(r"\[.*\]", text, re.S)
|
||||||
|
if m:
|
||||||
|
try:
|
||||||
|
arr = json.loads(m.group(0))
|
||||||
|
if isinstance(arr, list):
|
||||||
|
return arr
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
return []
|
||||||
|
|
||||||
|
|
||||||
|
def predict_suggestions(history=None, n=3):
|
||||||
|
"""基于对话历史,让大模型预测用户接下来最可能追问的 n 个问题(底部快捷语句)。
|
||||||
|
每个问题不超过 30 字;LLM 异常时回退到默认快捷问题。"""
|
||||||
|
n = max(1, min(int(n or 3), 6))
|
||||||
|
history = history or []
|
||||||
|
msgs = [{"role": "system", "content": (
|
||||||
|
f"你是「NBA球迷大全」智能助手。根据对话历史,站在用户角度预测他接下来最可能追问的{n}个问题。\n"
|
||||||
|
"要求:\n"
|
||||||
|
"1. 每个问题不超过30个汉字,简洁口语化\n"
|
||||||
|
"2. 必须是用户会直接发送的提问,不要编号、不要引号、不要解释\n"
|
||||||
|
"3. 只输出JSON数组,例如:[\"库里今天拿了几分\",\"湖人下一场什么时候\"],不要输出任何其他内容")}]
|
||||||
|
for h in history[-6:]:
|
||||||
|
msgs.append({"role": "user", "content": h.get("user", "")})
|
||||||
|
if h.get("assistant"):
|
||||||
|
msgs.append({"role": "assistant", "content": str(h["assistant"])[:600]})
|
||||||
|
if len(msgs) == 1:
|
||||||
|
return DEFAULT_SUGGESTIONS[:n]
|
||||||
|
try:
|
||||||
|
resp = llm.chat(msgs, temperature=0.9, max_tokens=200)
|
||||||
|
arr = _parse_json_array(llm.parse_content(resp))
|
||||||
|
out = [str(x).strip()[:30] for x in arr if str(x).strip()][:n]
|
||||||
|
if out:
|
||||||
|
return out
|
||||||
|
except Exception as e:
|
||||||
|
log.warning("快捷问题预测失败(%s),回退默认", e)
|
||||||
|
return DEFAULT_SUGGESTIONS[:n]
|
||||||
+11
-1
@@ -164,13 +164,23 @@ def _match_games(text, game_refs):
|
|||||||
return cards
|
return cards
|
||||||
|
|
||||||
|
|
||||||
def link_entities(text, game_refs=None):
|
def link_entities(text, game_refs=None, mark_mode="first"):
|
||||||
"""主入口:扫描回答文本。
|
"""主入口:扫描回答文本。
|
||||||
返回 (spans, cards)
|
返回 (spans, cards)
|
||||||
spans: 实体命中区间(前端高亮标记用),按 start 升序、互不重叠
|
spans: 实体命中区间(前端高亮标记用),按 start 升序、互不重叠
|
||||||
|
mark_mode="first" 时同一实体(type,id)只保留首次出现;"all" 时全部标记
|
||||||
cards: 快速查看卡片数据(每类限量,避免刷屏)
|
cards: 快速查看卡片数据(每类限量,避免刷屏)
|
||||||
"""
|
"""
|
||||||
spans = _find_spans(text or "")
|
spans = _find_spans(text or "")
|
||||||
|
if mark_mode == "first":
|
||||||
|
seen, kept = set(), []
|
||||||
|
for sp in spans: # spans 已按 start 升序 → 保留首次
|
||||||
|
key = (sp["type"], sp["id"])
|
||||||
|
if key in seen:
|
||||||
|
continue
|
||||||
|
seen.add(key)
|
||||||
|
kept.append(sp)
|
||||||
|
spans = kept
|
||||||
cards = []
|
cards = []
|
||||||
seen_cards = set()
|
seen_cards = set()
|
||||||
for sp in spans:
|
for sp in spans:
|
||||||
|
|||||||
@@ -46,6 +46,9 @@ body { background:var(--bg); color:var(--txt); font-family:"PingFang SC","Micros
|
|||||||
table { width:100%; border-collapse:collapse; }
|
table { width:100%; border-collapse:collapse; }
|
||||||
th, td { padding:9px 11px; text-align:left; font-size:13px; border-bottom:1px solid var(--line); white-space:nowrap; max-width:260px; overflow:hidden; text-overflow:ellipsis; }
|
th, td { padding:9px 11px; text-align:left; font-size:13px; border-bottom:1px solid var(--line); white-space:nowrap; max-width:260px; overflow:hidden; text-overflow:ellipsis; }
|
||||||
th { background:var(--bg2); color:var(--sub); font-weight:600; font-size:12px; position:sticky; top:0; }
|
th { background:var(--bg2); color:var(--sub); font-weight:600; font-size:12px; position:sticky; top:0; }
|
||||||
|
th.sortable { cursor:pointer; user-select:none; transition:.15s; }
|
||||||
|
th.sortable:hover { color:var(--orange2); }
|
||||||
|
th.sort-active { color:var(--orange2); }
|
||||||
tr:hover td { background:rgba(249,115,22,.05); }
|
tr:hover td { background:rgba(249,115,22,.05); }
|
||||||
td.num { text-align:center; }
|
td.num { text-align:center; }
|
||||||
.row-ops { display:flex; gap:6px; }
|
.row-ops { display:flex; gap:6px; }
|
||||||
@@ -157,8 +160,17 @@ td.num { text-align:center; }
|
|||||||
<textarea id="cfg-suggestions" style="min-height:160px"></textarea>
|
<textarea id="cfg-suggestions" style="min-height:160px"></textarea>
|
||||||
<div class="tip">💡 一行一个问题。保存后刷新前台页面即可看到新的快捷问题。</div>
|
<div class="tip">💡 一行一个问题。保存后刷新前台页面即可看到新的快捷问题。</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="row2">
|
||||||
|
<div><label>对话中底部快捷问题预测个数(默认3,范围1-6)</label><input type="number" id="cfg-suggestion_count" min="1" max="6">
|
||||||
|
<div class="tip">对话进行中,大模型根据上下文预测用户可能追问的问题数量(每个≤30字)</div></div>
|
||||||
|
</div>
|
||||||
<div class="row2">
|
<div class="row2">
|
||||||
<div><label>管理员密码(留空则不修改)</label><input type="password" id="cfg-admin_password" placeholder="••••••"></div>
|
<div><label>管理员密码(留空则不修改)</label><input type="password" id="cfg-admin_password" placeholder="••••••"></div>
|
||||||
|
<div><label>实体标记模式</label><select id="cfg-entity_mark_mode">
|
||||||
|
<option value="first">只标记首次出现(推荐)</option>
|
||||||
|
<option value="all">全部标记</option>
|
||||||
|
</select>
|
||||||
|
<div class="tip">对话回答中球队/球员/人物等特殊标记策略</div></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<button class="btn" id="cfg-save">💾 保存配置</button>
|
<button class="btn" id="cfg-save">💾 保存配置</button>
|
||||||
|
|||||||
+24
-5
@@ -4,7 +4,7 @@ const $$ = (s) => [...document.querySelectorAll(s)];
|
|||||||
const esc = (s) => String(s ?? "").replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" }[c]));
|
const esc = (s) => String(s ?? "").replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" }[c]));
|
||||||
|
|
||||||
let TOKEN = localStorage.getItem("nba_admin_token") || "";
|
let TOKEN = localStorage.getItem("nba_admin_token") || "";
|
||||||
let CUR = { table: "", page: 1, q: "" };
|
let CUR = { table: "", page: 1, q: "", sort: "id", order: "desc" };
|
||||||
let LOOKUPS = {}; // teams/players/leagues/sports → {id: name}
|
let LOOKUPS = {}; // teams/players/leagues/sports → {id: name}
|
||||||
|
|
||||||
/* 字段中文名 */
|
/* 字段中文名 */
|
||||||
@@ -79,7 +79,7 @@ function switchPage(p) {
|
|||||||
$("#page-config").classList.toggle("hidden", p !== "config");
|
$("#page-config").classList.toggle("hidden", p !== "config");
|
||||||
if (p === "stats") loadStats();
|
if (p === "stats") loadStats();
|
||||||
else if (p === "config") loadConfig();
|
else if (p === "config") loadConfig();
|
||||||
else { CUR = { table: p, page: 1, q: "" }; $("#tbl-search").value = ""; loadTable(); }
|
else { CUR = { table: p, page: 1, q: "", sort: "id", order: "desc" }; $("#tbl-search").value = ""; loadTable(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================= 仪表盘 ================= */
|
/* ================= 仪表盘 ================= */
|
||||||
@@ -108,16 +108,20 @@ async function loadLookups() {
|
|||||||
|
|
||||||
async function loadTable() {
|
async function loadTable() {
|
||||||
$("#table-title").textContent = TITLE_CN[CUR.table] || CUR.table;
|
$("#table-title").textContent = TITLE_CN[CUR.table] || CUR.table;
|
||||||
const d = await api(`/api/admin/${CUR.table}?page=${CUR.page}&size=20&q=${encodeURIComponent(CUR.q)}`);
|
const d = await api(`/api/admin/${CUR.table}?page=${CUR.page}&size=20&q=${encodeURIComponent(CUR.q)}&sort=${encodeURIComponent(CUR.sort)}&order=${CUR.order}`);
|
||||||
const cols = d.columns.filter((c) => c.name !== "created_at");
|
const cols = d.columns.filter((c) => c.name !== "created_at");
|
||||||
const rows = d.rows;
|
const rows = d.rows;
|
||||||
if (!Object.keys(LOOKUPS).length) await loadLookups().catch(() => {});
|
if (!Object.keys(LOOKUPS).length) await loadLookups().catch(() => {});
|
||||||
const thead = `<tr>${cols.map((c) => `<th>${esc(FIELD_CN[CUR.table]?.[c.name] || c.name)}</th>`).join("")}<th>操作</th></tr>`;
|
const thead = `<tr>${cols.map((c) => {
|
||||||
|
const active = CUR.sort === c.name;
|
||||||
|
const arrow = active ? (CUR.order === "asc" ? " ▲" : " ▼") : "";
|
||||||
|
return `<th class="sortable ${active ? "sort-active" : ""}" data-sort="${c.name}" title="点击排序">${esc(FIELD_CN[CUR.table]?.[c.name] || c.name)}${arrow}</th>`;
|
||||||
|
}).join("")}<th>操作</th></tr>`;
|
||||||
const tbody = rows.map((r) => {
|
const tbody = rows.map((r) => {
|
||||||
const tds = cols.map((c) => {
|
const tds = cols.map((c) => {
|
||||||
let v = r[c.name];
|
let v = r[c.name];
|
||||||
if (v === null || v === undefined) v = "";
|
if (v === null || v === undefined) v = "";
|
||||||
if (c.name === "id") v = `<span class="badge">#${v}</span>`;
|
if (c.name === "id") v = v; // ID 列纯数值显示
|
||||||
else if (["team_id", "home_team_id", "away_team_id"].includes(c.name)) v = (LOOKUPS.teams || {})[v] || v;
|
else if (["team_id", "home_team_id", "away_team_id"].includes(c.name)) v = (LOOKUPS.teams || {})[v] || v;
|
||||||
else if (c.name === "player_id") v = (LOOKUPS.players || {})[v] || v;
|
else if (c.name === "player_id") v = (LOOKUPS.players || {})[v] || v;
|
||||||
else if (c.name === "league_id") v = (LOOKUPS.leagues || {})[v] || v;
|
else if (c.name === "league_id") v = (LOOKUPS.leagues || {})[v] || v;
|
||||||
@@ -141,6 +145,17 @@ $("#tbl-search-btn").addEventListener("click", () => { CUR.q = $("#tbl-search").
|
|||||||
$("#tbl-search").addEventListener("keydown", (e) => { if (e.key === "Enter") $("#tbl-search-btn").click(); });
|
$("#tbl-search").addEventListener("keydown", (e) => { if (e.key === "Enter") $("#tbl-search-btn").click(); });
|
||||||
$("#tbl-add").addEventListener("click", () => openEdit(CUR.table, null));
|
$("#tbl-add").addEventListener("click", () => openEdit(CUR.table, null));
|
||||||
|
|
||||||
|
/* 表头点击排序:首次点击升序,再点切降序,循环 */
|
||||||
|
$("#tbl-wrap").addEventListener("click", (e) => {
|
||||||
|
const th = e.target.closest("th[data-sort]");
|
||||||
|
if (!th) return;
|
||||||
|
const f = th.dataset.sort;
|
||||||
|
if (CUR.sort === f) CUR.order = CUR.order === "asc" ? "desc" : "asc";
|
||||||
|
else { CUR.sort = f; CUR.order = "asc"; }
|
||||||
|
CUR.page = 1;
|
||||||
|
loadTable();
|
||||||
|
});
|
||||||
|
|
||||||
/* ================= 编辑弹窗 ================= */
|
/* ================= 编辑弹窗 ================= */
|
||||||
let EDIT = { table: "", id: null };
|
let EDIT = { table: "", id: null };
|
||||||
|
|
||||||
@@ -207,6 +222,8 @@ async function loadConfig() {
|
|||||||
$("#cfg-welcome_hint").value = d.welcome_hint || "";
|
$("#cfg-welcome_hint").value = d.welcome_hint || "";
|
||||||
$("#cfg-footer_text").value = d.footer_text || "";
|
$("#cfg-footer_text").value = d.footer_text || "";
|
||||||
$("#cfg-admin_password").value = "";
|
$("#cfg-admin_password").value = "";
|
||||||
|
$("#cfg-entity_mark_mode").value = d.entity_mark_mode === "all" ? "all" : "first";
|
||||||
|
$("#cfg-suggestion_count").value = d.suggestion_count || "3";
|
||||||
try { $("#cfg-suggestions").value = JSON.parse(d.suggestions || "[]").join("\n"); }
|
try { $("#cfg-suggestions").value = JSON.parse(d.suggestions || "[]").join("\n"); }
|
||||||
catch (e) { $("#cfg-suggestions").value = ""; }
|
catch (e) { $("#cfg-suggestions").value = ""; }
|
||||||
$("#cfg-msg").textContent = "";
|
$("#cfg-msg").textContent = "";
|
||||||
@@ -222,6 +239,8 @@ $("#cfg-save").addEventListener("click", async () => {
|
|||||||
};
|
};
|
||||||
const pw = $("#cfg-admin_password").value;
|
const pw = $("#cfg-admin_password").value;
|
||||||
if (pw) payload.admin_password = pw;
|
if (pw) payload.admin_password = pw;
|
||||||
|
payload.entity_mark_mode = $("#cfg-entity_mark_mode").value;
|
||||||
|
payload.suggestion_count = String(Math.min(6, Math.max(1, parseInt($("#cfg-suggestion_count").value || "3"))));
|
||||||
try {
|
try {
|
||||||
await api("/api/admin/config", { method: "PUT", body: JSON.stringify(payload) });
|
await api("/api/admin/config", { method: "PUT", body: JSON.stringify(payload) });
|
||||||
$("#cfg-msg").textContent = "✅ 保存成功,前台刷新后生效";
|
$("#cfg-msg").textContent = "✅ 保存成功,前台刷新后生效";
|
||||||
|
|||||||
@@ -122,6 +122,9 @@ async function sendChat(text) {
|
|||||||
addMsg("bot", html);
|
addMsg("bot", html);
|
||||||
chatHistory.push({ user: text, assistant: d.reply });
|
chatHistory.push({ user: text, assistant: d.reply });
|
||||||
if (chatHistory.length > 20) chatHistory.splice(0, chatHistory.length - 20);
|
if (chatHistory.length > 20) chatHistory.splice(0, chatHistory.length - 20);
|
||||||
|
// 大模型预测下一轮快捷问题(异步刷新底部 chips)
|
||||||
|
const mark = chatHistory.length;
|
||||||
|
refreshChips(mark);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
typing.remove();
|
typing.remove();
|
||||||
addMsg("bot", "⚠️ 网络异常,请稍后再试。");
|
addMsg("bot", "⚠️ 网络异常,请稍后再试。");
|
||||||
@@ -139,6 +142,19 @@ function askQuick(q) {
|
|||||||
sendChat(q);
|
sendChat(q);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 底部快捷问题:对话进行中由大模型预测用户可能追问的问题(异步刷新) */
|
||||||
|
async function refreshChips(mark) {
|
||||||
|
try {
|
||||||
|
const r = await fetch("/api/suggest", { method: "POST", headers: { "Content-Type": "application/json" },
|
||||||
|
body: JSON.stringify({ history: chatHistory.slice(-6) }) });
|
||||||
|
const d = await r.json();
|
||||||
|
if (!d.suggestions || !d.suggestions.length) return;
|
||||||
|
if (mark !== chatHistory.length) return; // 期间用户又发了新消息 → 丢弃过期预测
|
||||||
|
$("#chips").innerHTML = d.suggestions.map((q) => `<button>${esc(q)}</button>`).join("");
|
||||||
|
$$("#chips button").forEach((b) => b.addEventListener("click", () => askQuick(b.textContent)));
|
||||||
|
} catch (e) {}
|
||||||
|
}
|
||||||
|
|
||||||
/* 聊天区事件委托:快捷语句 / 实体标记 / 新闻链接 / 卡片 */
|
/* 聊天区事件委托:快捷语句 / 实体标记 / 新闻链接 / 卡片 */
|
||||||
$("#chat-list").addEventListener("click", (e) => {
|
$("#chat-list").addEventListener("click", (e) => {
|
||||||
const q = e.target.closest(".quick-q");
|
const q = e.target.closest(".quick-q");
|
||||||
|
|||||||
@@ -25,7 +25,6 @@
|
|||||||
<button class="tab" data-view="persons">👥 人物</button>
|
<button class="tab" data-view="persons">👥 人物</button>
|
||||||
<button class="tab" data-view="standings">🏆 排名</button>
|
<button class="tab" data-view="standings">🏆 排名</button>
|
||||||
</nav>
|
</nav>
|
||||||
<a class="admin-link" href="/admin" title="管理后台">⚙️</a>
|
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<main>
|
<main>
|
||||||
|
|||||||
+15
-15
@@ -30,32 +30,32 @@ main { flex: 1; width: 100%; max-width: 1200px; margin: 0 auto; padding: 20px 16
|
|||||||
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
|
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
|
||||||
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--card); border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; font-size: 19px; flex-shrink: 0; }
|
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--card); border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; font-size: 19px; flex-shrink: 0; }
|
||||||
.msg.user .avatar { background: linear-gradient(135deg, #f97316, #ea580c); border: none; }
|
.msg.user .avatar { background: linear-gradient(135deg, #f97316, #ea580c); border: none; }
|
||||||
.bubble { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px; font-size: 14.5px; line-height: 1.75; white-space: pre-wrap; word-break: break-word; }
|
.bubble { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px; font-size: 14.5px; line-height: 1.55; white-space: normal; word-break: break-word; }
|
||||||
.msg.user .bubble { background: #2a1c10; border-color: #7c3a1e; }
|
.msg.user .bubble { background: #2a1c10; border-color: #7c3a1e; white-space: pre-wrap; }
|
||||||
.bubble b { color: var(--orange2); }
|
.bubble b { color: var(--orange2); }
|
||||||
.bubble em { color: var(--blue); font-style: normal; }
|
.bubble em { color: var(--blue); font-style: normal; }
|
||||||
.bubble .hint { color: var(--sub); font-size: 13px; margin-top: 6px; }
|
.bubble .hint { color: var(--sub); font-size: 13px; margin-top: 6px; }
|
||||||
.bubble .quick-q { color: var(--blue); cursor: pointer; text-decoration: none; border-bottom: 1px dashed var(--blue); }
|
.bubble .quick-q { color: var(--blue); cursor: pointer; text-decoration: none; border-bottom: 1px dashed var(--blue); }
|
||||||
.bubble .quick-q:hover { color: var(--orange2); border-bottom-color: var(--orange2); }
|
.bubble .quick-q:hover { color: var(--orange2); border-bottom-color: var(--orange2); }
|
||||||
.bubble ul { margin: 6px 0 6px 18px; }
|
.bubble ul { margin: 4px 0 4px 18px; }
|
||||||
.bubble li { margin: 3px 0; }
|
.bubble li { margin: 2px 0; }
|
||||||
|
|
||||||
/* ---------- Markdown 渲染(需求3) ---------- */
|
/* ---------- Markdown 渲染(需求3) ---------- */
|
||||||
.md { line-height: 1.8; }
|
.md { line-height: 1.6; }
|
||||||
.md h1, .md h2, .md h3, .md h4 { margin: 12px 0 6px; line-height: 1.4; }
|
.md h1, .md h2, .md h3, .md h4 { margin: 10px 0 4px; line-height: 1.35; }
|
||||||
.md h1 { font-size: 17px; } .md h2 { font-size: 16px; } .md h3, .md h4 { font-size: 15px; }
|
.md h1 { font-size: 16.5px; } .md h2 { font-size: 15.5px; } .md h3, .md h4 { font-size: 14.5px; }
|
||||||
.md h1::before, .md h2::before { content: ""; }
|
.md h1::before, .md h2::before { content: ""; }
|
||||||
.md p { margin: 6px 0; }
|
.md p { margin: 4px 0; }
|
||||||
.md ul, .md ol { margin: 6px 0 6px 20px; }
|
.md ul, .md ol { margin: 4px 0 4px 20px; }
|
||||||
.md li { margin: 3px 0; }
|
.md li { margin: 2px 0; }
|
||||||
.md code { background: #0d1117; border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; font-size: 12.5px; font-family: Consolas, monospace; color: var(--green); }
|
.md code { background: #0d1117; border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; font-size: 12.5px; font-family: Consolas, monospace; color: var(--green); }
|
||||||
.md pre { background: #0d1117; border: 1px solid var(--line); border-radius: 10px; padding: 12px; overflow-x: auto; margin: 8px 0; }
|
.md pre { background: #0d1117; border: 1px solid var(--line); border-radius: 10px; padding: 10px; overflow-x: auto; margin: 6px 0; }
|
||||||
.md pre code { background: transparent; border: none; padding: 0; color: var(--txt); }
|
.md pre code { background: transparent; border: none; padding: 0; color: var(--txt); }
|
||||||
.md blockquote { border-left: 3px solid var(--orange2); padding: 2px 12px; margin: 8px 0; color: var(--sub); background: rgba(249,115,22,.06); border-radius: 0 8px 8px 0; }
|
.md blockquote { border-left: 3px solid var(--orange2); padding: 2px 12px; margin: 6px 0; color: var(--sub); background: rgba(249,115,22,.06); border-radius: 0 8px 8px 0; }
|
||||||
.md table { display: block; width: 100%; overflow-x: auto; margin: 10px 0; }
|
.md table { display: block; width: 100%; overflow-x: auto; margin: 8px 0; }
|
||||||
.md table th, .md table td { padding: 7px 10px; font-size: 12.5px; }
|
.md table th, .md table td { padding: 6px 9px; font-size: 12.5px; }
|
||||||
.md table th { background: var(--bg2); color: var(--orange2); }
|
.md table th { background: var(--bg2); color: var(--orange2); }
|
||||||
.md hr { border: none; border-top: 1px solid var(--line); margin: 10px 0; }
|
.md hr { border: none; border-top: 1px solid var(--line); margin: 8px 0; }
|
||||||
.md a { color: var(--blue); text-decoration: none; }
|
.md a { color: var(--blue); text-decoration: none; }
|
||||||
.md a:hover { text-decoration: underline; }
|
.md a:hover { text-decoration: underline; }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user