Skip to content

Commit 6ac55eb

Browse files
committed
fix: 细节修复
1 parent 11a8d93 commit 6ac55eb

2 files changed

Lines changed: 15 additions & 19 deletions

File tree

frontend/src/layout/DialogCamera.vue

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,9 @@
11
<template>
22
<el-dialog v-model="camera.show" title="文件快照" width="600">
33
<div class="camera-dialog">
4-
<el-input v-model="input" placeholder="请输入快照说明" class="input" maxlength="32" show-word-limit>
4+
<el-input v-model="camera.input" placeholder="请输入快照说明" class="input" maxlength="32" show-word-limit>
55
<template #append>
6-
<el-button
7-
@click="
8-
() => {
9-
camera.add(input)
10-
input = ''
11-
}
12-
"
13-
>
14-
添加快照
15-
</el-button>
6+
<el-button @click="camera.add()"> 添加快照 </el-button>
167
</template>
178
</el-input>
189

@@ -43,12 +34,8 @@
4334
</template>
4435

4536
<script lang="ts" setup>
46-
import { ref } from 'vue'
47-
4837
import { useCameraStore } from '@/store/camera'
4938
import { dayjs } from 'element-plus'
5039
5140
const camera = useCameraStore()
52-
53-
const input = ref('')
5441
</script>

frontend/src/store/camera.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ interface OpenModel {
2424
export const useCameraStore = defineStore('camera', () => {
2525
const show = ref(false)
2626

27+
const input = ref('')
28+
2729
const option = ref<OpenModel>()
2830

2931
const data = ref<ValueModel[]>([])
@@ -55,12 +57,17 @@ export const useCameraStore = defineStore('camera', () => {
5557
}
5658
}
5759

58-
const add = async (msg: string) => {
59-
if (!option.value) {
60+
const add = async () => {
61+
if (!option.value || !input.value) {
62+
return
63+
}
64+
65+
if (data.value.find((i) => i.name.replace(/\.txt$/, '') === input.value)) {
66+
ElMessage({ type: 'error', message: '快照说明不能相同' })
6067
return
6168
}
6269

63-
const filePath = `${CAMERA_DIR_PATH}/${getKey(option.value.path)}/${msg}.txt`
70+
const filePath = `${CAMERA_DIR_PATH}/${getKey(option.value.path)}/${input.value}.txt`
6471

6572
await axios.post(
6673
HOST,
@@ -73,6 +80,8 @@ export const useCameraStore = defineStore('camera', () => {
7380
{ params: { _api: 'save' } },
7481
)
7582

83+
input.value = ''
84+
7685
await load()
7786
}
7887

@@ -139,5 +148,5 @@ export const useCameraStore = defineStore('camera', () => {
139148
show.value = false
140149
}
141150

142-
return { show, data, open, add, del, usage }
151+
return { show, input, data, open, add, del, usage }
143152
})

0 commit comments

Comments
 (0)