UnisKB/ui/src/views/tool/toolStore/InternalDescDrawer.vue

100 lines
2.5 KiB
Vue
Raw Normal View History

2025-05-15 10:21:38 +00:00
<template>
<el-drawer v-model="visibleInternalDesc" size="60%" :append-to-body="true">
<template #header>
<div class="flex align-center" style="margin-left: -8px">
<el-button class="cursor mr-4" link @click.prevent="visibleInternalDesc = false">
<el-icon :size="20">
<Back />
</el-icon>
</el-button>
<h4>详情</h4>
</div>
</template>
<div>
<div class="card-header">
<div class="flex-between">
<div class="title flex align-center">
2025-06-05 09:28:07 +00:00
<el-avatar
2025-06-26 12:25:24 +00:00
v-if="isAppIcon(toolDetail?.icon)"
2025-05-15 10:21:38 +00:00
shape="square"
:size="64"
style="background: none"
class="mr-8"
>
2025-06-26 12:25:24 +00:00
<img :src="toolDetail?.icon" alt="" />
2025-06-05 09:28:07 +00:00
</el-avatar>
<el-avatar
2025-06-26 12:25:24 +00:00
v-else-if="toolDetail?.name"
:name="toolDetail?.name"
2025-05-15 10:21:38 +00:00
pinyinColor
shape="square"
:size="64"
class="mr-8"
/>
<div class="ml-16">
2025-06-26 12:25:24 +00:00
<h3 class="mb-8">{{ toolDetail.name }}</h3>
<el-text type="info" v-if="toolDetail?.desc">
{{ toolDetail.desc }}
2025-05-15 10:21:38 +00:00
</el-text>
</div>
</div>
<div @click.stop>
2025-06-26 12:25:24 +00:00
<el-button type="primary" @click="addInternalTool(toolDetail)">
2025-05-15 10:21:38 +00:00
{{ $t('common.add') }}
</el-button>
</div>
</div>
<div class="mt-16">
<el-text type="info">
<div>{{ $t('common.author') }}: MaxKB</div>
</el-text>
</div>
</div>
<MdPreview
ref="editorRef"
editorId="preview-only"
:modelValue="markdownContent"
style="background: none"
noImgZoomIn
/>
</div>
</el-drawer>
</template>
<script setup lang="ts">
import { ref, watch } from 'vue'
import { cloneDeep } from 'lodash'
2025-05-26 10:10:18 +00:00
import { isAppIcon } from '@/utils/common'
2025-06-26 12:25:24 +00:00
const emit = defineEmits(['refresh', 'addTool'])
2025-05-15 10:21:38 +00:00
const visibleInternalDesc = ref(false)
const markdownContent = ref('')
2025-06-26 12:25:24 +00:00
const toolDetail = ref<any>({})
2025-05-15 10:21:38 +00:00
watch(visibleInternalDesc, (bool) => {
if (!bool) {
markdownContent.value = ''
}
})
const open = (data: any, detail: any) => {
2025-06-26 12:25:24 +00:00
toolDetail.value = detail
2025-05-15 10:21:38 +00:00
if (data) {
markdownContent.value = cloneDeep(data)
}
visibleInternalDesc.value = true
}
2025-06-26 12:25:24 +00:00
const addInternalTool = (data: any) => {
emit('addTool', data)
2025-05-15 10:21:38 +00:00
visibleInternalDesc.value = false
}
defineExpose({
open
})
</script>
<style lang="scss"></style>