27 lines
992 B
Python
27 lines
992 B
Python
# -*- coding: utf-8 -*-
|
|
"""公共配置端点:无需登录或特殊角色即可读取的站点级配置。
|
|
|
|
只暴露 ``site.`` 前缀的配置(如 Header 广告词),避免泄露短信密钥等敏感配置。
|
|
写入仍走 ``/admin/config/{key}``(要求 operator + config.manage 权限)。
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
from fastapi import APIRouter, Depends
|
|
|
|
from ..dependencies import get_db
|
|
from ...infrastructure.repositories import Database
|
|
|
|
router = APIRouter(tags=["public"])
|
|
|
|
|
|
@router.get("/site/config", summary="公共站点配置列表(所有用户可读)")
|
|
async def list_site_config(
|
|
db: Database = Depends(get_db),
|
|
):
|
|
"""返回所有 ``site.`` 前缀的配置项,供桌面端 / 小程序 / web 端读取。
|
|
|
|
不要求登录或 operator 角色;敏感配置(短信密钥等)不会出现在这里。
|
|
"""
|
|
all_config = await db.config.all()
|
|
return [item for item in all_config if str(item.get("key", "")).startswith("site.")]
|