Skip to content

Commit ba8bfad

Browse files
committed
fix: 细节优化
1 parent 095d0ce commit ba8bfad

4 files changed

Lines changed: 27 additions & 5 deletions

File tree

backend/src/cgi.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ async function main() {
121121
console.log(`Expires: ${new Date(Date.now() + maxAge * 1000).toUTCString()}`)
122122
console.log(`ETag: "${body.size}-${body.mtime.getTime()}"`)
123123
console.log(`Last-Modified: ${body.mtime.toUTCString()}`)
124+
} else {
125+
console.log('Cache-Control: no-store')
124126
}
125127

126128
// 自定义响应头

backend/src/koa.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@ app.use(async (ctx) => {
4848
if (type) {
4949
ctx.set('Content-Type', type)
5050
ctx.set('Content-Length', body.size)
51+
52+
// 缓存静态资源
53+
if (data.cache) {
54+
//
55+
} else {
56+
ctx.set('Cache-Control', 'no-store')
57+
}
58+
5159
ctx.set('Access-Control-Expose-Headers', 'X-Size,X-Update-Date,X-Create-Date')
5260
ctx.set('X-Size', body.size)
5361
ctx.set('X-Update-Date', body.mtime.toUTCString())

frontend/src/layout/ViewLeft/ViewFolder.vue

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@
6363
</template>
6464

6565
<script lang="ts" setup>
66-
import { ref, useTemplateRef } from 'vue'
67-
import { dayjs, ElMessageBox } from 'element-plus'
66+
import { nextTick, ref, useTemplateRef } from 'vue'
67+
import { dayjs, ElMessage, ElMessageBox } from 'element-plus'
6868
import { Files, Folder, FolderOpened, Refresh, Upload, DocumentAdd } from '@element-plus/icons-vue'
6969
7070
import FileView from '@/components/FileView.vue'
@@ -105,6 +105,8 @@ const addFile = async (node: RenderContentContext['node']) => {
105105
106106
await saveFile({ path, force: true, file: new Blob([new TextEncoder().encode(' ')]) })
107107
108+
ElMessage({ type: 'success', message: '操作成功' })
109+
108110
editor.add(path, { keep: false })
109111
110112
refreshNode(node)
@@ -141,12 +143,22 @@ const uploadFileChange = async (e: any) => {
141143
}
142144
}
143145
144-
await saveFile({ path: `${uploadInfo.value.data.value}/${file.name}`, force: true, file })
146+
const path = `${uploadInfo.value.data.value}/${file.name}`
147+
148+
await saveFile({ path, force: true, file })
149+
150+
ElMessage({ type: 'success', message: '操作成功' })
145151
146152
refreshNode(uploadInfo.value)
147153
154+
editor.remove(path, true)
155+
148156
e.target.value = ''
149157
uploadInfo.value = undefined
158+
159+
nextTick(() => {
160+
editor.add(path, { keep: false })
161+
})
150162
}
151163
152164
const refreshNode = (node: RenderContentContext['node']) => {

frontend/src/store/editor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,11 @@ export const useEditorStore = defineStore('editor', () => {
7878
}
7979
}
8080

81-
const remove = async (path: string) => {
81+
const remove = async (path: string, force = false) => {
8282
const index = view.findIndex((i) => i.path === path)
8383
const item = view[index]
8484
if (item) {
85-
if (item.diff) {
85+
if (item.diff && !force) {
8686
const value = await ElMessageBox.confirm('文件未保存,你的更改将丢失,确认关闭?', '提示', {
8787
confirmButtonText: '确认',
8888
cancelButtonText: '取消',

0 commit comments

Comments
 (0)