后端实现系统信息获取api

This commit is contained in:
Chenx221 2024-04-15 16:07:50 +08:00
parent df9292ff94
commit 2f8999cb3d
Signed by: chenx221
GPG Key ID: D7A9EC07024C3021

View File

@ -46,7 +46,7 @@ class AdminController extends Controller
'actions' => ['index', 'system', 'user', 'info', 'user-view', 'user-create', 'user-update', 'actions' => ['index', 'system', 'user', 'info', 'user-view', 'user-create', 'user-update',
'user-delete', 'user-totpoff', 'user-pwdreset', 'login-log', 'access-log', 'collection-up-log', 'user-delete', 'user-totpoff', 'user-pwdreset', 'login-log', 'access-log', 'collection-up-log',
'share-manage', 'share-manage-view', 'share-manage-delete', 'collection-manage', 'collection-manage-view', 'share-manage', 'share-manage-view', 'share-manage-delete', 'collection-manage', 'collection-manage-view',
'collection-manage-delete', 'notice-manage', 'feedback-manage', 'sysinfo'], 'collection-manage-delete', 'notice-manage', 'feedback-manage', 'sysinfo','get-sysinfo'],
'roles' => ['admin'], // only admin can do these 'roles' => ['admin'], // only admin can do these
] ]
], ],
@ -76,6 +76,7 @@ class AdminController extends Controller
'notice-manage' => ['GET'], 'notice-manage' => ['GET'],
'feedback-manage' => ['GET'], 'feedback-manage' => ['GET'],
'sysinfo' => ['GET'], 'sysinfo' => ['GET'],
'get-sysinfo' => ['GET'],
], ],
], ],
] ]
@ -593,11 +594,19 @@ class AdminController extends Controller
} }
/** /**
* Get server status * Get server status (mini)
* @return void
*/ */
public function actionGetSysinfo(): void public function actionGetSysinfo(): \yii\console\Response|Response
{ {
//TODO: Implement this method if (Yii::$app->request->isAjax) {
$MiniInfo = SystemInfoHelper::getSysInfoFre();
Yii::$app->response->format = Response::FORMAT_JSON;
Yii::$app->response->data = $MiniInfo;
} else {
Yii::$app->response->format = Response::FORMAT_JSON;
Yii::$app->response->data = ['error' => 'Invalid request'];
}
return Yii::$app->response;
} }
} }