Skip to content

Commit 50d9f14

Browse files
committed
fix: 修复大量抽离组件后带来的布局问题
1 parent 030215d commit 50d9f14

6 files changed

Lines changed: 48 additions & 38 deletions

File tree

src/components/layout/SidebarLeft.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ function handleNavClick(panelName: typeof windowStore.activeLeftPanelName) {
300300
/* 设置弹出框样式 */
301301
.settings-popover {
302302
position: absolute;
303-
left: 25px;
303+
left: 49px;
304304
bottom: -1px;
305305
}
306306
</style>

src/components/layout/TopMenuBar.vue

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,11 @@
6464
v-if="showStoredProjectsPopover"
6565
class="topbar-popover stored-projects-popover"
6666
>
67-
<StoredProjectsPopover />
67+
<StoredProjectsPopover
68+
:projects="storedProjects"
69+
@refresh="refreshStoredProjects"
70+
@close="closeAllPopovers"
71+
/>
6872
</div>
6973
</div>
7074

@@ -116,6 +120,7 @@ import { useWindowStore } from '@/stores/windowStore';
116120
import { useActiveContext } from '@/composables/useActiveContext';
117121
import { useFileImport } from '@/composables/useImporter';
118122
import { useProjectManager } from '@/composables/useProjectManager';
123+
import { vClickOutside } from '@/directives/clickOutside';
119124
import type { ProjectFile } from '@/types/project';
120125
import StoredProjectsPopover from '@/components/popovers/StoredProjectsPopover.vue';
121126
import ExportPopover from '@/components/popovers/ExportPopover.vue';
@@ -132,7 +137,7 @@ const activeContext = useActiveContext();
132137
const { importAndApply } = useFileImport();
133138
const projectManager = useProjectManager();
134139
135-
const showExportPopover = ref(true);
140+
const showExportPopover = ref(false);
136141
const showStoredProjectsPopover = ref(false);
137142
const storedProjects = ref<ProjectFile[]>([]);
138143
function closeAllPopovers() {
@@ -293,15 +298,16 @@ function handleClearAll() {
293298
294299
.topbar-popover {
295300
position: absolute;
296-
top: calc(100% + 8px);
297301
z-index: 100;
298302
}
299303
300304
.stored-projects-popover {
301-
right: -70px;
305+
top: 36px;
306+
right: -80px;
302307
}
303308
304309
.export-popover {
310+
top: 30px;
305311
right: -10px;
306312
}
307313
</style>

src/components/popovers/ExportPopover.vue

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div class="export-popover">
2+
<div class="popover">
33
<div class="export-item" @click="handleExportText">导出为 TEXT</div>
44
<div class="export-item" @click="handleExportHtml">导出为 HTML</div>
55
<div class="export-item" @click="handleExportDoc">导出为 DOC</div>
@@ -62,16 +62,13 @@ function handleExportProject() {
6262
}
6363
</script>
6464
<style scoped>
65-
.export-popover {
65+
.popover {
6666
width: 160px;
67-
box-sizing: border-box;
68-
padding: 6px 0;
69-
background: var(--bg-topbar);
7067
box-shadow: 0 4px 12px var(--box-shadow);
7168
}
7269
7370
.export-item {
74-
padding: 8px 16px;
71+
padding: 10px 16px;
7572
font-size: 13px;
7673
color: var(--text-primary);
7774
cursor: pointer;

src/components/popovers/SettingsPopover.vue

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div class="settings-popover">
2+
<div class="popover">
33
<div class="popover-header">偏好设置</div>
44

55
<div class="settings-section">
@@ -80,13 +80,9 @@ const styleStore = useStyleStore();
8080
</script>
8181

8282
<style scoped>
83-
.settings-popover {
83+
.popover {
8484
width: 200px;
85-
background-color: var(--bg-sidebar);
8685
padding: 12px;
87-
z-index: 100;
88-
cursor: default;
89-
color: var(--text-primary);
9086
box-shadow: 5px -3px 12px var(--box-shadow);
9187
}
9288

src/components/popovers/StoredProjectsPopover.vue

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div class="stored-projects-panel">
2+
<div class="popover">
33
<div class="stored-projects-toolbar">
44
<span>本地工程</span>
55
<button
@@ -11,13 +11,14 @@
1111
<RefreshCcw class="ui-icon" aria-hidden="true" />
1212
</button>
1313
</div>
14-
<div v-if="storedProjects.length === 0" class="stored-projects-empty">
14+
<div v-if="projects.length === 0" class="stored-projects-empty">
1515
当前没有已保存的本地工程
1616
</div>
1717
<div
18-
v-for="project in storedProjects"
18+
v-for="project in projects"
1919
:key="project.projectId"
2020
class="stored-project-item"
21+
@click="handleOpenStoredProject(project.projectId)"
2122
>
2223
<div class="stored-project-main">
2324
<div class="stored-project-name">
@@ -29,14 +30,6 @@
2930
</div>
3031
</div>
3132
<div class="stored-project-actions">
32-
<button
33-
class="icon-interactive"
34-
type="button"
35-
title="打开工程"
36-
@click="handleOpenStoredProject(project.projectId)"
37-
>
38-
<FolderOpen class="ui-icon" aria-hidden="true" />
39-
</button>
4033
<button
4134
class="icon-interactive icon-button-warning"
4235
type="button"
@@ -50,22 +43,31 @@
5043
</div>
5144
</template>
5245
<script setup lang="ts">
53-
import { ref } from 'vue';
46+
import { RefreshCcw, Trash2 } from '@lucide/vue';
5447
import { formatDate } from '@/utils/date';
5548
import type { ProjectFile } from '@/types/project';
5649
import { useProjectManager } from '@/composables/useProjectManager';
5750
51+
defineProps<{
52+
projects: ProjectFile[];
53+
}>();
54+
55+
const emit = defineEmits<{
56+
refresh: [];
57+
close: [];
58+
}>();
59+
5860
const projectManager = useProjectManager();
59-
const storedProjects = ref<ProjectFile[]>([]);
6061
6162
function refreshStoredProjects() {
62-
storedProjects.value = projectManager.getStoredProjects();
63+
emit('refresh');
6364
}
6465
6566
function handleOpenStoredProject(projectId: string) {
6667
try {
6768
if (projectManager.openStoredProject(projectId)) {
6869
refreshStoredProjects();
70+
emit('close');
6971
}
7072
} catch (error) {
7173
console.error(error);
@@ -96,21 +98,19 @@ function formatStoredProjectTime(time: string) {
9698
}
9799
</script>
98100
<style scoped>
99-
.stored-projects-panel {
101+
.popover {
100102
width: 280px;
101-
box-sizing: border-box;
102103
max-height: 400px;
103104
overflow-y: auto;
104-
padding: 10px 12px;
105-
color: var(--text-primary);
106-
background: var(--bg-topbar);
105+
padding-top: 10px;
107106
box-shadow: 0 4px 12px var(--box-shadow);
108107
}
109108
110109
.stored-projects-toolbar {
111110
display: flex;
112111
align-items: center;
113112
justify-content: space-between;
113+
padding: 0px 10px;
114114
margin-bottom: 4px;
115115
font-size: 13px;
116116
color: var(--text-muted);
@@ -124,7 +124,7 @@ function formatStoredProjectTime(time: string) {
124124
}
125125
126126
.stored-projects-empty {
127-
padding: 10px 0;
127+
padding: 10px 12px;
128128
font-size: 12px;
129129
color: var(--text-muted);
130130
}
@@ -134,9 +134,12 @@ function formatStoredProjectTime(time: string) {
134134
align-items: center;
135135
justify-content: space-between;
136136
gap: 8px;
137-
padding: 8px 0;
137+
padding: 10px 12px;
138138
border-top: none;
139139
}
140+
.stored-project-item:hover {
141+
background-color: var(--hover-bg);
142+
}
140143
141144
.stored-project-main {
142145
min-width: 0;

src/styles/style.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,14 @@ body,
435435
height: 16px;
436436
}
437437

438+
/* 通用 Popover 样式 */
439+
.popover {
440+
background-color: var(--bg-sidebar);
441+
z-index: 100;
442+
cursor: default;
443+
color: var(--text-primary);
444+
}
445+
438446
/* 滚动条,不知道为什么无论怎么写就是去不掉这个圆角 */
439447
* {
440448
scrollbar-width: thin;

0 commit comments

Comments
 (0)