Skip to content

Commit 990034d

Browse files
committed
feat: 部分细节优化
1 parent 967f69d commit 990034d

9 files changed

Lines changed: 24 additions & 118 deletions

File tree

frontend/.prettierrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"$schema": "https://json.schemastore.org/prettierrc",
33
"semi": false,
44
"singleQuote": true,
5-
"printWidth": 100
5+
"printWidth": 140
66
}

frontend/src/components/MonacoEditor.vue

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -21,44 +21,14 @@
2121

2222
<div class="info">{{ code.value.length }} 个字符</div>
2323

24-
<el-switch
25-
v-if="code.lang === 'markdown'"
26-
v-model="mdView"
27-
inline-prompt
28-
active-text="预览"
29-
inactive-text="源码"
30-
/>
24+
<el-switch v-if="code.lang === 'markdown'" v-model="mdView" inline-prompt active-text="预览" inactive-text="源码" />
3125

32-
<el-select
33-
v-model="code.lang"
34-
style="width: 120px"
35-
size="small"
36-
filterable
37-
placement="top"
38-
@change="changeLang"
39-
>
40-
<el-option
41-
v-for="item in LANG_OPTIONS"
42-
:key="item.value"
43-
:label="item.label"
44-
:value="item.value"
45-
/>
26+
<el-select v-model="code.lang" style="width: 120px" size="small" filterable placement="top" @change="changeLang">
27+
<el-option v-for="item in LANG_OPTIONS" :key="item.value" :label="item.label" :value="item.value" />
4628
</el-select>
4729

48-
<el-select
49-
v-model="code.encode"
50-
style="width: 120px"
51-
size="small"
52-
filterable
53-
placement="top-end"
54-
@change="changeEncode"
55-
>
56-
<el-option
57-
v-for="item in ENCODING_OPTIONS"
58-
:key="item.value"
59-
:label="item.label"
60-
:value="item.value"
61-
/>
30+
<el-select v-model="code.encode" style="width: 120px" size="small" filterable placement="top-end" @change="changeEncode">
31+
<el-option v-for="item in ENCODING_OPTIONS" :key="item.value" :label="item.label" :value="item.value" />
6232
</el-select>
6333
</div>
6434
</template>

frontend/src/components/PdfView.vue

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,7 @@
77

88
<div style="flex: 1"></div>
99

10-
<el-input-number
11-
v-model="option.scale"
12-
:min="10"
13-
:max="200"
14-
:step="10"
15-
size="small"
16-
@change="changeScale"
17-
style="width: 140px"
18-
>
10+
<el-input-number v-model="option.scale" :min="10" :max="200" :step="10" size="small" @change="changeScale" style="width: 140px">
1911
<template #prefix>
2012
<span>比例</span>
2113
</template>
@@ -44,12 +36,7 @@
4436

4537
<div class="body">
4638
<div class="left" v-show="left.outline" :style="{ width: `${left.width}px` }">
47-
<el-tree
48-
:data="outline"
49-
:props="{ children: 'items', label: 'title' }"
50-
:expand-on-click-node="false"
51-
@node-click="outlineClick"
52-
/>
39+
<el-tree :data="outline" :props="{ children: 'items', label: 'title' }" :expand-on-click-node="false" @node-click="outlineClick" />
5340

5441
<ClickMove @move="(v) => changeLeftWidth(v.x)" />
5542
</div>

frontend/src/layout/DialogLike.vue

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,7 @@
88
</div>
99
<div class="value">
1010
<el-select v-model="cfg.theme" size="small">
11-
<el-option
12-
v-for="item in THEME_OPTIONS"
13-
:key="item.value"
14-
:label="item.label"
15-
:value="item.value"
16-
/>
11+
<el-option v-for="item in THEME_OPTIONS" :key="item.value" :label="item.label" :value="item.value" />
1712
</el-select>
1813
</div>
1914
</div>
@@ -51,12 +46,7 @@
5146
<div class="t">自动换行</div>
5247
</div>
5348
<div class="value">
54-
<el-switch
55-
v-model="cfg.editorOption.wordWrap"
56-
inline-prompt
57-
active-value="on"
58-
inactive-value="off"
59-
/>
49+
<el-switch v-model="cfg.editorOption.wordWrap" inline-prompt active-value="on" inactive-value="off" />
6050
</div>
6151
</div>
6252

@@ -95,12 +85,7 @@
9585
<div class="t">默认打开</div>
9686
</div>
9787
<div class="value">
98-
<el-select
99-
v-model="cfg.folderDefOpen"
100-
size="small"
101-
clearable
102-
placeholder="启动时默认打开某个目录"
103-
>
88+
<el-select v-model="cfg.folderDefOpen" size="small" clearable placeholder="启动时默认打开某个目录">
10489
<el-option v-for="item in user.cfg.dir" :key="item" :label="item" :value="item" />
10590
</el-select>
10691
</div>
@@ -145,9 +130,7 @@ const { open } = storeToRefs(like)
145130
const { cfg } = storeToRefs(user)
146131
147132
watchEffect(() => {
148-
document.documentElement.className = THEME_OPTIONS.find((i) => i.value === cfg.value.theme)?.dark
149-
? 'dark'
150-
: ''
133+
document.documentElement.className = THEME_OPTIONS.find((i) => i.value === cfg.value.theme)?.dark ? 'dark' : ''
151134
})
152135
153136
watch(cfg, user.update, { deep: true })

