feat: editable description field

This commit is contained in:
putyy
2025-11-30 12:01:06 +08:00
committed by putyy
parent 51c43564b6
commit 00b4bf4068
4 changed files with 76 additions and 14 deletions

View File

@@ -49,6 +49,7 @@ declare module 'vue' {
RouterView: typeof import('vue-router')['RouterView']
Screen: typeof import('./src/components/Screen.vue')['default']
ShowLoading: typeof import('./src/components/ShowLoading.vue')['default']
ShowOrEdit: typeof import('./src/components/ShowOrEdit.vue')['default']
Sider: typeof import('./src/components/layout/Sider.vue')['default']
}
}

View File

@@ -8,3 +8,11 @@
width: 100vw;
height: 100vh;
}
.ellipsis-2 {
display: -webkit-box;
overflow: hidden;
text-overflow: ellipsis;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}

View File

@@ -0,0 +1,59 @@
<template>
<div
class="min-h-6"
@click="handleOnClick"
>
<n-input
v-if="isEdit"
ref="inputRef"
:value="inputValue"
@update:value="v => inputValue = v"
@change="handleChange"
@blur="handleChange"
/>
<n-tooltip
v-else
trigger="hover"
placement="top"
>
<template #trigger>
<div class="ellipsis-2">{{ inputValue }}</div>
</template>
<div class="ellipsis-2">{{ inputValue }}</div>
</n-tooltip>
</div>
</template>
<script setup lang="ts">
import { ref, nextTick, watch } from 'vue'
import type { InputInst } from 'naive-ui'
interface OnUpdateValue {
(value: string): void
}
const props = defineProps<{
value: string | number
onUpdateValue?: OnUpdateValue
}>()
const isEdit = ref(false)
const inputRef = ref<InputInst | null>(null)
const inputValue = ref(String(props.value))
watch(
() => props.value,
v => inputValue.value = String(v)
)
function handleOnClick() {
isEdit.value = true
nextTick(() => inputRef.value?.focus())
}
function handleChange() {
props.onUpdateValue?.(String(inputValue.value))
isEdit.value = false
}
</script>

View File

@@ -151,6 +151,7 @@ import ImportJson from "@/components/ImportJson.vue"
import {useEventStore} from "@/stores/event"
import {BrowserOpenURL, ClipboardSetText} from "../../wailsjs/runtime"
import Password from "@/components/Password.vue"
import ShowOrEdit from "@/components/ShowOrEdit.vue"
import {useI18n} from 'vue-i18n'
import {
DownloadOutline,
@@ -369,10 +370,12 @@ const columns = ref<any[]>([
key: "Description",
width: 150,
render: (row: appType.MediaInfo, index: number) => {
const d = h("div", {class: "ellipsis-2",}, row.Description)
return h(NTooltip, {trigger: 'hover', placement: 'top'}, {
trigger: () => d,
default: () => d
return h(ShowOrEdit, {
value: row.Description,
onUpdateValue(v: string) {
data.value[index].Description = v
cacheData()
}
})
}
},
@@ -962,12 +965,3 @@ const checkLoading = () => {
}, 6000)
}
</script>
<style>
.ellipsis-2 {
display: -webkit-box;
overflow: hidden;
text-overflow: ellipsis;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
</style>