-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHowToDesign
365 lines (304 loc) · 7.75 KB
/
HowToDesign
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
下载当前内容
git clone git@github.com:URRealHero/SoftwareEngineering.git
如果不会用git,就直接把改完的内容发我,告诉我改了哪些
开始设计任意界面需要给gpt下面的内容
There are three main files about my go cloud project, I will ask you to design each .vue file mentioned in the router/index.ts step by step,
I'll give you what the current .vue file is in next step, and ask you to modify or add new features to current page.
//src/App.vue
<!-- src/App.vue -->
<template>
<div :class="['main-container', isDarkMode ? 'dark' : 'light']">
<NavBar :isDarkMode="isDarkMode" @toggle-theme="toggleTheme" />
<div class="content">
<router-view :isDarkMode="isDarkMode" />
</div>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import NavBar from './components/NavBar.vue'
const isDarkMode = ref(false)
const toggleTheme = () => {
isDarkMode.value = !isDarkMode.value
}
</script>
<style scoped>
.main-container {
display: flex;
height: 100vh;
width: 100vw;
overflow: hidden;
}
.main-container.dark {
background-color: #1e1e1e;
color: #ffffff;
}
.main-container.light {
background-color: #f0f2f5;
color: #000000;
}
.content {
flex-grow: 1;
padding: 20px;
}
</style>
//src/main.js
// src/main.js
import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import './assets/styles.css'
createApp(App).use(router).mount('#app')
// src/router/index.js
import { createRouter, createWebHistory } from 'vue-router'
import Home from '../views/Home.vue'
import MyDrive from '../views/MyDrive.vue'
import Upload from '../views/Upload.vue'
import Categories from '../views/Categories/Categories.vue'
import Docs from '../views/Categories/Docs.vue'
import Images from '../views/Categories/Images.vue'
import Videos from '../views/Categories/Videos.vue'
import Audios from '../views/Categories/Audios.vue'
import Others from '../views/Categories/Others.vue'
import Settings from '../views/Settings.vue' // Import Settings.vue
const routes = [
{ path: '/', name: 'Home', component: Home },
{ path: '/my-drive', name: 'MyDrive', component: MyDrive },
{ path: '/upload', name: 'Upload', component: Upload },
{
path: '/categories',
name: 'Categories',
component: Categories,
children: [
{ path: 'docs', name: 'Docs', component: Docs },
{ path: 'images', name: 'Images', component: Images },
{ path: 'videos', name: 'Videos', component: Videos },
{ path: 'audios', name: 'Audios', component: Audios },
{ path: 'others', name: 'Others', component: Others },
],
},
{ path: '/settings', name: 'Settings', component: Settings }, // Add Settings route
]
const router = createRouter({
history: createWebHistory(),
routes,
})
export default router
//src/components/NavBar.vue
<!-- src/components/NavBar.vue -->
<template>
<div
class="sidebar"
:class="{ collapsed: isSidebarCollapsed }"
@mouseenter="expandSidebar"
@mouseleave="collapseSidebar"
>
<!-- Theme Toggle Button at the Top Right -->
<div class="theme-toggle" @click="toggleTheme">
<i class="icon">{{ isDarkMode ? '🌞' : '🌙' }}</i>
</div>
<!-- Logo -->
<div class="logo">
<img :src="logo" alt="Logo" class="logo-image" />
</div>
<!-- User Info (clickable, navigates to settings) -->
<div class="user-info" @click="navigateTo('/settings')">
<div class="avatar-wrapper">
<img :src="avatar" alt="User Avatar" class="avatar" />
</div>
<span class="username" v-if="!isSidebarCollapsed">John Doe</span>
</div>
<!-- Navigation Menu -->
<ul class="nav-menu">
<li :class="{ active: isActive('/') }" @click="navigateTo('/')">
<i class="icon">🏠</i>
<span v-if="!isSidebarCollapsed">主页</span>
</li>
<li
:class="{ active: isActive('/my-drive') }"
@click="navigateTo('/my-drive')"
>
<i class="icon">💼</i>
<span v-if="!isSidebarCollapsed">我的网盘</span>
</li>
<li
:class="{ active: isActive('/upload') }"
@click="navigateTo('/upload')"
>
<i class="icon">⬆️</i>
<span v-if="!isSidebarCollapsed">上传</span>
</li>
<li
:class="{ active: isActive('/categories') }"
@click="navigateTo('/categories')"
>
<i class="icon">📂</i>
<span v-if="!isSidebarCollapsed">分类</span>
</li>
</ul>
<!-- Log Out Button at the Bottom -->
<div class="logout-button" @click="logout">
<i class="icon">🚪</i>
<span v-if="!isSidebarCollapsed">退出</span>
</div>
</div>
</template>
<script setup lang="ts">
import { ref, defineProps, defineEmits } from 'vue'
import { useRouter, useRoute } from 'vue-router'
import logo from '@/assets/gocloud.svg'
import avatar from '@/assets/gocloud.png'
const props = defineProps({
isDarkMode: {
type: Boolean,
required: true,
},
})
const emit = defineEmits(['toggle-theme'])
const isSidebarCollapsed = ref(true)
const expandSidebar = () => {
isSidebarCollapsed.value = false
}
const collapseSidebar = () => {
isSidebarCollapsed.value = true
}
const router = useRouter()
const route = useRoute()
const navigateTo = (path: string) => {
router.push(path)
}
const isActive = (path: string) => {
return route.path === path || route.path.startsWith(path + '/')
}
// Emit toggle theme event
const toggleTheme = () => {
emit('toggle-theme')
}
// Log out function
const logout = () => {
// Implement your logout logic here
// For example, clear user data and redirect to login page
console.log('Logging out...')
router.push('/login')
}
</script>
<style scoped>
/* Sidebar styles */
.sidebar {
position: relative;
background-color: #3a3f51;
color: #ffffff;
display: flex;
flex-direction: column;
align-items: center;
padding: 20px;
width: 200px; /* Fixed width */
transition: width 0.3s;
overflow: hidden;
}
.sidebar.collapsed {
width: 60px; /* Adjusted collapsed width */
}
/* Theme Toggle Button at the Top Right */
.theme-toggle {
position: absolute;
top: 10px;
right: 10px;
cursor: pointer;
}
.theme-toggle .icon {
font-size: 1.5em;
}
/* Logo styles */
.logo {
margin-bottom: 20px;
}
.logo-image {
width: 80px; /* Increased width */
height: auto;
}
.sidebar.collapsed .logo-image {
width: 60px; /* Adjusted collapsed width */
}
/* User Info styles */
.user-info {
display: flex;
flex-direction: column;
align-items: center;
margin-bottom: 30px;
cursor: pointer;
}
.user-info:hover {
opacity: 0.8;
}
.avatar-wrapper {
width: 50px;
height: 50px;
border-radius: 50%;
border: 2px solid #ffffff;
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 10px;
}
.sidebar.collapsed .avatar-wrapper {
width: 30px;
height: 30px;
}
.avatar {
width: 100%;
height: 100%;
border-radius: 50%;
}
.username {
font-size: 1em;
font-weight: bold;
}
.sidebar.collapsed .username {
display: none;
}
/* Navigation Menu styles */
.nav-menu {
list-style: none;
padding: 0;
width: 100%;
}
.nav-menu li {
display: flex;
align-items: center;
padding: 15px;
cursor: pointer;
transition: background-color 0.3s;
}
.nav-menu li.active {
background-color: #555a71;
}
.nav-menu li:hover {
background-color: #555a71;
}
.nav-menu li .icon {
margin-right: 10px;
}
.sidebar.collapsed .nav-menu li span {
display: none;
}
/* Log Out Button at the Bottom */
.logout-button {
margin-top: auto;
width: 100%;
display: flex;
align-items: center;
padding: 15px;
cursor: pointer;
transition: background-color 0.3s;
}
.logout-button:hover {
background-color: #555a71;
}
.logout-button .icon {
margin-right: 10px;
}
.sidebar.collapsed .logout-button span {
display: none;
}
</style>