frontend/src/layout/DialogOpen.vue

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,7 @@
1515
<el-tabs v-model="show">
1616
<el-tab-pane label="文件" name="file">
1717
<div class="view-dialog">
18-
<el-input
19-
v-model="input"
20-
placeholder="请输入文件路径(不存在的文件编辑后可直接新增)"
21-
class="input"
22-
>
18+
<el-input v-model="input" placeholder="请输入文件路径(不存在的文件编辑后可直接新增)" class="input">
2319
<template #append>
2420
<el-button @click="editor.add(input)">确认</el-button>
2521
</template>
@@ -32,12 +28,7 @@
3228
</div>
3329

3430
<div class="list">
35-
<div
36-
class="item"
37-
v-for="item in open.history"
38-
:key="item.path"
39-
@click="editor.add(item.path)"
40-
>
31+
<div class="item" v-for="item in open.history" :key="item.path" @click="editor.add(item.path)">
4132
<div class="t">{{ item.path }}</div>
4233
<div style="flex: 1"></div>
4334
<el-icon class="i" @click.stop="open.removeHistory(item.path)"><Close /></el-icon>
@@ -58,13 +49,7 @@
5849
<div class="title">
5950
<div class="t">我的目录</div>
6051

61-
<el-select
62-
v-model="cfg.folderDefOpen"
63-
size="small"
64-
clearable
65-
style="width: 200px"
66-
placeholder="选择目录"
67-
>
52+
<el-select v-model="cfg.folderDefOpen" size="small" clearable style="width: 200px" placeholder="选择目录">
6853
<el-option-group label="启动时默认打开">
6954
<el-option v-for="item in user.cfg.dir" :key="item" :label="item" :value="item" />
7055
</el-option-group>

frontend/src/layout/ViewEditor.vue

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,11 @@
1313
<div v-show="item.diff" class="diff"></div>
1414
</template>
1515

16-
<ImageView
17-
v-if="FILE_MAP[getFileSuffix(item.path)] === 'img'"
18-
:src="item.path"
19-
:list="item.list"
20-
/>
16+
<ImageView v-if="FILE_MAP[getFileSuffix(item.path)] === 'img'" :src="item.path" :list="item.list" />
2117

2218
<PdfView v-else-if="FILE_MAP[getFileSuffix(item.path)] === 'pdf'" :src="item.path" />
2319

24-
<div
25-
class="no-open"
26-
v-else-if="FILE_MAP[getFileSuffix(item.path)] || errorMap[item.path]"
27-
>
20+
<div class="no-open" v-else-if="FILE_MAP[getFileSuffix(item.path)] || errorMap[item.path]">
2821
<div class="t">{{ errorMap[item.path] || '不支持二进制文件的编辑' }}</div>
2922
</div>
3023

@@ -91,10 +84,7 @@ const errorMap = ref<{ [x: string]: string | undefined }>({})
9184
9285
watch(
9386
() => active.value,
94-
() =>
95-
editor.view.forEach(
96-
(item) => active.value !== item.path && !item.keep && editor.remove(item.path),
97-
),
87+
() => editor.view.forEach((item) => active.value !== item.path && !item.keep && editor.remove(item.path)),
9888
)
9989
</script>
10090

frontend/src/layout/ViewLeft/ViewFolder.vue

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,7 @@ import { useLikeStore } from '@/store/like'
6666
import { useOpenStore } from '@/store/open'
6767
import { useUserStore } from '@/store/user'
6868
69-
import {
70-
type TreeInstance,
71-
type TreeData,
72-
type TreeNodeData,
73-
type RenderContentContext,
74-
} from 'element-plus'
69+
import type { TreeInstance, TreeData, TreeNodeData, RenderContentContext } from 'element-plus'
7570
7671
const editor = useEditorStore()
7772
const like = useLikeStore()
@@ -95,11 +90,7 @@ const addFile = async (node: RenderContentContext['node']) => {
9590
9691
const path = `${node.data.value}/${value}`
9792
98-
await axios.post(
99-
HOST,
100-
{ encode: 'utf8', path, value: '', force: 1 },
101-
{ params: { _api: 'save' } },
102-
)
93+
await axios.post(HOST, { encode: 'utf8', path, value: '', force: 1 }, { params: { _api: 'save' } })
10394
10495
editor.add(path, { keep: false })
10596

frontend/src/store/user.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import axios from 'axios'
44
import { cloneDeep, debounce } from 'lodash'
55

66
import localStorage from '@/utils/localStorage'
7-
import { HOST, IS_DEV, USER_CONFIG_PATH } from '@/utils/env'
7+
import { HOST, IS_DEV, APP_DIR_PATH } from '@/utils/env'
88

99
import { useLikeStore } from '@/store/like'
1010

@@ -30,6 +30,8 @@ interface LikeModel {
3030
folderHidePrefix: string[] // 隐藏的文件前缀
3131
}
3232

33+
const USER_CONFIG_PATH = `${APP_DIR_PATH}/config.json`
34+
3335
const getDef = (): LikeModel => ({
3436
// 全局配置
3537
theme: 'vs-dark', // 主题

frontend/src/utils/env.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,4 @@ export const IS_DEV = import.meta.env.MODE === 'development'
22

33
export const HOST = IS_DEV ? 'http://127.0.0.1:17746' : '/cgi/ThirdParty/code.editor/index.cgi'
44

5-
export const USER_CONFIG_PATH = IS_DEV
6-
? '/Users/flex/Downloads/config.json'
7-
: '/var/apps/code.editor/shares/code.editor/config.json'
5+
export const APP_DIR_PATH = IS_DEV ? '/Users/flex/Downloads' : '/var/apps/code.editor/shares/code.editor'

0 commit comments

Comments
 (0)