feat: cron task style fix

This commit is contained in:
engigu
2025-12-21 14:30:59 +08:00
parent f0beb8a654
commit d8b5b75eaf
11 changed files with 174 additions and 67 deletions
+3 -3
View File
@@ -108,7 +108,7 @@ export const api = {
changePassword: (data: { old_password: string; new_password: string }) =>
request('/settings/password', { method: 'POST', body: JSON.stringify(data) }),
cleanLogs: (days: number) =>
request<{ deleted: number }>('/settings/clean-logs', { method: 'POST', body: JSON.stringify({ days }) }),
request<{ deleted: number }>('/settings/cleanlogs', { method: 'POST', body: JSON.stringify({ days }) }),
getSite: () => request<SiteSettings>('/settings/site'),
getPublicSite: () => request<{ title: string; subtitle: string; icon: string }>('/settings/public'),
updateSite: (data: SiteSettings) =>
@@ -119,7 +119,7 @@ export const api = {
if (params?.page) query.set('page', String(params.page))
if (params?.page_size) query.set('page_size', String(params.page_size))
if (params?.username) query.set('username', params.username)
return request<LoginLogListResponse>(`/settings/login-logs?${query}`)
return request<LoginLogListResponse>(`/settings/loginlogs?${query}`)
}
},
files: {
@@ -157,7 +157,7 @@ export const api = {
}
if (targetPath) formData.append('path', targetPath)
const res = await fetch(`${BASE_URL}/files/upload-files`, {
const res = await fetch(`${BASE_URL}/files/uploadfiles`, {
method: 'POST',
credentials: 'include',
body: formData
+1 -1
View File
@@ -18,7 +18,7 @@ const navItems = [
{ to: '/history', icon: ScrollText, label: '执行历史', exact: true },
{ to: '/environments', icon: Variable, label: '环境变量', exact: true },
{ to: '/terminal', icon: Terminal, label: '终端命令', exact: true },
{ to: '/login-logs', icon: KeyRound, label: '登录日志', exact: true },
{ to: '/loginlogs', icon: KeyRound, label: '登录日志', exact: true },
{ to: '/settings', icon: Settings, label: '系统设置', exact: true },
]
+1 -1
View File
@@ -20,7 +20,7 @@ const router = createRouter({
{ path: 'editor/:path(.*)?', name: 'editor', component: () => import('@/views/editor/Editor.vue') },
{ path: 'environments', name: 'environments', component: () => import('@/views/environments/Environments.vue') },
{ path: 'history', name: 'history', component: () => import('@/views/history/History.vue') },
{ path: 'login-logs', name: 'login-logs', component: () => import('@/views/login-logs/LoginLogs.vue') },
{ path: 'loginlogs', name: 'loginlogs', component: () => import('@/views/loginlogs/LoginLogs.vue') },
{ path: 'terminal', name: 'terminal', component: () => import('@/views/terminal/Terminal.vue') },
{ path: 'settings', name: 'settings', component: () => import('@/views/settings/Settings.vue') }
]
+3 -3
View File
@@ -117,12 +117,12 @@ onMounted(loadLogs)
<div class="flex gap-4">
<!-- 日志列表 -->
<div class="flex-1 rounded-lg border bg-card">
<div class="flex-1 min-w-0 rounded-lg border bg-card">
<!-- 表头 -->
<div class="flex items-center gap-4 px-4 py-2 border-b bg-muted/50 text-sm text-muted-foreground font-medium">
<span class="w-12 shrink-0">ID</span>
<span class="w-32 shrink-0">任务名称</span>
<span class="flex-1">命令</span>
<span :class="selectedLog ? 'w-40 shrink-0' : 'flex-1'">命令</span>
<span class="w-12 shrink-0 text-center">状态</span>
<span class="w-20 text-right shrink-0">耗时</span>
<span class="w-40 text-right shrink-0">执行时间</span>
@@ -143,7 +143,7 @@ onMounted(loadLogs)
>
<span class="w-12 shrink-0 text-muted-foreground text-sm">#{{ log.id }}</span>
<span class="w-32 font-medium truncate shrink-0 text-sm">{{ log.task_name }}</span>
<code class="flex-1 text-muted-foreground truncate text-xs bg-muted px-2 py-1 rounded">{{ log.command }}</code>
<code :class="['text-muted-foreground truncate text-xs bg-muted px-2 py-1 rounded', selectedLog ? 'w-40 shrink-0' : 'flex-1']">{{ log.command }}</code>
<span class="w-12 flex justify-center shrink-0">
<span :class="['w-2 h-2 rounded-full', log.status === 'success' ? 'bg-green-500' : log.status === 'failed' ? 'bg-red-500' : 'bg-yellow-500']" />
</span>
@@ -58,15 +58,6 @@ function handlePageChange(page: number) {
loadLogs()
}
function getBrowserInfo(userAgent: string): string {
if (!userAgent) return '未知'
if (userAgent.includes('Chrome')) return 'Chrome'
if (userAgent.includes('Firefox')) return 'Firefox'
if (userAgent.includes('Safari')) return 'Safari'
if (userAgent.includes('Edge')) return 'Edge'
return '其他'
}
onMounted(loadLogs)
</script>
@@ -98,9 +89,8 @@ onMounted(loadLogs)
<div class="flex items-center gap-4 px-4 py-2 border-b bg-muted/50 text-sm text-muted-foreground font-medium">
<span class="w-24 shrink-0">用户名</span>
<span class="w-32 shrink-0">IP 地址</span>
<span class="w-20 shrink-0">浏览器</span>
<span class="w-16 shrink-0 text-center">状态</span>
<span class="flex-1">消息</span>
<span class="flex-1">User Agent</span>
<span class="w-40 shrink-0 text-right">时间</span>
</div>
<!-- 列表 -->
@@ -115,13 +105,12 @@ onMounted(loadLogs)
>
<span class="w-24 shrink-0 font-medium text-sm truncate">{{ log.username }}</span>
<code class="w-32 shrink-0 text-xs text-muted-foreground bg-muted px-2 py-1 rounded">{{ log.ip }}</code>
<span class="w-20 shrink-0 text-xs text-muted-foreground">{{ getBrowserInfo(log.user_agent) }}</span>
<span class="w-16 shrink-0 flex justify-center">
<Badge :variant="log.status === 'success' ? 'default' : 'destructive'" class="text-xs">
{{ log.status === 'success' ? '成功' : '失败' }}
</Badge>
</span>
<span class="flex-1 text-sm text-muted-foreground truncate">{{ log.message }}</span>
<span class="flex-1 text-xs text-muted-foreground truncate" :title="log.user_agent">{{ log.user_agent || '-' }}</span>
<span class="w-40 shrink-0 text-right text-xs text-muted-foreground">{{ log.created_at }}</span>
</div>
</div>
+2 -2
View File
@@ -139,7 +139,7 @@ onMounted(loadTasks)
<span class="w-12 shrink-0">ID</span>
<span class="w-40 shrink-0">名称</span>
<span class="flex-1">命令</span>
<span class="w-28 shrink-0">定时规则</span>
<span class="w-32 shrink-0">定时规则</span>
<span class="w-40 shrink-0">上次执行</span>
<span class="w-40 shrink-0">下次执行</span>
<span class="w-12 shrink-0 text-center">状态</span>
@@ -158,7 +158,7 @@ onMounted(loadTasks)
<span class="w-12 shrink-0 text-muted-foreground text-sm">#{{ task.id }}</span>
<span class="w-40 font-medium truncate shrink-0 text-sm">{{ task.name }}</span>
<code class="flex-1 text-muted-foreground truncate text-xs bg-muted px-2 py-1 rounded">{{ task.command }}</code>
<code class="w-28 shrink-0 text-muted-foreground text-xs bg-muted px-2 py-1 rounded">{{ task.schedule }}</code>
<code class="w-36 shrink-0 text-muted-foreground text-xs bg-muted px-2 py-1 rounded">{{ task.schedule }}</code>
<span class="w-40 shrink-0 text-muted-foreground text-xs">{{ task.last_run || '-' }}</span>
<span class="w-40 shrink-0 text-muted-foreground text-xs">{{ task.next_run || '-' }}</span>
<span class="w-12 flex justify-center shrink-0 cursor-pointer" @click="toggleTask(task, !task.enabled)" :title="task.enabled ? '点击禁用' : '点击启用'">