feat: 添加页脚和ICP备案信息到系统设置和页面
1. 新增页脚信息和ICP备案信息的系统配置项 2. 开放公开接口获取新增的系统设置项 3. 在管理端布局添加页脚和ICP备案展示
This commit is contained in:
parent
cab1bf1f61
commit
924885e038
@ -73,18 +73,21 @@ async def get_public_setting(
|
||||
key: str = None,
|
||||
db: AsyncSession = Depends(get_db),
|
||||
):
|
||||
"""公开接口:获取系统设置(仅允许获取id为1或key为"系统标题"的内容)"""
|
||||
"""公开接口:获取系统设置(允许获取id为1/2或key为"系统标题"/"IPC内容"的内容)"""
|
||||
ALLOWED_IDS = {1, 2, 3}
|
||||
ALLOWED_KEYS = {"系统标题", "页脚信息", "IPC信息"}
|
||||
|
||||
if setting_id is not None:
|
||||
if setting_id != 1:
|
||||
if setting_id not in ALLOWED_IDS:
|
||||
raise HTTPException(status_code=403, detail="无权访问该设置项")
|
||||
result = await db.execute(select(SystemSetting).filter(SystemSetting.id == setting_id))
|
||||
elif key is not None:
|
||||
if key != "系统标题":
|
||||
if key not in ALLOWED_KEYS:
|
||||
raise HTTPException(status_code=403, detail="无权访问该设置项")
|
||||
result = await db.execute(select(SystemSetting).filter(SystemSetting.key == key))
|
||||
else:
|
||||
raise HTTPException(status_code=400, detail="必须提供setting_id或key参数")
|
||||
|
||||
|
||||
setting = result.scalar_one_or_none()
|
||||
if not setting:
|
||||
raise HTTPException(status_code=404, detail="设置项不存在")
|
||||
|
||||
@ -349,6 +349,18 @@ async def init_system_settings(db: AsyncSession):
|
||||
"type": "string",
|
||||
"description": "系统显示标题"
|
||||
},
|
||||
{
|
||||
"key": "页脚信息",
|
||||
"value": "© 2026 图书管理系统 版权所有 | 技术支持:强蕊科技",
|
||||
"type": "string",
|
||||
"description": "页脚信息"
|
||||
},
|
||||
{
|
||||
"key": "ICP信息",
|
||||
"value": "京ICP备2023000000号",
|
||||
"type": "string",
|
||||
"description": "ICP备案信息"
|
||||
}
|
||||
]
|
||||
|
||||
# 检查现有系统设置
|
||||
|
||||
@ -53,6 +53,13 @@
|
||||
<div class="page-content">
|
||||
<router-view />
|
||||
</div>
|
||||
<!-- IPC 页脚 -->
|
||||
<div class="footer" v-if="footerInfo">
|
||||
{{ footerInfo }}
|
||||
<a href="https://beian.miit.gov.cn" target="_blank">
|
||||
<span v-if="ipcContent"> | {{ ipcContent }}</span>
|
||||
</a>
|
||||
</div>
|
||||
</el-main>
|
||||
</el-container>
|
||||
</el-container>
|
||||
@ -70,6 +77,8 @@ const route = useRoute();
|
||||
const router = useRouter();
|
||||
const auth = useAuthStore();
|
||||
const sysTitle = ref("");
|
||||
const footerInfo = ref("");
|
||||
const ipcContent = ref("");
|
||||
|
||||
const active = computed(() => route.path);
|
||||
const pageTitle = computed(() => (route.meta.title as string) || "");
|
||||
@ -98,9 +107,35 @@ async function getSysTitle() {
|
||||
}
|
||||
}
|
||||
|
||||
async function getfooterInfo() {
|
||||
try {
|
||||
const baseURL = import.meta.env.VITE_API_BASE || "/api";
|
||||
let res = await axios.get(`${baseURL}/settings/public?setting_id=2`)
|
||||
if (res.data) {
|
||||
footerInfo.value = res.data.value;
|
||||
}
|
||||
} catch {
|
||||
// 脚注内容加载失败不影响页面正常显示
|
||||
}
|
||||
}
|
||||
|
||||
async function getipcContent() {
|
||||
try {
|
||||
const baseURL = import.meta.env.VITE_API_BASE || "/api";
|
||||
let res = await axios.get(`${baseURL}/settings/public?setting_id=3`)
|
||||
if (res.data) {
|
||||
ipcContent.value = res.data.value;
|
||||
}
|
||||
} catch {
|
||||
// IPC内容加载失败不影响页面正常显示
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
await getSysTitle();
|
||||
await getfooterInfo();
|
||||
await getipcContent();
|
||||
if (!auth.user) {
|
||||
await auth.fetchProfile();
|
||||
}
|
||||
@ -166,4 +201,13 @@ async function onLogout() {
|
||||
flex-direction: column;
|
||||
min-width: 0;
|
||||
}
|
||||
.footer {
|
||||
flex-shrink: 0;
|
||||
margin-top: auto;
|
||||
padding: 12px 0;
|
||||
text-align: center;
|
||||
font-size: 13px;
|
||||
color: #94a3b8;
|
||||
border-top: 1px solid #e2e8f0;
|
||||
}
|
||||
</style>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user