Import the client, server, skills, tests, and build scripts as the starting point for the rebuild, then trim the surfaces this project does not ship: Electron desktop packaging, the marketing website, and the ESP32 firmware tree. CI keeps the web build, e2e, lockfile, release, and Docker workflows. Rename the package and CLI entry points to hermes-ui, drop the prepare hook so npm ci no longer triggers a build, and drop the removed tsconfig and nodemon references. Rewrite AGENTS.md, ARCHITECTURE.md, DEVELOPMENT.md, and the READMEs so the documented package map and hard rules match this repository. reference_code/ is ignored: it is a read-only snapshot, not an input to the build.
100 lines
2.7 KiB
Vue
100 lines
2.7 KiB
Vue
<script setup lang="ts">
|
|
import { ref, watch, computed } from 'vue'
|
|
import { NModal, NInput, NButton, NSpace, useMessage } from 'naive-ui'
|
|
import { useI18n } from 'vue-i18n'
|
|
import { useFilesStore } from '@/stores/hermes/files'
|
|
import type { FileEntry } from '@/api/hermes/files'
|
|
|
|
const { t } = useI18n()
|
|
const message = useMessage()
|
|
const filesStore = useFilesStore()
|
|
|
|
const props = defineProps<{
|
|
show: boolean
|
|
mode: 'newFile' | 'newFolder' | 'rename'
|
|
entry?: FileEntry | null
|
|
targetPath?: string | null
|
|
}>()
|
|
|
|
const emit = defineEmits<{
|
|
(e: 'update:show', value: boolean): void
|
|
}>()
|
|
|
|
const inputValue = ref('')
|
|
const submitting = ref(false)
|
|
|
|
watch(() => props.show, (val) => {
|
|
if (val) {
|
|
if (props.mode === 'rename' && props.entry) {
|
|
inputValue.value = props.entry.name
|
|
} else {
|
|
inputValue.value = ''
|
|
}
|
|
}
|
|
})
|
|
|
|
const title = computed(() => {
|
|
switch (props.mode) {
|
|
case 'newFile': return t('files.newFile')
|
|
case 'newFolder': return t('files.newFolder')
|
|
case 'rename': return t('files.rename')
|
|
}
|
|
})
|
|
|
|
const placeholder = computed(() => {
|
|
switch (props.mode) {
|
|
case 'newFile': return t('files.newFileName')
|
|
case 'newFolder': return t('files.newFolderName')
|
|
case 'rename': return t('files.renameTo')
|
|
}
|
|
})
|
|
|
|
async function handleSubmit() {
|
|
if (!inputValue.value.trim()) return
|
|
submitting.value = true
|
|
try {
|
|
switch (props.mode) {
|
|
case 'newFile':
|
|
await filesStore.createFile(inputValue.value.trim())
|
|
message.success(t('files.created'))
|
|
break
|
|
case 'newFolder':
|
|
await filesStore.createDir(inputValue.value.trim(), props.targetPath || undefined)
|
|
message.success(t('files.created'))
|
|
break
|
|
case 'rename':
|
|
if (props.entry) {
|
|
await filesStore.renameEntry(props.entry, inputValue.value.trim())
|
|
message.success(t('files.renamed'))
|
|
}
|
|
break
|
|
}
|
|
emit('update:show', false)
|
|
} catch (err: any) {
|
|
const msg = props.mode === 'rename' ? t('files.renameFailed') : t('files.createFailed')
|
|
message.error(err.message || msg)
|
|
} finally {
|
|
submitting.value = false
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<NModal :show="props.show" preset="dialog" :title="title" @update:show="emit('update:show', false)" style="width: 400px;">
|
|
<NInput
|
|
v-model:value="inputValue"
|
|
:placeholder="placeholder"
|
|
@keydown.enter="handleSubmit"
|
|
autofocus
|
|
/>
|
|
<template #action>
|
|
<NSpace>
|
|
<NButton @click="emit('update:show', false)">{{ t('common.cancel') }}</NButton>
|
|
<NButton type="primary" :loading="submitting" :disabled="!inputValue.trim()" @click="handleSubmit">
|
|
{{ t('common.ok') }}
|
|
</NButton>
|
|
</NSpace>
|
|
</template>
|
|
</NModal>
|
|
</template>
|