Skip to content

Commit 7befab6

Browse files
authored
Merge pull request #28 from hingq/codex/migrate-layout-components-to-tailwind
重构:将布局与主界面迁移为 Tailwind 原子类
2 parents 279b5ec + 3e46357 commit 7befab6

17 files changed

Lines changed: 196 additions & 693 deletions

File tree

src/components/Asdie.vue

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
<template>
2-
<el-menu default-active="2" :collapse="isCollapse" background-color="var(--vt-c-blue)" :router="true" :mode=mode>
3-
<el-menu-item index="/layout">
2+
<el-menu
3+
default-active="2"
4+
:collapse="isCollapse"
5+
:router="true"
6+
:mode="mode"
7+
class="h-full border-r-0 bg-sky-700 text-slate-100 dark:bg-slate-900 dark:text-slate-100"
8+
>
9+
<el-menu-item index="/layout" class="!text-inherit">
410
<el-icon>
511
<UserFilled />
612
</el-icon>
@@ -75,8 +81,4 @@ const mode = computed(() => collapseStore.rowOrCol)
7581
.el-menu-item {
7682
--el-menu-hover-bg-color: #275880;
7783
}
78-
79-
.el-menu {
80-
border-right: 0;
81-
}
8284
</style>

src/components/Header.vue

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import { useCollaspeStore, useTheme } from '@/stores';
55
import { ref } from 'vue';
66
import { useRouter } from 'vue-router';
7-
const router=useRouter()
7+
const router = useRouter()
88
const span_collapse = ref('')
99
const theme=useTheme()
1010
const collapseStore = useCollaspeStore()
@@ -16,11 +16,10 @@ const collapse = () => {
1616
collapseStore.change() //展开与折叠
1717
}
1818
}
19-
//改变mode
2019
const changeMode = async () => {
21-
props.el_con.$el.classList.add("an") //添加样式
20+
props.el_con.$el.classList.add('an')
2221
setTimeout(() => {
23-
props.el_con.$el.classList.remove("an")
22+
props.el_con.$el.classList.remove('an')
2423
}, 1000)
2524
props.el_con.$el.style.flexDirection = props.el_con.$el.style.flexDirection === `column` ? `row` : `column`
2625
@@ -31,8 +30,8 @@ const changeMode = async () => {
3130
span.style.cursor=` not-allowed`
3231
flag=false
3332
} else {
34-
span.style.cursor='pointer'
35-
flag=true
33+
span.style.cursor = 'pointer'
34+
flag = true
3635
3736
}
3837
}
@@ -41,22 +40,21 @@ const props = defineProps({
4140
default: null
4241
}
4342
})
44-
const toUrl=(url)=>{
43+
const toUrl = (url) => {
4544
router.push(url)
4645
}
47-
// change the theme
48-
const toggle=()=>{
46+
const toggle = () => {
4947
theme.setTheme()
5048
}
5149
</script>
5250
<template>
53-
<div class="header">
54-
<span @click="collapse" class="icon" ref="span_collapse">
51+
<div class="flex flex-wrap items-center gap-2 border-b border-sky-200 bg-white px-3 py-2 text-slate-700 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-100">
52+
<span @click="collapse" class="relative bottom-[-2px] mr-1 inline-flex w-9 cursor-pointer items-center justify-center rounded-md p-1 transition hover:bg-slate-100 dark:hover:bg-slate-800" ref="span_collapse">
5553
<el-icon :size="25">
5654
<i-ep-Operation />
5755
</el-icon>
5856
</span>
59-
<span @click="changeMode" class="icon" >
57+
<span @click="changeMode" class="relative bottom-[-2px] mr-2 inline-flex w-9 cursor-pointer items-center justify-center rounded-md p-1 transition hover:bg-slate-100 dark:hover:bg-slate-800">
6058
<el-icon :size="25">
6159
<i-ep-Expand />
6260
</el-icon>

src/styles/twClasses.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export const shellCardClass =
2+
'rounded-xl border border-slate-200 bg-white text-slate-700 shadow-sm dark:border-slate-700 dark:bg-slate-900 dark:text-slate-100'
3+
4+
export const sectionHeaderClass =
5+
'flex h-14 items-center justify-between border-b border-slate-200 px-4 text-base font-medium text-slate-700 dark:border-slate-700 dark:text-slate-100'
6+
7+
export const tableSectionClass =
8+
'rounded-xl border border-slate-200 bg-white dark:border-slate-700 dark:bg-slate-900'
9+
10+
export const mutedTextClass = 'text-slate-500 dark:text-slate-400'

src/views/AboutView.vue

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,6 @@
11
<template>
2-
<div class="about">
3-
<h1>This is an about page</h1>
2+
<div class="about flex min-h-screen items-center rounded-xl border border-slate-200 bg-white p-6 text-slate-700 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-100">
3+
<h1 class="text-2xl font-semibold">This is an about page</h1>
44
</div>
5-
<Button></Button>
6-
5+
<Button></Button>
76
</template>
8-
9-
<style>
10-
@media (min-width: 1024px) {
11-
.about {
12-
min-height: 100vh;
13-
display: flex;
14-
align-items: center;
15-
}
16-
}
17-
</style>

src/views/HomeView.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import TheWelcome from '../components/TheWelcome.vue'
33
</script>
44

55
<template>
6-
<main>
7-
<el-button>111</el-button>
8-
<TheWelcome />
6+
<main class="space-y-3 rounded-xl border border-slate-200 bg-white p-4 text-slate-700 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-100">
7+
<el-button>111</el-button>
8+
<TheWelcome />
99
</main>
1010
</template>

src/views/Landing.vue

Lines changed: 11 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -32,129 +32,22 @@ const goToAbout = () => {
3232
</script>
3333

3434
<template>
35-
<main class="landing-page">
36-
<section class="hero">
37-
<h1 class="title">算法演示/学习平台</h1>
38-
<p class="subtitle">聚焦算法理解与交互实践,帮助你高效掌握核心数据结构与算法思维。</p>
35+
<main class="flex min-h-[calc(100vh-2rem)] flex-col justify-center gap-8 rounded-2xl border border-slate-200 bg-slate-50 px-4 py-8 text-slate-700 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-100 max-md:min-h-auto max-md:justify-start max-md:gap-6 max-md:px-3 max-md:py-6">
36+
<section class="text-center">
37+
<h1 class="text-3xl font-bold text-slate-800 dark:text-slate-100">算法演示/学习平台</h1>
38+
<p class="mt-3 text-slate-500 dark:text-slate-400">聚焦算法理解与交互实践,帮助你高效掌握核心数据结构与算法思维。</p>
3939
</section>
4040

41-
<section class="feature-grid">
42-
<article v-for="feature in coreFeatures" :key="feature.title" class="feature-card">
43-
<h2>{{ feature.title }}</h2>
44-
<p>{{ feature.description }}</p>
41+
<section class="grid grid-cols-[repeat(auto-fit,minmax(210px,1fr))] gap-4 max-md:grid-cols-1">
42+
<article v-for="feature in coreFeatures" :key="feature.title" class="rounded-xl border border-slate-200 bg-white p-5 shadow-sm dark:border-slate-700 dark:bg-slate-950">
43+
<h2 class="text-lg font-semibold text-slate-800 dark:text-slate-100">{{ feature.title }}</h2>
44+
<p class="mt-2 text-sm text-slate-500 dark:text-slate-400">{{ feature.description }}</p>
4545
</article>
4646
</section>
4747

48-
<section class="actions">
49-
<button class="btn btn-primary" @click="goToAlgorithmDemo">进入算法演示</button>
50-
<button class="btn btn-secondary" @click="goToAbout">查看介绍 / 关于</button>
48+
<section class="flex flex-wrap justify-center gap-3 max-md:flex-col max-md:items-stretch">
49+
<button class="cursor-pointer rounded-full bg-sky-700 px-5 py-2 text-sm text-white transition hover:opacity-90 max-md:w-full" @click="goToAlgorithmDemo">进入算法演示</button>
50+
<button class="cursor-pointer rounded-full border border-slate-300 bg-white px-5 py-2 text-sm text-slate-700 transition hover:opacity-90 dark:border-slate-600 dark:bg-slate-900 dark:text-slate-100 max-md:w-full" @click="goToAbout">查看介绍 / 关于</button>
5151
</section>
5252
</main>
5353
</template>
54-
55-
<style scoped>
56-
.landing-page {
57-
min-height: calc(100vh - 2rem);
58-
padding: 2rem 1rem;
59-
background: var(--color-background-soft);
60-
border-radius: 16px;
61-
display: flex;
62-
flex-direction: column;
63-
justify-content: center;
64-
gap: 2rem;
65-
}
66-
67-
.hero {
68-
text-align: center;
69-
}
70-
71-
.title {
72-
color: var(--color-heading);
73-
font-size: clamp(1.75rem, 2.6vw, 2.3rem);
74-
font-weight: 700;
75-
}
76-
77-
.subtitle {
78-
margin-top: 0.75rem;
79-
color: var(--vt-c-text-light-2);
80-
}
81-
82-
.feature-grid {
83-
display: grid;
84-
grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
85-
gap: 1rem;
86-
}
87-
88-
.feature-card {
89-
background: var(--color-background);
90-
border: 1px solid var(--color-border);
91-
border-radius: 14px;
92-
box-shadow: 0 8px 24px rgba(44, 62, 80, 0.08);
93-
padding: 1.2rem;
94-
}
95-
96-
.feature-card h2 {
97-
color: var(--color-heading);
98-
font-size: 1.1rem;
99-
font-weight: 600;
100-
}
101-
102-
.feature-card p {
103-
margin-top: 0.5rem;
104-
color: var(--vt-c-text-light-2);
105-
font-size: 0.95rem;
106-
}
107-
108-
.actions {
109-
display: flex;
110-
justify-content: center;
111-
flex-wrap: wrap;
112-
gap: 0.75rem;
113-
}
114-
115-
.btn {
116-
border: 0;
117-
border-radius: 999px;
118-
padding: 0.65rem 1.3rem;
119-
cursor: pointer;
120-
font-size: 0.95rem;
121-
transition: opacity 0.2s ease;
122-
}
123-
124-
.btn:hover {
125-
opacity: 0.9;
126-
}
127-
128-
.btn-primary {
129-
background: var(--vt-c-blue);
130-
color: var(--vt-c-white);
131-
}
132-
133-
.btn-secondary {
134-
background: var(--color-background);
135-
color: var(--color-heading);
136-
border: 1px solid var(--color-borderColor);
137-
}
138-
139-
@media (max-width: 768px) {
140-
.landing-page {
141-
min-height: auto;
142-
justify-content: flex-start;
143-
padding: 1.5rem 0.9rem;
144-
gap: 1.5rem;
145-
}
146-
147-
.feature-grid {
148-
grid-template-columns: 1fr;
149-
}
150-
151-
.actions {
152-
flex-direction: column;
153-
align-items: stretch;
154-
}
155-
156-
.btn {
157-
width: 100%;
158-
}
159-
}
160-
</style>

src/views/admin/issue.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
<!-- 信息发布 -->
1+
<!-- 信息发布 -->
2+
<template>
3+
<div class="rounded-lg border border-slate-200 bg-white p-4 text-slate-700 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-100">信息发布</div>
4+
</template>

src/views/admin/subjectManage.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
<!-- 科目管理 -->
1+
<!-- 科目管理 -->
2+
<template>
3+
<div class="rounded-lg border border-slate-200 bg-white p-4 text-slate-700 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-100">科目管理</div>
4+
</template>

src/views/algorithm/index.vue

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,13 @@ const toUrl = (key, url) => {
6464
<button class="nav-btn close-btn" aria-label="关闭导航" :aria-expanded="navVisible" aria-controls="algorithm-nav" @click="closeList">
6565
<el-icon><Close /></el-icon>
6666
</button>
67-
<div class="side">
68-
<div class="link">
69-
</div>
70-
<el-collapse>
67+
<div class="side mt-12">
68+
<div class="link"></div>
69+
<el-collapse class="rounded-lg border border-slate-200 bg-white/90 p-2 dark:border-slate-700 dark:bg-slate-950/80">
7170
<el-collapse-item name="1">
7271
<template #title>
7372
<el-icon><Sort /></el-icon>
74-
<span class="collapse-title">排序</span>
73+
<span class="ml-1">排序</span>
7574
</template>
7675
<div class="link">
7776
<span @click="toUrl('sort', 'buble')"><el-icon><Top /></el-icon>冒泡排序</span>
@@ -85,7 +84,7 @@ const toUrl = (key, url) => {
8584
<el-collapse-item name="2">
8685
<template #title>
8786
<el-icon><Search /></el-icon>
88-
<span class="collapse-title">查找</span>
87+
<span class="ml-1">查找</span>
8988
</template>
9089
<div class="link">
9190
<span @click="toUrl('search', 'binary')"><el-icon><Pointer /></el-icon>折半查找</span>
@@ -95,21 +94,19 @@ const toUrl = (key, url) => {
9594
<el-collapse-item name="3">
9695
<template #title>
9796
<el-icon><Share /></el-icon>
98-
<span class="collapse-title">二叉树</span>
97+
<span class="ml-1">二叉树</span>
9998
</template>
10099
<div class="link">
101100
<span @click="toUrl('binary', 'create')"><el-icon><Share /></el-icon>二叉搜索树</span>
102101
</div>
103-
<div>
104-
105-
</div>
102+
<div></div>
106103
</el-collapse-item>
107104
</el-collapse>
108105
</div>
109106
</div>
110107
</div>
111108
</div>
112-
<main class="algorithm-content">
109+
<main class="algorithm-content relative z-[1] px-6 py-4">
113110
<router-view></router-view>
114111
</main>
115112
</div>
@@ -125,7 +122,6 @@ const toUrl = (key, url) => {
125122
126123
.nav-btn {
127124
border: none;
128-
background-color: transparent;
129125
cursor: pointer;
130126
font-size: 20px;
131127
}
@@ -234,25 +230,9 @@ const toUrl = (key, url) => {
234230
right: 30px;
235231
}
236232
237-
.side {
238-
margin-top: 50px;
239-
}
240-
241-
.algorithm-content {
242-
position: relative;
243-
z-index: var(--algorithm-content-z);
244-
padding: 16px 24px;
245-
}
246-
247-
248-
.collapse-title {
249-
margin-left: 6px;
250-
}
251-
252233
:deep(.el-collapse-item__header) {
253234
font-size: 16px !important;
254235
gap: 4px;
255236
}
256237
257238
</style>
258-
<style></style>

0 commit comments

Comments
 (0)