Skip to content

Commit fca7201

Browse files
committed
fix: 优化日志样式
1 parent 3625353 commit fca7201

File tree

3 files changed

+122
-135
lines changed

3 files changed

+122
-135
lines changed

resources/logger/index.css

Lines changed: 115 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -1,215 +1,200 @@
1+
:root {
2+
--bg-color: #1e1e1e;
3+
--container-bg: #252526;
4+
--text-color: #d4d4d4;
5+
--border-color: #3e3e42;
6+
--header-bg: #333333;
7+
--accent-color: #007acc;
8+
9+
--level-debug: #b5cea8;
10+
--level-info: #569cd6;
11+
--level-mark: #c586c0;
12+
--level-warn: #ce9178;
13+
--level-error: #f44747;
14+
--level-fatal: #d16969;
15+
}
16+
117
* {
218
margin: 0;
319
padding: 0;
420
box-sizing: border-box;
521
}
622

723
body {
8-
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif, 'Microsoft YaHei';
9-
background: linear-gradient(135deg, #c7d2fe 0%, #fbcfe8 50%, #a5f3fc 100%);
10-
padding: 20px;
11-
min-height: 100vh;
24+
font-family: 'Fira Code', 'Consolas', 'Monaco', 'Courier New', monospace;
25+
background-color: var(--bg-color);
26+
color: var(--text-color);
27+
padding: 0;
28+
margin: 0;
29+
font-size: 14px;
30+
line-height: 1.5;
1231
}
1332

1433
.container {
15-
max-width: 1400px;
16-
margin: 0 auto;
17-
background: rgba(255, 255, 255, 0.96);
18-
border-radius: 18px;
19-
box-shadow: 0 18px 45px rgba(148, 163, 184, 0.45);
20-
overflow: hidden;
21-
width: fit-content;
34+
max-width: 100%;
35+
margin: 0;
36+
background: var(--bg-color);
37+
display: flex;
38+
flex-direction: column;
2239
}
2340

2441
.header {
25-
position: relative;
26-
padding: 30px;
27-
color: #0f172a;
28-
overflow: hidden;
29-
background: url('../img/logger.png') center/cover no-repeat, #e0f2ff;
30-
border-bottom: 1px solid rgba(148, 163, 184, 0.35);
31-
}
32-
33-
.header h1,
34-
.header .info {
35-
position: relative;
36-
z-index: 2;
37-
}
38-
39-
.header-bg-text {
40-
position: absolute;
41-
inset: 0;
42+
background: var(--header-bg);
43+
padding: 10px 20px;
44+
border-bottom: 1px solid var(--border-color);
4245
display: flex;
46+
justify-content: space-between;
4347
align-items: center;
44-
justify-content: center;
45-
font-size: 92px;
46-
font-weight: 800;
47-
letter-spacing: 0.12em;
48-
text-transform: uppercase;
49-
color: rgba(30, 64, 175, 0.2);
50-
filter: blur(2px);
51-
pointer-events: none;
52-
z-index: 1;
48+
position: sticky;
49+
top: 0;
50+
z-index: 100;
51+
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
5352
}
5453

5554
.header h1 {
56-
font-size: 32px;
57-
margin-bottom: 15px;
55+
font-size: 16px;
5856
font-weight: 600;
59-
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
57+
color: #fff;
58+
margin: 0;
59+
display: flex;
60+
align-items: center;
61+
gap: 10px;
62+
}
63+
64+
.header h1::before {
65+
content: '>';
66+
color: var(--accent-color);
67+
font-weight: bold;
6068
}
6169

6270
.info {
6371
display: flex;
64-
gap: 20px;
65-
font-size: 14px;
66-
opacity: 0.95;
72+
gap: 15px;
73+
font-size: 12px;
74+
color: #cccccc;
6775
}
6876

6977
.info span {
70-
background: rgba(255, 255, 255, 0.2);
71-
padding: 6px 12px;
72-
border-radius: 6px;
73-
backdrop-filter: blur(10px);
78+
background: rgba(255, 255, 255, 0.1);
79+
padding: 2px 8px;
80+
border-radius: 3px;
81+
}
82+
83+
.header-bg-text {
84+
display: none;
7485
}
7586

7687
.logs-container {
77-
padding: 20px;
78-
/* 让截图包含全部日志,不使用内部滚动条 */
79-
overflow: visible;
88+
padding: 10px 0;
8089
}
8190

8291
.log-item {
83-
display: flex;
84-
align-items: flex-start;
85-
padding: 12px 16px;
86-
margin-bottom: 8px;
87-
border-radius: 8px;
88-
background: #f9fafb;
89-
border-left: 4px solid #e5e7eb;
90-
transition: all 0.2s ease;
92+
padding: 2px 10px;
93+
border-left: 3px solid transparent;
94+
transition: background-color 0.1s;
9195
font-size: 13px;
9296
line-height: 1.6;
9397
}
9498

9599
.log-item:hover {
96-
transform: translateX(4px);
97-
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
100+
background-color: #2a2d2e;
101+
}
102+
103+
.log-content {
104+
display: block;
105+
}
106+
107+
.log-prefix {
108+
color: #858585;
109+
font-size: 12px;
110+
white-space: nowrap;
111+
opacity: 0.9;
112+
margin-right: 8px;
98113
}
99114

100115
.log-time {
101-
color: #6c757d;
102-
font-family: 'Consolas', 'Monaco', monospace;
103-
min-width: 100px;
104-
margin-right: 12px;
105-
font-weight: 500;
116+
color: #858585;
106117
}
107118

108119
.log-level {
109-
display: inline-block;
110-
padding: 2px 10px;
111-
border-radius: 4px;
112-
font-weight: 600;
120+
font-weight: bold;
113121
text-transform: uppercase;
114-
font-size: 11px;
115-
min-width: 60px;
116-
text-align: center;
117-
margin-right: 12px;
122+
font-size: 12px;
118123
}
119124

120125
.level-debug {
121-
background: #9ca3af;
122-
color: white;
126+
color: var(--level-debug);
123127
}
124128

125129
.level-info {
126-
background: #38bdf8;
127-
color: white;
130+
color: var(--level-info);
128131
}
129132

130133
.level-mark {
131-
background: #a855f7;
132-
color: white;
134+
color: var(--level-mark);
133135
}
134136

135137
.level-warn {
136-
background: #facc15;
137-
color: #422006;
138+
color: var(--level-warn);
138139
}
139140

140141
.level-error {
141-
background: #ef4444;
142-
color: white;
142+
color: var(--level-error);
143143
}
144144

145145
.level-fatal {
146-
background: #000;
147-
color: white;
146+
color: var(--level-fatal);
147+
background: #5a1d1d;
148+
padding: 0 4px;
149+
border-radius: 2px;
148150
}
149151

150152
.log-message {
151-
flex: 1;
152-
word-break: break-all;
153-
color: #212529;
154-
font-family: 'Consolas', 'Monaco', monospace;
155153
white-space: pre-wrap;
154+
word-break: break-word;
155+
color: #cccccc;
156156
}
157157

158-
/* 不同日志级别的边框颜色 */
159-
.log-debug {
160-
border-left-color: #d1d5db;
161-
background: #f9fafb;
162-
}
163-
164-
.log-info {
165-
border-left-color: #93c5fd;
166-
background: #e0f2fe;
167-
}
168-
169-
.log-mark {
170-
border-left-color: #c4b5fd;
171-
background: #f3e8ff;
172-
}
173-
174-
.log-warn {
175-
border-left-color: #fcd34d;
176-
background: #fef3c7;
158+
/* Log item border indicators */
159+
.log-item.log-error {
160+
border-left-color: var(--level-error);
161+
background: rgba(244, 71, 71, 0.05);
177162
}
178163

179-
.log-error {
180-
border-left-color: #fca5a5;
181-
background: #fee2e2;
164+
.log-item.log-warn {
165+
border-left-color: var(--level-warn);
166+
background: rgba(206, 145, 120, 0.05);
182167
}
183168

184-
.log-fatal {
185-
border-left-color: #9ca3af;
186-
background: #f5f5f5;
169+
.log-item.log-fatal {
170+
border-left-color: var(--level-fatal);
171+
background: rgba(209, 105, 105, 0.1);
187172
}
188173

189174
.footer {
190-
background: #f8f9fa;
191-
padding: 15px 30px;
175+
padding: 5px 20px;
192176
text-align: center;
193-
color: #6c757d;
194-
font-size: 12px;
195-
border-top: 1px solid #dee2e6;
177+
color: #666;
178+
font-size: 11px;
179+
border-top: 1px solid var(--border-color);
180+
background: var(--container-bg);
196181
}
197182

198-
/* 滚动条样式 */
199-
.logs-container::-webkit-scrollbar {
200-
width: 8px;
183+
/* Scrollbar */
184+
::-webkit-scrollbar {
185+
width: 10px;
186+
height: 10px;
201187
}
202188

203-
.logs-container::-webkit-scrollbar-track {
204-
background: #f1f1f1;
205-
border-radius: 4px;
189+
::-webkit-scrollbar-track {
190+
background: var(--bg-color);
206191
}
207192

208-
.logs-container::-webkit-scrollbar-thumb {
209-
background: #888;
210-
border-radius: 4px;
193+
::-webkit-scrollbar-thumb {
194+
background: #424242;
195+
border-radius: 5px;
211196
}
212197

213-
.logs-container::-webkit-scrollbar-thumb:hover {
214-
background: #555;
198+
::-webkit-scrollbar-thumb:hover {
199+
background: #4f4f4f;
215200
}

resources/logger/index.html

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<body>
1212
<div class="container">
1313
<div class="header">
14-
<h1>📋 Karin 日志</h1>
14+
<h1>Karin 日志</h1>
1515
<div class="info">
1616
<span class="date">{{date}}</span>
1717
<span class="count">共 {{total}} 条日志</span>
@@ -21,9 +21,11 @@ <h1>📋 Karin 日志</h1>
2121
<div class="logs-container">
2222
{{each logs}}
2323
<div class="log-item log-{{$value.level}}">
24-
<span class="log-time">{{$value.time}}</span>
25-
<span class="log-level level-{{$value.level}}">{{$value.level}}</span>
26-
<span class="log-message">{{@ $value.messageHtml}}</span>
24+
<div class="log-content">
25+
<span class="log-prefix">[<span class="log-time">{{$value.time}}</span>][<span
26+
class="log-level level-{{$value.level}}">{{$value.level}}</span>]</span>
27+
<span class="log-message">{{@ $value.messageHtml}}</span>
28+
</div>
2729
</div>
2830
{{/each}}
2931
</div>

src/apps/logger.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ export const logViewer = karin.command(/^#日志\s*(\d+)?$/, async (e) => {
264264
const match = e.msg.match(/^#\s*(\d+)?$/)
265265
let limit = match && match[1] ? Number(match[1]) : 50
266266
if (!Number.isFinite(limit) || limit <= 0) limit = 50
267-
if (limit > 200) limit = 200
267+
if (limit > 1000) limit = 1000
268268

269269
const logs = await getTodayLogs(limit)
270270
const parsedLogs = logs.map(parseLogLine)

0 commit comments

Comments
 (0)