Skip to content

Commit 283c25c

Browse files
committed
feat: v1.5.1
1 parent 85ff7c8 commit 283c25c

File tree

9 files changed

+47
-12
lines changed

9 files changed

+47
-12
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# 更新日志
22

3+
## 1.5.1
4+
5+
- 新增:偏好设置支持切换快照时询问
6+
- 新增:切换快照立即保存
7+
38
## 1.5.0
49

510
- 新增:文件快照功能,可随时回退文件

backend/src/cgi.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ async function main() {
7373
if (type) {
7474
console.log(`Content-Type: ${type}`)
7575
console.log(`Content-Length: ${body.size}`)
76-
console.log(`Last-Modified: ${body.time}`)
7776
console.log('')
7877
body.stream.pipe(process.stdout)
7978
} else {

backend/src/koa.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ app.use(async (ctx) => {
2222
if (type) {
2323
ctx.set('Content-Type', type)
2424
ctx.set('Content-Length', body.size)
25-
ctx.set('Last-Modified', body.time)
2625
ctx.body = body.stream
2726
} else {
2827
ctx.set('Content-Type', 'application/json; charset=utf-8')

backend/src/router/read.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ module.exports = async function ({ query }) {
2323
console.log(`Cache-Control: public, max-age=${maxAge}, immutable`)
2424
console.log(`Expires: ${new Date(Date.now() + maxAge * 1000).toUTCString()}`)
2525
console.log(`ETag: "${stat.size}-${stat.mtime.getTime()}"`)
26+
console.log(`Last-Modified: ${stat.mtime.toUTCString()}`)
2627
}
2728

2829
return {

frontend/src/components/MonacoEditor.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@
2222
path: code.path,
2323
value: code.value,
2424
encode: code.encode,
25-
callback: (v) => (code.value = v),
25+
callback: (v) => {
26+
code.value = v
27+
user.cfg.fileCameraUseDoSave && save()
28+
},
2629
})
2730
"
2831
>

frontend/src/layout/DialogLike.vue

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,24 @@
103103
<div v-if="cfg.fileBigWait > 0">超出 {{ getSize(cfg.fileBigWait) }} 将询问</div>
104104
</div>
105105
</div>
106+
107+
<div class="item">
108+
<div class="label">
109+
<div class="t">切换快照时询问</div>
110+
</div>
111+
<div class="value">
112+
<el-switch v-model="cfg.fileCameraUseConfirm" />
113+
</div>
114+
</div>
115+
116+
<div class="item">
117+
<div class="label">
118+
<div class="t">切换快照立即保存</div>
119+
</div>
120+
<div class="value">
121+
<el-switch v-model="cfg.fileCameraUseDoSave" />
122+
</div>
123+
</div>
106124
</el-tab-pane>
107125
<el-tab-pane label="目录" name="folder">
108126
<div class="item">

frontend/src/store/camera.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import axios from 'axios'
66
import { HOST, APP_DIR_PATH } from '@/utils/env'
77
import { getKey } from '@/utils/file'
88

9+
import { useUserStore } from './user'
10+
911
const CAMERA_DIR_PATH = `${APP_DIR_PATH}/camera`
1012

1113
interface ValueModel {
@@ -22,6 +24,8 @@ interface OpenModel {
2224
}
2325

2426
export const useCameraStore = defineStore('camera', () => {
27+
const user = useUserStore()
28+
2529
const show = ref(false)
2630

2731
const input = ref('')
@@ -126,14 +130,16 @@ export const useCameraStore = defineStore('camera', () => {
126130
return
127131
}
128132

129-
try {
130-
await ElMessageBox.confirm(`确定要使用【${item.name.replace(/\.txt$/, '')}】快照吗?当前窗口内容将会被覆盖`, '提示', {
131-
confirmButtonText: '继续',
132-
cancelButtonText: '取消',
133-
type: 'info',
134-
})
135-
} catch {
136-
return
133+
if (user.cfg.fileCameraUseConfirm) {
134+
try {
135+
await ElMessageBox.confirm(`确定要使用【${item.name.replace(/\.txt$/, '')}】快照吗?当前窗口内容将会被覆盖`, '提示', {
136+
confirmButtonText: '继续',
137+
cancelButtonText: '取消',
138+
type: 'info',
139+
})
140+
} catch {
141+
return
142+
}
137143
}
138144

139145
const filePath = `${CAMERA_DIR_PATH}/${getKey(option.value.path)}/${item.name}`

frontend/src/store/user.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ interface LikeModel {
1919
fileMdView: boolean // MD打开默认预览
2020
fileAllOpen: boolean // Web端全文件支持
2121
fileBigWait: number // 多大文件暂停加载,0为不启用
22+
fileCameraUseConfirm: boolean // 切换快照时询问
23+
fileCameraUseDoSave: boolean // 切换快照立即保存
2224
editorOption: {
2325
// 编辑器配置
2426
fontSize: number // 字体大小
@@ -44,6 +46,8 @@ const getDef = (): LikeModel => ({
4446
fileMdView: false, // md默认预览
4547
fileAllOpen: false, // Web端全文件支持
4648
fileBigWait: 50 * 1024 * 1024, // 多大文件暂停加载,0为不启用,默认50M
49+
fileCameraUseConfirm: true, // 切换快照时询问
50+
fileCameraUseDoSave: false, // 切换快照立即保存
4751
editorOption: {
4852
// 编辑器配置
4953
fontSize: 14, // 字体大小

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "code.editor",
3-
"version": "1.5.0",
3+
"version": "1.5.1",
44
"changelog": "<div>新增:文件快照功能,可随时回退文件</div><div>新增:图片查看,支持同级快速预览</div><div>新增:PDF 阅读,支持索引跳转和缩放</div><div>新增:支持刷新目录和在目录下创建文件</div><div>新增:偏好设置-启动时询问,可在桌面图标访问时不询问开启</div><div>新增:markdown 文件支持预览</div><div>新增:偏好设置支持设置打开 markdown 时默认预览</div><div>新增:显示字数、文件大小、最后更新日期</div><div>新增:独立窗口按钮</div><div>新增:加载大文件将提示是否继续加载,避免带宽浪费</div>",
55
"scripts": {
66
"dev": "node src/app.js",

0 commit comments

Comments
 (0)