mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 01:33:05 +00:00
fix: click paragraph card
This commit is contained in:
parent
371ee61c24
commit
48c59b59a8
|
|
@ -1,5 +1,5 @@
|
|||
<template>
|
||||
<MdPreview :language="language" noIconfont noPrettier :codeFoldable="false" v-bind="$attrs" />
|
||||
<MdPreview :language="language" noIconfont noPrettier :codeFoldable="false" v-bind="$attrs" @click.stop="handleClick"/>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
|
|
@ -11,6 +11,9 @@ import useStore from '@/stores'
|
|||
import ZH_TW from '@vavt/cm-extension/dist/locale/zh-TW'
|
||||
|
||||
defineOptions({ name: 'MdPreview' })
|
||||
|
||||
const emit = defineEmits(['clickPreview'])
|
||||
|
||||
const { user } = useStore()
|
||||
const language = computed(() => user.getLanguage() || getBrowserLang() || '')
|
||||
config({
|
||||
|
|
@ -20,6 +23,14 @@ config({
|
|||
}
|
||||
}
|
||||
})
|
||||
|
||||
function handleClick(e: MouseEvent) {
|
||||
if ((e.target as HTMLElement).closest('a') || (e.target as HTMLElement).closest('.md-editor-copy-button')) {
|
||||
e.stopPropagation()
|
||||
} else {
|
||||
emit('clickPreview')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
:class="data.is_active ? '' : 'disabled'"
|
||||
@mouseenter="cardEnter()"
|
||||
@mouseleave="cardLeave()"
|
||||
@click.stop="editParagraph(data)"
|
||||
@click.stop="handleClickCard(data)"
|
||||
v-loading="loading"
|
||||
>
|
||||
<div v-show="show" class="mk-sticky" v-if="!disabled">
|
||||
|
|
@ -94,6 +94,7 @@
|
|||
:modelValue="data.content"
|
||||
class="maxkb-md"
|
||||
style="background: none"
|
||||
@clickPreview="handleClickCard(data)"
|
||||
/>
|
||||
|
||||
<ParagraphDialog
|
||||
|
|
@ -136,7 +137,7 @@ const apiType = computed(() => {
|
|||
return type as 'systemShare' | 'workspace' | 'systemManage'
|
||||
})
|
||||
|
||||
const emit = defineEmits(['changeState', 'deleteParagraph', 'refresh', 'refreshMigrateParagraph','move'])
|
||||
const emit = defineEmits(['clickCard','changeState', 'deleteParagraph', 'refresh', 'refreshMigrateParagraph','move'])
|
||||
const loading = ref(false)
|
||||
const changeStateloading = ref(false)
|
||||
const show = ref(false)
|
||||
|
|
@ -201,6 +202,14 @@ function editParagraph(row: any) {
|
|||
}
|
||||
}
|
||||
|
||||
function handleClickCard(row: any) {
|
||||
if (!props.disabled) {
|
||||
editParagraph(row)
|
||||
}else {
|
||||
emit('clickCard')
|
||||
}
|
||||
}
|
||||
|
||||
function addParagraph(row: any) {
|
||||
title.value = t('views.paragraph.addParagraph')
|
||||
ParagraphDialogRef.value.open(row, 'add')
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@
|
|||
<!-- 批量操作 -->
|
||||
<div class="paragraph-card flex w-full" v-if="isBatch === true">
|
||||
<el-checkbox :value="item.id" />
|
||||
<ParagraphCard :data="item" class="mb-8 w-full" :disabled="true" />
|
||||
<ParagraphCard :data="item" class="mb-8 w-full" :disabled="true" @clickCard="toggleSelect(item.id)"/>
|
||||
</div>
|
||||
<!-- 非批量操作 -->
|
||||
<div class="handle paragraph-card flex w-full" :id="item.id" v-else>
|
||||
|
|
@ -205,6 +205,15 @@ const handleClick = (e: MouseEvent, ele: any) => {
|
|||
const isBatch = ref(false)
|
||||
const multipleSelection = ref<any[]>([])
|
||||
|
||||
function toggleSelect(id: number) {
|
||||
const index = multipleSelection.value.indexOf(id)
|
||||
if (index === -1) {
|
||||
multipleSelection.value.push(id)
|
||||
} else {
|
||||
multipleSelection.value.splice(index, 1)
|
||||
}
|
||||
}
|
||||
|
||||
const paginationConfig = reactive({
|
||||
current_page: 1,
|
||||
page_size: 30,
|
||||
|
|
|
|||
Loading…
Reference in New Issue