diff --git a/.github/workflows/friend_circle_lite.yml b/.github/workflows/friend_circle_lite.yml index 5ca5f59..82da3e2 100644 --- a/.github/workflows/friend_circle_lite.yml +++ b/.github/workflows/friend_circle_lite.yml @@ -64,7 +64,7 @@ jobs: - name: Commit changes run: | mkdir pages - cp -r main ./static/index.html ./static/readme.md ./static/favicon.ico all.json errors.json pages/ + cp -r main ./static/index.html ./static/readme.md ./static/favicon.ico ./static/bg-light.webp all.json errors.json pages/ cd pages git init git add . diff --git a/readme.md b/readme.md index 53e8f6d..032dcb9 100644 --- a/readme.md +++ b/readme.md @@ -11,6 +11,12 @@ ## 开发进度 +### 2024-09-28 + +* 更新自部署的api地址,统一为all.json,提高js兼容性 +* 美化展示页面UI(@JLinMr),添加背景图片 +* 优化作者卡片弹窗动效(@JLinMr) + ### 2024-09-22 * 修复 #18 提出的,由于rss倒序导致限制抓取错误的问题,改为先全部获取后,按照时间排序,再选择性获取 @@ -20,14 +26,13 @@ * 更新部署方式,将静态文件放到page分支下,主分支不放数据文件 * 前后端分离,部署方式不变但更加直观方便 -### 2024-09-03 - -* 添加特定RSS选项,用于指定部分友链特殊RSS地址 -* 更新文档,添加特定RSS选项配置部分 -
查看更多 +

2024-09-03

+ +* 添加特定RSS选项,用于指定部分友链特殊RSS地址 +* 更新文档,添加特定RSS选项配置部分

2024-08-28

diff --git a/server.py b/server.py index 9096097..75478ac 100644 --- a/server.py +++ b/server.py @@ -1,5 +1,6 @@ from fastapi import FastAPI -from fastapi.responses import HTMLResponse, JSONResponse +from fastapi.staticfiles import StaticFiles +from fastapi.responses import FileResponse, HTMLResponse, JSONResponse from starlette.middleware.cors import CORSMiddleware import json import random @@ -9,6 +10,9 @@ from friend_circle_lite.get_conf import load_config app = FastAPI() +# 设置静态文件目录 +app.mount("/static", StaticFiles(directory="static"), name="static") + # 添加 CORS 中间件 app.add_middleware( CORSMiddleware, @@ -17,15 +21,19 @@ app.add_middleware( allow_methods=["*"], allow_headers=["*"], ) +# 返回图标图片 +@app.get("/favicon.ico", response_class=HTMLResponse) +async def favicon(): + return FileResponse('static/favicon.ico') + +# 返回背景图片 +@app.get("/bg-light.webp", response_class=HTMLResponse) +async def bg_light(): + return FileResponse('static/bg-light.webp') @app.get("/", response_class=HTMLResponse) async def root(): - try: - with open('./static/index.html', 'r', encoding='utf-8') as f: - html_content = f.read() - return HTMLResponse(content=html_content) - except FileNotFoundError: - return HTMLResponse(content="

File not found

", status_code=404) + return FileResponse('./static/index.html') @app.get('/all.json') async def get_all_articles(): diff --git a/static/bg-light.webp b/static/bg-light.webp new file mode 100644 index 0000000..c977104 Binary files /dev/null and b/static/bg-light.webp differ diff --git a/static/index.html b/static/index.html index 8d6719a..c071988 100644 --- a/static/index.html +++ b/static/index.html @@ -11,7 +11,7 @@