Skip to content

Commit 124986b

Browse files
authored
Merge pull request #88 from OrzMiku/main
feat: 移动端适配
2 parents 734938b + e3b110a commit 124986b

File tree

14 files changed

+372
-153
lines changed

14 files changed

+372
-153
lines changed

web/package-lock.json

Lines changed: 45 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/package.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,14 @@
44
"version": "0.1.0",
55
"description": "GPT Load Balancer Frontend - A modern Vue 3 frontend for GPT load balancing service",
66
"type": "module",
7-
"keywords": ["vue3", "typescript", "vite", "naive-ui", "gpt-load", "frontend"],
7+
"keywords": [
8+
"vue3",
9+
"typescript",
10+
"vite",
11+
"naive-ui",
12+
"gpt-load",
13+
"frontend"
14+
],
815
"author": "tbphp",
916
"license": "MIT",
1017
"repository": {
@@ -32,6 +39,7 @@
3239
},
3340
"dependencies": {
3441
"@vicons/ionicons5": "^0.13.0",
42+
"@vueuse/core": "^13.6.0",
3543
"axios": "^1.9.0",
3644
"naive-ui": "^2.41.0",
3745
"vue": "^3.5.13",

web/src/components/AppFooter.vue

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ onMounted(() => {
218218
border-top: 1px solid rgba(0, 0, 0, 0.08);
219219
padding: 12px 24px;
220220
font-size: 14px;
221-
height: 52px;
221+
min-height: 52px;
222222
}
223223
224224
.footer-container {
@@ -231,7 +231,6 @@ onMounted(() => {
231231
align-items: center;
232232
justify-content: center;
233233
gap: 16px;
234-
flex-wrap: wrap;
235234
line-height: 1.4;
236235
}
237236
@@ -269,6 +268,7 @@ onMounted(() => {
269268
font-weight: 500;
270269
font-size: 13px;
271270
color: #666;
271+
white-space: nowrap;
272272
}
273273
274274
.version-clickable {
@@ -301,6 +301,7 @@ onMounted(() => {
301301
border-radius: 4px;
302302
transition: all 0.2s ease;
303303
font-size: 13px;
304+
white-space: nowrap;
304305
}
305306
306307
.footer-link:hover {
@@ -345,6 +346,7 @@ onMounted(() => {
345346
@media (max-width: 768px) {
346347
.app-footer {
347348
padding: 10px 16px;
349+
height: auto;
348350
}
349351
350352
.footer-main {
@@ -353,7 +355,7 @@ onMounted(() => {
353355
text-align: center;
354356
}
355357
356-
.divider {
358+
.footer-main :deep(.n-divider) {
357359
display: none;
358360
}
359361

web/src/components/BaseInfoCard.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ onMounted(() => {
5959
<template>
6060
<div class="stats-container">
6161
<n-space vertical size="medium">
62-
<n-grid :cols="4" :x-gap="20" :y-gap="20" responsive="screen">
62+
<n-grid cols="2 s:4" :x-gap="20" :y-gap="20" responsive="screen">
6363
<!-- 密钥数量 -->
6464
<n-grid-item span="1">
6565
<n-card :bordered="false" class="stat-card" style="animation-delay: 0s">
@@ -217,13 +217,13 @@ onMounted(() => {
217217
}
218218
219219
.stat-icon {
220-
width: 48px;
221-
height: 48px;
220+
width: 40px;
221+
height: 40px;
222222
border-radius: var(--border-radius-md);
223223
display: flex;
224224
align-items: center;
225225
justify-content: center;
226-
font-size: 1.5rem;
226+
font-size: 1.4rem;
227227
color: white;
228228
box-shadow: var(--shadow-md);
229229
}
@@ -262,7 +262,7 @@ onMounted(() => {
262262
}
263263
264264
.stat-value {
265-
font-size: 2.5rem;
265+
font-size: 2rem;
266266
font-weight: 700;
267267
line-height: 1.2;
268268
color: #1e293b;

web/src/components/GlobalTaskProgressBar.vue

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,14 +170,23 @@ function getTaskTitle(): string {
170170
bottom: 62px;
171171
right: 10px;
172172
z-index: 9999;
173-
width: 350px;
173+
width: 95%;
174+
max-width: 350px;
174175
background: white;
175176
border-radius: var(--border-radius-md);
176177
box-shadow: var(--shadow-lg);
177178
border: 1px solid rgba(0, 0, 0, 0.08);
178179
animation: slideIn 0.3s ease-out;
179180
}
180181
182+
@media (max-width: 768px) {
183+
.global-task-progress {
184+
bottom: 72px;
185+
left: 50%;
186+
transform: translateX(-50%);
187+
}
188+
}
189+
181190
@keyframes slideIn {
182191
from {
183192
transform: translateX(100%);

web/src/components/Layout.vue

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,21 @@ import AppFooter from "@/components/AppFooter.vue";
33
import GlobalTaskProgressBar from "@/components/GlobalTaskProgressBar.vue";
44
import Logout from "@/components/Logout.vue";
55
import NavBar from "@/components/NavBar.vue";
6+
import { useMediaQuery } from "@vueuse/core";
7+
import { ref, watch } from "vue";
8+
9+
const isMenuOpen = ref(false);
10+
const isMobile = useMediaQuery("(max-width: 768px)");
11+
12+
watch(isMobile, value => {
13+
if (!value) {
14+
isMenuOpen.value = false;
15+
}
16+
});
17+
18+
const toggleMenu = () => {
19+
isMenuOpen.value = !isMenuOpen.value;
20+
};
621
</script>
722

823
<template>
@@ -13,17 +28,33 @@ import NavBar from "@/components/NavBar.vue";
1328
<div class="brand-icon">
1429
<img src="@/assets/logo.png" alt="" />
1530
</div>
16-
<h1 class="brand-title">GPT Load</h1>
31+
<h1 v-if="!isMobile" class="brand-title">GPT Load</h1>
1732
</div>
1833

19-
<nav-bar class="header-nav" />
34+
<nav v-if="!isMobile" class="header-nav">
35+
<nav-bar />
36+
</nav>
2037

2138
<div class="header-actions">
22-
<logout />
39+
<logout v-if="!isMobile" />
40+
<n-button v-else text @click="toggleMenu">
41+
<svg viewBox="0 0 24 24" width="24" height="24">
42+
<path fill="currentColor" d="M3,6H21V8H3V6M3,11H21V13H3V11M3,16H21V18H3V16Z" />
43+
</svg>
44+
</n-button>
2345
</div>
2446
</div>
2547
</n-layout-header>
2648

49+
<n-drawer v-model:show="isMenuOpen" :width="240" placement="right">
50+
<n-drawer-content title="GPT Load" body-content-style="padding: 0;">
51+
<nav-bar mode="vertical" @close="isMenuOpen = false" />
52+
<div class="mobile-actions">
53+
<logout />
54+
</div>
55+
</n-drawer-content>
56+
</n-drawer>
57+
2758
<n-layout-content class="layout-content">
2859
<div class="content-wrapper">
2960
<router-view v-slot="{ Component }">
@@ -56,14 +87,14 @@ import NavBar from "@/components/NavBar.vue";
5687
position: sticky;
5788
top: 0;
5889
z-index: 100;
59-
padding: 0 24px;
90+
padding: 0 12px;
6091
}
6192
6293
.header-content {
6394
display: flex;
6495
align-items: center;
6596
justify-content: space-between;
66-
padding: 8px;
97+
padding: 8px 0;
6798
overflow-x: auto;
6899
max-width: 1200px;
69100
margin: 0 auto;
@@ -101,6 +132,13 @@ import NavBar from "@/components/NavBar.vue";
101132
102133
.header-actions {
103134
flex-shrink: 0;
135+
display: flex;
136+
align-items: center;
137+
}
138+
139+
.mobile-actions {
140+
padding: 12px;
141+
border-top: 1px solid rgba(0, 0, 0, 0.08);
104142
}
105143
106144
.layout-content {
@@ -113,7 +151,7 @@ import NavBar from "@/components/NavBar.vue";
113151
}
114152
115153
.content-wrapper {
116-
padding: 24px 12px;
154+
padding: 16px;
117155
min-height: calc(100vh - 111px);
118156
}
119157

web/src/components/LineChart.vue

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -792,9 +792,34 @@ onMounted(() => {
792792
align-items: flex-start;
793793
}
794794
795+
.chart-wrapper {
796+
flex-direction: column;
797+
align-items: center;
798+
}
799+
795800
.chart-legend {
801+
position: relative;
802+
transform: none;
803+
left: auto;
804+
top: auto;
805+
margin-top: 8px;
806+
margin-bottom: 12px;
807+
background: transparent;
808+
backdrop-filter: none;
809+
border: none;
810+
width: 100%;
796811
flex-wrap: wrap;
797-
gap: 16px;
812+
gap: 8px;
813+
justify-content: center;
814+
}
815+
816+
.legend-item {
817+
padding: 4px 10px;
818+
font-size: 12px;
819+
color: #333;
820+
background: white;
821+
border: 1px solid rgba(0, 0, 0, 0.1);
822+
gap: 6px;
798823
}
799824
800825
.chart-svg {

0 commit comments

Comments
 (0)