Skip to content

Commit 6c3c5c8

Browse files
committed
feat: 添加platform字段到status API,用于OneBot判断平台类型
1 parent 1c5135e commit 6c3c5c8

2 files changed

Lines changed: 10 additions & 13 deletions

File tree

backend/src/module/api/program.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import logging
22
import os
33
import signal
4+
import sys
45

56
from fastapi import APIRouter, Depends, HTTPException
67
from fastapi.responses import JSONResponse
@@ -68,18 +69,14 @@ async def stop():
6869

6970
@router.get("/status", response_model=dict, dependencies=[Depends(get_current_user)])
7071
async def program_status():
71-
if not program.is_running:
72-
return {
73-
"status": False,
74-
"version": VERSION,
75-
"first_run": program.first_run,
76-
}
77-
else:
78-
return {
79-
"status": True,
80-
"version": VERSION,
81-
"first_run": program.first_run,
82-
}
72+
is_linux = sys.platform == "linux"
73+
base = {
74+
"status": program.is_running,
75+
"version": VERSION,
76+
"first_run": program.first_run,
77+
"platform": "linux" if is_linux else "windows",
78+
}
79+
return base
8380

8481

8582
@router.get(

webui/src/api/program.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const apiProgram = {
2929
* 状态
3030
*/
3131
async status() {
32-
const { data } = await axios.get<{ status: boolean; version: string }>(
32+
const { data } = await axios.get<{ status: boolean; version: string; platform: string; first_run: boolean }>(
3333
'api/v1/status'
3434
);
3535

0 commit comments

Comments
 (0)