编辑调整、对比模块
This commit is contained in:
1 parent
c9e61f38c5
commit
6cfa74c901
76 files changed
+9514
-626
No files matched your search
@@ -22,6 +22,25 @@ const store = useEditorStore()
|
||||
const files = computed(() => store.recentFiles)
|
||||
const folders = computed(() => store.recentFolders)
|
||||
|
||||
/** 取所在目录(同时兼容 `\` 与 `/`)。 */
|
||||
function parentDir(fullPath: string): string {
|
||||
const index = Math.max(fullPath.lastIndexOf('\\'), fullPath.lastIndexOf('/'))
|
||||
return index > 0 ? fullPath.slice(0, index) : ''
|
||||
}
|
||||
|
||||
/**
|
||||
* 路径尾部摘要:只保留末尾若干字符并前置省略号(例:`...ways\Downloads`)。
|
||||
*
|
||||
* 做「一眼看出在哪儿」的提示,完整路径仍由行的 `title` 提供。短路径整段显示,
|
||||
* 长路径保留末尾 14 个字符 —— 前面的盘符与中间层级对辨认位置帮助不大,省略它们
|
||||
* 反而让列表更整齐。目录项与文件项都取**所在目录**,名字里已经有的末级不再重复。
|
||||
*/
|
||||
function pathTail(fullPath: string): string {
|
||||
const dir = parentDir(fullPath).replace(/\//g, '\\')
|
||||
if (!dir) return ''
|
||||
return dir.length <= 18 ? dir : `...${dir.slice(-14)}`
|
||||
}
|
||||
|
||||
async function openFile(entry: RecentEntry): Promise<void> {
|
||||
try {
|
||||
await store.openDoc(entry.path)
|
||||
@@ -83,7 +102,9 @@ async function openFolder(entry: RecentEntry): Promise<void> {
|
||||
@click="openFile(entry)"
|
||||
>
|
||||
<FileText class="size-3.5 shrink-0 opacity-70" />
|
||||
<span class="truncate">{{ entry.name }}</span>
|
||||
<span class="truncate">
|
||||
{{ entry.name }}<span v-if="pathTail(entry.path)" class="text-muted-foreground">({{ pathTail(entry.path) }})</span>
|
||||
</span>
|
||||
<span v-if="!entry.exists" class="shrink-0 text-[10px]">(已失效)</span>
|
||||
<button
|
||||
type="button"
|
||||
@@ -118,7 +139,9 @@ async function openFolder(entry: RecentEntry): Promise<void> {
|
||||
@click="openFolder(entry)"
|
||||
>
|
||||
<History class="size-3.5 shrink-0 opacity-70" />
|
||||
<span class="truncate">{{ entry.name }}</span>
|
||||
<span class="truncate">
|
||||
{{ entry.name }}<span v-if="pathTail(entry.path)" class="text-muted-foreground">({{ pathTail(entry.path) }})</span>
|
||||
</span>
|
||||
<span v-if="!entry.exists" class="shrink-0 text-[10px]">(已失效)</span>
|
||||
<button
|
||||
type="button"
|
||||
|
||||
Reference in new issue
Block a user