@@ -24,6 +24,8 @@ interface OpenModel {
2424export 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 ( / \. t x t $ / , '' ) === 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