feat: 初始版本,圆角主题与首次管理员引导

This commit is contained in:
2025-12-07 10:53:52 +08:00
commit 63db6a0815
43 changed files with 1293 additions and 0 deletions

28
app/services/images.py Normal file
View File

@@ -0,0 +1,28 @@
import os
import uuid
import json
from PIL import Image, ExifTags
def save_image(file_storage, base_dir):
ext = os.path.splitext(file_storage.filename)[1].lower()
name = f"{uuid.uuid4().hex}{ext}"
original_path = os.path.join(base_dir, name)
file_storage.save(original_path)
web_path = os.path.join(base_dir, f"web_{name}")
thumb_path = os.path.join(base_dir, f"thumb_{name}")
with Image.open(original_path) as im:
im_web = im.copy()
im_web.thumbnail((1600, 1600))
im_web.save(web_path)
im_thumb = im.copy()
im_thumb.thumbnail((400, 400))
im_thumb.save(thumb_path)
exif = {}
try:
raw = im.getexif()
for k, v in raw.items():
tag = ExifTags.TAGS.get(k, str(k))
exif[tag] = str(v)
except Exception:
exif = {}
return original_path, web_path, thumb_path, json.dumps(exif)

6
app/services/notify.py Normal file
View File

@@ -0,0 +1,6 @@
from ..extensions import db
from ..models import Notification
def notify(user_id, type_, payload_json=None):
n = Notification(user_id=user_id, type=type_, payload_json=payload_json)
db.session.add(n)