Skip to content

Commit 5a22c1b

Browse files
committed
fix: 优化最新打开的面板的显示
1 parent 0c2ee5e commit 5a22c1b

File tree

1 file changed

+17
-23
lines changed

1 file changed

+17
-23
lines changed

app/src/sub/RecentFilesWindow.tsx

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ export default function RecentFilesWindow({ winId = "" }: { winId?: string }) {
3434
const [currentPreselect, setCurrentPreselect] = React.useState<number>(0);
3535
const [searchString, setSearchString] = React.useState("");
3636

37+
const [currentShowPath, setCurrentShowPath] = React.useState<string>("");
38+
const [currentShowTime, setCurrentShowTime] = React.useState<string>("");
39+
3740
/**
3841
* 用于刷新页面显示
3942
*/
@@ -65,24 +68,8 @@ export default function RecentFilesWindow({ winId = "" }: { winId?: string }) {
6568

6669
useEffect(() => {
6770
if (isLoading) return;
68-
const currentRect = SubWindow.get(winId).rect;
69-
const createdWin = SubWindow.create({
70-
titleBarOverlay: true,
71-
children: (
72-
<div className="flex flex-col gap-1 p-5">
73-
<span className="text-sm">文件路径</span>
74-
<span>{recentFilesFiltered[currentPreselect].uri.toString()}</span>
75-
<div className="h-1"></div>
76-
<span className="text-sm">修改时间</span>
77-
<span>{new Date(recentFilesFiltered[currentPreselect].time).toLocaleString()}</span>
78-
</div>
79-
),
80-
rect: new Rectangle(currentRect.rightTop.add(new Vector(10, 0)), Vector.same(-1)),
81-
closeWhenClickOutside: true,
82-
});
83-
return () => {
84-
SubWindow.close(createdWin.id);
85-
};
71+
setCurrentShowPath(decodeURI(recentFilesFiltered[currentPreselect].uri.toString()));
72+
setCurrentShowTime(new Date(recentFilesFiltered[currentPreselect].time).toLocaleString());
8673
}, [currentPreselect, isLoading]);
8774

8875
const handleKeyDown = (e: KeyboardEvent) => {
@@ -118,6 +105,10 @@ export default function RecentFilesWindow({ winId = "" }: { winId?: string }) {
118105
return (
119106
<div className={cn("flex h-full flex-col items-center gap-2")}>
120107
<Input placeholder="请输入要筛选的文件" onChange={onInputChange} value={searchString} autoFocus />
108+
<div className="flex w-full flex-col items-baseline justify-center px-4 text-xs">
109+
<p>{currentShowPath}</p>
110+
<p>{currentShowTime}</p>
111+
</div>
121112

122113
{/* 加载中提示 */}
123114
{isLoading && (
@@ -132,13 +123,16 @@ export default function RecentFilesWindow({ winId = "" }: { winId?: string }) {
132123
</div>
133124
)}
134125

135-
<div className="flex w-full flex-1 ring">
126+
<div className="flex w-full flex-wrap gap-2 p-4">
136127
{recentFilesFiltered.map((file, index) => (
137128
<div
138129
key={index}
139-
className={cn("flex origin-left items-center gap-2 border-4 border-transparent px-2 py-1 opacity-75", {
140-
"border-panel-success-text opacity-100": index === currentPreselect,
141-
})}
130+
className={cn(
131+
"bg-muted/50 flex max-w-64 origin-left flex-col items-center gap-2 truncate rounded-lg border p-4 px-2 py-1 opacity-75",
132+
{
133+
"opacity-100": index === currentPreselect,
134+
},
135+
)}
142136
onMouseEnter={() => setCurrentPreselect(index)}
143137
onClick={() => openFile(file)}
144138
>
@@ -154,6 +148,6 @@ RecentFilesWindow.open = () => {
154148
SubWindow.create({
155149
title: "最近打开的文件",
156150
children: <RecentFilesWindow />,
157-
rect: new Rectangle(new Vector(50, 50), new Vector(250, window.innerHeight - 100)),
151+
rect: new Rectangle(new Vector(50, 50), new Vector(window.innerWidth - 300, window.innerHeight - 100)),
158152
});
159153
};

0 commit comments

Comments
 (0)