@@ -4,25 +4,25 @@ import { useI18n } from 'vue-i18n'
44import { apiFetch } from ' @/shared/api'
55import { useToast , useConfirm } from ' sbot-ui'
66import { SModal , SButton , SBadge , SFormItem , SInput , STextarea , SCheckCard , STable , type STableColumn } from ' sbot-ui'
7- import type { MemoryItem , MemoryConfig } from ' @/shared/types'
7+ import type { NoteItem , NoteConfig } from ' @/shared/types'
88
99const { t } = useI18n ()
1010const { show } = useToast ()
1111const { confirm } = useConfirm ()
1212
1313const columns = computed <STableColumn []>(() => [
14- { key: ' content' , label: t (' memories .content_col' ), primary: true , ellipsis: true },
15- { key: ' createdAt' , label: t (' memories .created_col' ), width: ' 150px' , ellipsis: true },
16- { key: ' accessCount' , label: t (' memories .access_count_col' ), width: ' 60px' , align: ' center' },
17- { key: ' lastAccessed' , label: t (' memories .last_accessed_col' ), width: ' 150px' , ellipsis: true },
18- { key: ' ops' , label: t (' common.ops' ), width: ' 140px' , align: ' center' , ops: true },
14+ { key: ' content' , label: t (' notes .content_col' ), primary: true , ellipsis: true },
15+ { key: ' createdAt' , label: t (' notes .created_col' ), width: ' 150px' , ellipsis: true },
16+ { key: ' accessCount' , label: t (' notes .access_count_col' ), width: ' 60px' , align: ' center' },
17+ { key: ' lastAccessed' , label: t (' notes .last_accessed_col' ), width: ' 150px' , ellipsis: true },
18+ { key: ' ops' , label: t (' common.ops' ), width: ' 140px' , align: ' center' , ops: true },
1919])
2020
21- const visible = ref (false )
22- const memoryId = ref (' ' )
23- const memoryConfig = ref <Partial <MemoryConfig >>({})
24- const memories = ref <MemoryItem []>([])
25- const loading = ref (false )
21+ const visible = ref (false )
22+ const noteId = ref (' ' )
23+ const noteConfig = ref <Partial <NoteConfig >>({})
24+ const notes = ref <NoteItem []>([])
25+ const loading = ref (false )
2626
2727const showAddModal = ref (false )
2828const addContent = ref (' ' )
@@ -35,15 +35,15 @@ const editId = ref('')
3535const editContent = ref (' ' )
3636const saving = ref (false )
3737
38- function memUrl (path = ' ' ) {
39- return ` /api/memories /${encodeURIComponent (memoryId .value )}${path } `
38+ function noteUrl (path = ' ' ) {
39+ return ` /api/notes /${encodeURIComponent (noteId .value )}${path } `
4040}
4141
4242async function load() {
4343 loading .value = true
4444 try {
45- const res = await apiFetch (memUrl ())
46- memories .value = res .data || []
45+ const res = await apiFetch (noteUrl ())
46+ notes .value = res .data || []
4747 } catch (e : any ) {
4848 show (e .message , ' error' )
4949 } finally {
@@ -53,7 +53,7 @@ async function load() {
5353
5454async function remove(id : string ) {
5555 try {
56- await apiFetch (memUrl (` /${encodeURIComponent (id )} ` ), ' DELETE' )
56+ await apiFetch (noteUrl (` /${encodeURIComponent (id )} ` ), ' DELETE' )
5757 show (t (' common.deleted' ))
5858 await load ()
5959 } catch (e : any ) {
@@ -62,10 +62,10 @@ async function remove(id: string) {
6262}
6363
6464async function clearAll() {
65- if (! await confirm (t (' memories .confirm_clear' , { name: memoryConfig .value .name || memoryId .value }), { danger: true })) return
65+ if (! await confirm (t (' notes .confirm_clear' , { name: noteConfig .value .name || noteId .value }), { danger: true })) return
6666 try {
67- await apiFetch (memUrl (), ' DELETE' )
68- memories .value = []
67+ await apiFetch (noteUrl (), ' DELETE' )
68+ notes .value = []
6969 } catch (e : any ) {
7070 show (e .message , ' error' )
7171 }
@@ -79,15 +79,15 @@ function openAdd() {
7979}
8080
8181async function confirmAdd() {
82- if (! addContent .value .trim ()) { show (t (' memories .error_content' ), ' error' ); return }
82+ if (! addContent .value .trim ()) { show (t (' notes .error_content' ), ' error' ); return }
8383 adding .value = true
8484 try {
85- const res = await apiFetch (memUrl (' /add' ), ' POST' , {
85+ const res = await apiFetch (noteUrl (' /add' ), ' POST' , {
8686 content: addContent .value .trim (),
8787 autoSplit: autoSplit .value ,
8888 chunkSize: autoSplit .value ? chunkSize .value : undefined ,
8989 })
90- show (t (' memories .added_count' , { count: res .data ?.ids ?.length ?? 0 }))
90+ show (t (' notes .added_count' , { count: res .data ?.ids ?.length ?? 0 }))
9191 showAddModal .value = false
9292 await load ()
9393 } catch (e : any ) {
@@ -97,17 +97,17 @@ async function confirmAdd() {
9797 }
9898}
9999
100- function openEdit(row : MemoryItem ) {
100+ function openEdit(row : NoteItem ) {
101101 editId .value = row .id
102102 editContent .value = row .content
103103 showEditModal .value = true
104104}
105105
106106async function confirmEdit() {
107- if (! editContent .value .trim ()) { show (t (' memories .error_content' ), ' error' ); return }
107+ if (! editContent .value .trim ()) { show (t (' notes .error_content' ), ' error' ); return }
108108 saving .value = true
109109 try {
110- await apiFetch (memUrl (` /${encodeURIComponent (editId .value )} ` ), ' PUT' , { content: editContent .value .trim () })
110+ await apiFetch (noteUrl (` /${encodeURIComponent (editId .value )} ` ), ' PUT' , { content: editContent .value .trim () })
111111 show (t (' common.saved' ))
112112 showEditModal .value = false
113113 await load ()
@@ -118,11 +118,11 @@ async function confirmEdit() {
118118 }
119119}
120120
121- function open(id : string , config : Partial <MemoryConfig >) {
122- memoryId .value = id
123- memoryConfig .value = config
124- memories .value = []
125- visible .value = true
121+ function open(id : string , config : Partial <NoteConfig >) {
122+ noteId .value = id
123+ noteConfig .value = config
124+ notes .value = []
125+ visible .value = true
126126 load ()
127127}
128128
@@ -133,29 +133,29 @@ defineExpose({ open })
133133 <SModal v-model :visible =" visible " width="xl">
134134 <template #header >
135135 <div style =" display :flex ;align-items :center ;gap :10px " >
136- <h3 class =" s-modal-title" >{{ t('memories .content_title') }}</h3 >
137- <SBadge variant="neutral" size="sm">{{ memoryConfig .name || memoryId }}</SBadge >
138- <span v-if =" !loading" class =" mem -count-badge" >{{ t('memories .count', { count: memories .length }) }}</span >
136+ <h3 class =" s-modal-title" >{{ t('notes .content_title') }}</h3 >
137+ <SBadge variant="neutral" size="sm">{{ noteConfig .name || noteId }}</SBadge >
138+ <span v-if =" !loading" class =" note -count-badge" >{{ t('notes .count', { count: notes .length }) }}</span >
139139 </div >
140140 </template >
141141
142142 <template #toolbar >
143143 <SButton type="outline" size="sm" :disabled =" loading " @click =" load " >
144144 {{ loading ? t('common.loading') : t('common.refresh') }}
145145 </SButton >
146- <SButton type="primary" size="sm" @click =" openAdd " >{{ t('memories.add_memory ') }}</SButton >
147- <SButton type="danger" size="sm" style =" margin-left :auto " :disabled =" memories .length === 0 " @click =" clearAll " >
148- {{ t('memories .clear_all') }}
146+ <SButton type="primary" size="sm" @click =" openAdd " >{{ t('notes.add_note ') }}</SButton >
147+ <SButton type="danger" size="sm" style =" margin-left :auto " :disabled =" notes .length === 0 " @click =" clearAll " >
148+ {{ t('notes .clear_all') }}
149149 </SButton >
150150 </template >
151151
152152 <STable
153153 :columns =" columns "
154- :rows =" memories "
154+ :rows =" notes "
155155 row-key="id"
156156 :loading =" loading "
157157 :loading-text =" t (' common.loading' )"
158- :empty-text =" t (' memories.no_memories ' )"
158+ :empty-text =" t (' notes.no_notes ' )"
159159 >
160160 <template #content =" { row } " >
161161 <span :title =" row.content" >{{ row.content }}</span >
@@ -176,27 +176,27 @@ defineExpose({ open })
176176 </STable >
177177 </SModal >
178178
179- <!-- Add memory modal (nested) -->
180- <SModal v-model :visible =" showAddModal " :title =" t (' memories.add_memory_title ' )" width="sm" nested>
181- <SFormItem :label =" t (' memories.memory_content ' )" >
182- <STextarea v-model =" addContent " :rows =" 7 " :placeholder =" t (' memories.memory_placeholder ' )" />
179+ <!-- Add note modal (nested) -->
180+ <SModal v-model :visible =" showAddModal " :title =" t (' notes.add_note_title ' )" width="sm" nested>
181+ <SFormItem :label =" t (' notes.note_content ' )" >
182+ <STextarea v-model =" addContent " :rows =" 7 " :placeholder =" t (' notes.note_placeholder ' )" />
183183 </SFormItem >
184- <SCheckCard v-model =" autoSplit " style =" margin-top :8px " >{{ t('memories .auto_split') }}</SCheckCard >
185- <SFormItem v-if =" autoSplit " :label =" t (' memories .chunk_size' )" style =" margin-top :8px " >
186- <SInput v-model .number =" chunkSize " type="number" min="50" :placeholder =" t (' memories .chunk_size_placeholder' )" />
184+ <SCheckCard v-model =" autoSplit " style =" margin-top :8px " >{{ t('notes .auto_split') }}</SCheckCard >
185+ <SFormItem v-if =" autoSplit " :label =" t (' notes .chunk_size' )" style =" margin-top :8px " >
186+ <SInput v-model .number =" chunkSize " type="number" min="50" :placeholder =" t (' notes .chunk_size_placeholder' )" />
187187 </SFormItem >
188188 <template #footer >
189189 <SButton type="outline" :disabled =" adding " @click =" showAddModal = false " >{{ t('common.cancel') }}</SButton >
190190 <SButton type="primary" :disabled =" adding " :loading =" adding " @click =" confirmAdd " >
191- {{ adding ? t('memories .adding') : t('memories .add_btn') }}
191+ {{ adding ? t('notes .adding') : t('notes .add_btn') }}
192192 </SButton >
193193 </template >
194194 </SModal >
195195
196- <!-- Edit memory modal (nested) -->
197- <SModal v-model :visible =" showEditModal " :title =" t (' memories.edit_memory_title ' )" width="sm" nested>
198- <SFormItem :label =" t (' memories.memory_content ' )" >
199- <STextarea v-model =" editContent " :rows =" 7 " :placeholder =" t (' memories.memory_placeholder ' )" />
196+ <!-- Edit note modal (nested) -->
197+ <SModal v-model :visible =" showEditModal " :title =" t (' notes.edit_note_title ' )" width="sm" nested>
198+ <SFormItem :label =" t (' notes.note_content ' )" >
199+ <STextarea v-model =" editContent " :rows =" 7 " :placeholder =" t (' notes.note_placeholder ' )" />
200200 </SFormItem >
201201 <template #footer >
202202 <SButton type="outline" :disabled =" saving " @click =" showEditModal = false " >{{ t('common.cancel') }}</SButton >
@@ -208,7 +208,7 @@ defineExpose({ open })
208208</template >
209209
210210<style scoped>
211- .mem -count-badge {
211+ .note -count-badge {
212212 font-size : var (--sui-fs-sm );
213213 color : var (--sui-fg-disabled );
214214}
0 commit comments