Files
news-tracker/templates/profile.html
T

68 lines
2.5 KiB
HTML

{% extends "base.html" %}
{% set active = 'profile' %}
{% block title %}兴趣画像 - 新闻智能跟踪{% endblock %}
{% block content %}
<div class="page-head">
<h1>🎯 兴趣画像</h1>
<p class="muted">系统据此判断资讯对您的重要度与相关度。修改后建议在仪表盘点「重新打分」。</p>
</div>
<div class="two-col">
<section class="card">
<h3>🔑 关注关键词</h3>
<div class="form-row">
<input id="kw_name" placeholder="关键词">
<input id="kw_weight" type="number" value="5" style="width:80px" title="权重">
<button class="btn" onclick="addItem('keyword')">添加</button>
</div>
<div class="tag-list">
{% for k in keywords %}
<span class="chip">{{ k.keyword }} <b>{{ k.weight }}</b> <a class="chip-x" onclick="delItem('keyword', {{ k.id }})"></a></span>
{% endfor %}
</div>
</section>
<section class="card">
<h3>🏷️ 关注公司/实体</h3>
<div class="form-row">
<input id="co_name" placeholder="公司名(如:字节跳动)">
<button class="btn" onclick="addItem('company')">添加</button>
</div>
<div class="tag-list">
{% for c in companies %}
<span class="chip">{{ c.name }} <a class="chip-x" onclick="delItem('company', {{ c.id }})"></a></span>
{% endfor %}
</div>
</section>
</div>
<section class="card">
<h3>🗂️ 关注领域</h3>
<div class="form-row">
<input id="dm_name" placeholder="领域名(如:具身智能)">
<input id="dm_weight" type="number" value="5" style="width:80px" title="权重">
<button class="btn" onclick="addItem('domain')">添加</button>
</div>
<div class="tag-list">
{% for d in domains %}
<span class="chip">{{ d.name }} <b>{{ d.weight }}</b> <a class="chip-x" onclick="delItem('domain', {{ d.id }})"></a></span>
{% endfor %}
</div>
</section>
{% endblock %}
{% block script %}
<script>
async function addItem(kind){
const nameEl = document.getElementById(kind==='keyword'?'kw_name':(kind==='domain'?'dm_name':'co_name'));
const weightEl = document.getElementById(kind==='keyword'?'kw_weight':(kind==='domain'?'dm_weight':null));
const name = nameEl.value.trim(); if (!name) return;
const r = await API.json('/api/profile', {action:'add', kind, name, weight: weightEl?parseInt(weightEl.value)||5:5});
if (r.ok){ toast('✅ 已添加'); setTimeout(()=>location.reload(), 400); }
}
async function delItem(kind, id){
await API.json('/api/profile', {action:'delete', kind, id});
location.reload();
}
</script>
{% endblock %}