Skip to content

Commit 48c59b5

Browse files
committed
fix: click paragraph card
1 parent 371ee61 commit 48c59b5

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

ui/src/components/markdown/MdPreview.vue

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<MdPreview :language="language" noIconfont noPrettier :codeFoldable="false" v-bind="$attrs" />
2+
<MdPreview :language="language" noIconfont noPrettier :codeFoldable="false" v-bind="$attrs" @click.stop="handleClick"/>
33
</template>
44

55
<script setup lang="ts">
@@ -11,6 +11,9 @@ import useStore from '@/stores'
1111
import ZH_TW from '@vavt/cm-extension/dist/locale/zh-TW'
1212
1313
defineOptions({ name: 'MdPreview' })
14+
15+
const emit = defineEmits(['clickPreview'])
16+
1417
const { user } = useStore()
1518
const language = computed(() => user.getLanguage() || getBrowserLang() || '')
1619
config({
@@ -20,6 +23,14 @@ config({
2023
}
2124
}
2225
})
26+
27+
function handleClick(e: MouseEvent) {
28+
if ((e.target as HTMLElement).closest('a') || (e.target as HTMLElement).closest('.md-editor-copy-button')) {
29+
e.stopPropagation()
30+
} else {
31+
emit('clickPreview')
32+
}
33+
}
2334
</script>
2435

2536
<style lang="scss" scoped>

ui/src/views/paragraph/component/ParagraphCard.vue

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
:class="data.is_active ? '' : 'disabled'"
66
@mouseenter="cardEnter()"
77
@mouseleave="cardLeave()"
8-
@click.stop="editParagraph(data)"
8+
@click.stop="handleClickCard(data)"
99
v-loading="loading"
1010
>
1111
<div v-show="show" class="mk-sticky" v-if="!disabled">
@@ -94,6 +94,7 @@
9494
:modelValue="data.content"
9595
class="maxkb-md"
9696
style="background: none"
97+
@clickPreview="handleClickCard(data)"
9798
/>
9899

99100
<ParagraphDialog
@@ -136,7 +137,7 @@ const apiType = computed(() => {
136137
return type as 'systemShare' | 'workspace' | 'systemManage'
137138
})
138139
139-
const emit = defineEmits(['changeState', 'deleteParagraph', 'refresh', 'refreshMigrateParagraph','move'])
140+
const emit = defineEmits(['clickCard','changeState', 'deleteParagraph', 'refresh', 'refreshMigrateParagraph','move'])
140141
const loading = ref(false)
141142
const changeStateloading = ref(false)
142143
const show = ref(false)
@@ -201,6 +202,14 @@ function editParagraph(row: any) {
201202
}
202203
}
203204
205+
function handleClickCard(row: any) {
206+
if (!props.disabled) {
207+
editParagraph(row)
208+
}else {
209+
emit('clickCard')
210+
}
211+
}
212+
204213
function addParagraph(row: any) {
205214
title.value = t('views.paragraph.addParagraph')
206215
ParagraphDialogRef.value.open(row, 'add')

ui/src/views/paragraph/index.vue

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
<!-- 批量操作 -->
9797
<div class="paragraph-card flex w-full" v-if="isBatch === true">
9898
<el-checkbox :value="item.id" />
99-
<ParagraphCard :data="item" class="mb-8 w-full" :disabled="true" />
99+
<ParagraphCard :data="item" class="mb-8 w-full" :disabled="true" @clickCard="toggleSelect(item.id)"/>
100100
</div>
101101
<!-- 非批量操作 -->
102102
<div class="handle paragraph-card flex w-full" :id="item.id" v-else>
@@ -205,6 +205,15 @@ const handleClick = (e: MouseEvent, ele: any) => {
205205
const isBatch = ref(false)
206206
const multipleSelection = ref<any[]>([])
207207
208+
function toggleSelect(id: number) {
209+
const index = multipleSelection.value.indexOf(id)
210+
if (index === -1) {
211+
multipleSelection.value.push(id)
212+
} else {
213+
multipleSelection.value.splice(index, 1)
214+
}
215+
}
216+
208217
const paginationConfig = reactive({
209218
current_page: 1,
210219
page_size: 30,

0 commit comments

Comments
 (0)