11<template >
2- <el-dialog v-model =" show" title =" 打开" width =" 500" @closed =" input = ''" >
3- <el-tabs default-value =" file" >
2+ <el-dialog
3+ :modelValue =" !!show"
4+ @update:modelValue ="
5+ (v: boolean) => {
6+ if (v === false) {
7+ show = undefined
8+ }
9+ }
10+ "
11+ title =" 打开"
12+ width =" 500"
13+ @closed =" input = ''"
14+ >
15+ <el-tabs v-model =" show" >
416 <el-tab-pane label =" 文件" name =" file" >
517 <div class =" view-dialog" >
6- <el-input v-model =" input" placeholder =" 请输入文件路径(不存在的文件编辑后可直接新增)" >
18+ <el-input
19+ v-model =" input"
20+ placeholder =" 请输入文件路径(不存在的文件编辑后可直接新增)"
21+ class =" input"
22+ >
723 <template #append >
824 <el-button @click =" editor.add(input)" >确认</el-button >
925 </template >
1531 <el-button size =" small" @click =" open.clearHistory()" >清除全部</el-button >
1632 </div >
1733
18- <div class =" history " >
34+ <div class =" list " >
1935 <div
2036 class =" item"
2137 v-for =" item in open.history"
3046 </template >
3147 </div >
3248 </el-tab-pane >
49+
50+ <el-tab-pane label =" 目录" name =" dir" >
51+ <div class =" view-dialog" >
52+ <el-input v-model =" input" placeholder =" 请输入目录路径" class =" input" >
53+ <template #append >
54+ <el-button @click =" addDir(input)" >添加目录</el-button >
55+ </template >
56+ </el-input >
57+
58+ <div class =" title" >
59+ <div class =" t" >我的目录</div >
60+
61+ <el-select
62+ v-model =" cfg.folderDefOpen"
63+ size =" small"
64+ clearable
65+ style =" width : 200px "
66+ placeholder =" 选择目录"
67+ >
68+ <el-option-group label =" 启动时默认打开" >
69+ <el-option v-for =" item in user.cfg.dir" :key =" item" :label =" item" :value =" item" />
70+ </el-option-group >
71+ </el-select >
72+ </div >
73+
74+ <div class =" list" >
75+ <div class =" item" v-for =" item in user.cfg.dir" :key =" item" @click =" changeDir(item)" >
76+ <div class =" t" >{{ item }}</div >
77+ <div style =" flex : 1 " ></div >
78+ <el-icon v-if =" user.cfg.dir.length > 1" class =" i" @click.stop =" deleteDir(item)" >
79+ <Close />
80+ </el-icon >
81+ </div >
82+ </div >
83+ </div >
84+ </el-tab-pane >
3385 </el-tabs >
3486 </el-dialog >
3587</template >
@@ -39,31 +91,65 @@ import { onMounted } from 'vue'
3991import { storeToRefs } from ' pinia'
4092import { Close } from ' @element-plus/icons-vue'
4193
94+ import { useUserStore } from ' @/store/user'
4295import { useOpenStore } from ' @/store/open'
4396import { useEditorStore } from ' @/store/editor'
97+ import { useLikeStore } from ' @/store/like'
4498
99+ const user = useUserStore ()
45100const open = useOpenStore ()
101+ const like = useLikeStore ()
46102const editor = useEditorStore ()
47103
48104const { show, input } = storeToRefs (open )
105+ const { cfg } = storeToRefs (like )
49106
50107onMounted (async () => {
51108 const query = new URLSearchParams (window .location .search ).get (' path' ) || ' '
52109 if (query ) {
53110 editor .add (query )
54111 } else {
55- show .value = true
112+ show .value = ' file '
56113 }
57114})
115+
116+ const changeDir = (v : string ) => {
117+ like .cfg .folderActive = v
118+ open .show = undefined
119+ }
120+
121+ const addDir = (v : string ) => {
122+ const index = user .cfg .dir .findIndex ((i ) => i === v )
123+ if (index > - 1 ) {
124+ user .cfg .dir .splice (index , 1 )
125+ }
126+
127+ user .cfg .dir .unshift (v )
128+ }
129+
130+ const deleteDir = (v : string ) => {
131+ const index = user .cfg .dir .findIndex ((i ) => i === v )
132+ if (index > - 1 ) {
133+ user .cfg .dir .splice (index , 1 )
134+
135+ if (cfg .value .folderDefOpen === v ) {
136+ cfg .value .folderDefOpen = ' '
137+ }
138+ }
139+ }
58140 </script >
59141
60142<style lang="scss" scoped>
61143.view-dialog {
62144 display : flex ;
63145 flex-direction : column ;
64146
147+ > .input {
148+ margin-bottom : 12px ;
149+ }
150+
65151 > .title {
66- margin : 12 px 0 4px ;
152+ margin-bottom : 4px ;
67153 display : flex ;
68154 align-items : center ;
69155 gap : 12px ;
@@ -75,7 +161,7 @@ onMounted(async () => {
75161 }
76162 }
77163
78- > .history {
164+ > .list {
79165 display : flex ;
80166 flex-direction : column ;
81167 height : 200px ;
0 commit comments