v1.2.12 新闻页增强:类别筛选标签(全部/新闻/百科/总决赛/续约/中国球员/选秀) + 分页控件(10条/页),可与搜索组合
This commit is contained in:
@@ -191,15 +191,10 @@ def api_playoffs():
|
||||
def api_news():
|
||||
q = request.args.get("q", "")
|
||||
kind = request.args.get("kind", "")
|
||||
limit = int(request.args.get("limit", 20))
|
||||
if q:
|
||||
r = tools.search_news(q, limit=limit)
|
||||
return jsonify(r.get("results", []))
|
||||
from db import query
|
||||
rows = query("""SELECT id,title,author,source,publish_time,tags,kind,substr(content,1,160) AS summary
|
||||
FROM news WHERE (?='' OR kind=?) ORDER BY publish_time DESC, id DESC LIMIT ?""",
|
||||
(kind, kind, limit))
|
||||
return jsonify(rows)
|
||||
tag = request.args.get("tag", "")
|
||||
page = max(1, int(request.args.get("page", 1)))
|
||||
size = min(30, max(1, int(request.args.get("size", 10))))
|
||||
return jsonify(tools.list_news(q, kind=kind, tag=tag, page=page, size=size))
|
||||
|
||||
|
||||
@app.route("/api/news/<int:nid>")
|
||||
|
||||
Reference in New Issue
Block a user