diff --git a/src/api/index.js b/src/api/index.js index bcddbfd..13326df 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -67,32 +67,33 @@ export const instanceApi = { runUser, additionalProperties }), - deleteInstance: (instanceName) => - api.post('/frpcAct/instanceMgr/delete', { instanceName }), - modifyInstance: (instanceName, instanceID, type, modifiedData) => + deleteInstance: (instanceID) => + api.post('/frpcAct/instanceMgr/delete', { instanceID }), + modifyInstance: (instanceID, type, modifiedData) => api.post('/frpcAct/instanceMgr/modify', { - instanceName, instanceID, type, modifiedData }), listInstances: () => api.get('/frpcAct/instanceMgr/list'), - startInstance: (instanceName) => - api.post('/frpcAct/instanceMgr/start', { instanceName }), - stopInstance: (instanceName) => - api.post('/frpcAct/instanceMgr/stop', { instanceName }), - restartInstance: (instanceName) => - api.post('/frpcAct/instanceMgr/restart', { instanceName }), - getInstanceLogs: (instanceName) => - api.get('/frpcAct/instanceMgr/logs', { params: { instanceName } }), + startInstance: (instanceID) => + api.post('/frpcAct/instanceMgr/start', { instanceID }), + stopInstance: (instanceID) => + api.post('/frpcAct/instanceMgr/stop', { instanceID }), + restartInstance: (instanceID) => + api.post('/frpcAct/instanceMgr/restart', { instanceID }), + getInstanceStatus: (instanceID) => + api.post('/frpcAct/instanceMgr/status', { instanceID }), + getInstanceLogs: (instanceID) => + api.post('/frpcAct/instanceMgr/logs', { instanceID }), getInstanceProxies: (instanceID) => - api.get('/frpcAct/proxyMgr/list', { params: { instanceID } }), + api.get(`/frpcAct/proxyMgr/list?instanceID=${instanceID}`), createProxy: (instanceID, proxyInfo) => api.post('/frpcAct/proxyMgr/create', { instanceID, proxyInfo }) }; export const logApi = { - getLogs: (level) => api.get('/logMgr/list', { params: { level } }) + getLogs: (level) => api.post('/logMgr/list', { level }) }; export const monitorApi = { @@ -106,9 +107,6 @@ export const systemInfoApi = { export default api; export const TODO_API_NOTES = { - instanceStart: 'TODO: /frpcAct/instanceMgr/start - 启动实例 API 未在 api-backend.md 中定义', - instanceStop: 'TODO: /frpcAct/instanceMgr/stop - 停止实例 API 未在 api-backend.md 中定义', - instanceRestart: 'TODO: /frpcAct/instanceMgr/restart - 重启实例 API 未在 api-backend.md 中定义', instanceLogs: 'TODO: /frpcAct/instanceMgr/logs - 获取实例日志 API 未在 api-backend.md 中定义', instanceProxies: 'TODO: /frpcAct/instanceMgr/proxies - 获取实例代理列表 API 未在 api-backend.md 中定义', logList: 'TODO: /logMgr/list - 获取系统日志 API 未在 api-backend.md 中定义', diff --git a/src/components/TopBar.vue b/src/components/TopBar.vue index 3edce4b..feec830 100644 --- a/src/components/TopBar.vue +++ b/src/components/TopBar.vue @@ -114,7 +114,7 @@ export default { onMounted(() => { checkStatus(); getSoftwareInfo(); - setInterval(checkStatus, 5000); + setInterval(checkStatus, 60000); document.addEventListener('click', closeMenu); }); diff --git a/src/router/index.js b/src/router/index.js index 6bb2150..dc78f28 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -21,7 +21,7 @@ const routes = [ component: () => import('../views/Instances.vue') }, { - path: 'instances/:name', + path: 'instances/:id', name: 'InstanceDetail', component: () => import('../views/InstanceDetail.vue') }, diff --git a/src/views/InstanceDetail.vue b/src/views/InstanceDetail.vue index 4b28257..13d4861 100644 --- a/src/views/InstanceDetail.vue +++ b/src/views/InstanceDetail.vue @@ -4,10 +4,53 @@ -

{{ instanceName }} - Details

+

{{ instanceID }} - Details

+
+

Instance Status +
+ + +
+

+
+
+ Status: + + {{ instanceStatus === 'running' ? 'Running' : 'Stopped' }} + +
+
+ PID: + {{ statusInfo.pid }} +
+
+ Init System: + {{ statusInfo.initSystem }} +
+
+ Service Name: + {{ statusInfo.serviceName }} +
+
+
+

Configuration

@@ -164,7 +164,7 @@ import { ref, computed, onMounted } from 'vue'; import { useRouter } from 'vue-router'; import { instanceApi } from '../api/index.js'; -import { showNotification, formatDate, highlightText } from '../utils/functions.js'; +import { showNotification, formatDate, highlightText, getCookie } from '../utils/functions.js'; export default { name: 'Instances', @@ -179,6 +179,7 @@ export default { const instances = ref([]); const showAddModal = ref(false); const loading = ref(false); + const userType = ref(getCookie('user-type') || 'visitor'); const formData = ref({ name: '', auth_method: 'token', @@ -207,14 +208,23 @@ export default { ...instance, status: 'stopped' })); + + for (const instance of instances.value) { + try { + const statusResult = await instanceApi.getInstanceStatus(String(instance.instanceID)); + instance.status = statusResult.data.status; + } catch (error) { + console.error(`Failed to load status for instance ${instance.instanceID}:`, error); + } + } } catch (error) { showNotification('Load instance list failed', 'error'); } }; - const startInstance = async (instanceName) => { + const startInstance = async (instanceID) => { try { - await instanceApi.startInstance(instanceName); + await instanceApi.startInstance(instanceID); showNotification('Instance started successfully', 'success'); await loadInstances(); } catch (error) { @@ -222,9 +232,9 @@ export default { } }; - const stopInstance = async (instanceName) => { + const stopInstance = async (instanceID) => { try { - await instanceApi.stopInstance(instanceName); + await instanceApi.stopInstance(instanceID); showNotification('Instance stopped successfully', 'success'); await loadInstances(); } catch (error) { @@ -232,8 +242,8 @@ export default { } }; - const goToDetail = (instanceName) => { - router.push(`/instances/${instanceName}`); + const goToDetail = (instanceID) => { + router.push(`/instances/${instanceID}`); }; const handleAddInstance = async () => { @@ -297,6 +307,7 @@ export default { return { instances, filteredInstances, + userType, startInstance, stopInstance, goToDetail,