feat(workspace): 增强预览面板功能,支持关闭和折叠操作,优化样式
This commit is contained in:
parent
596eeeaaac
commit
5fb6af8cb8
@ -79,8 +79,14 @@
|
|||||||
>
|
>
|
||||||
<Maximize2 :size="18" />
|
<Maximize2 :size="18" />
|
||||||
</button>
|
</button>
|
||||||
<button v-if="showClose" class="modal-action-btn" @click="$emit('close')" title="关闭">
|
<button
|
||||||
<X :size="18" />
|
v-if="showClose"
|
||||||
|
class="modal-action-btn"
|
||||||
|
@click="$emit('close')"
|
||||||
|
:title="closeTitle"
|
||||||
|
:aria-label="closeTitle"
|
||||||
|
>
|
||||||
|
<component :is="closeIconComponent" :size="18" />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -234,7 +240,7 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, onUnmounted, ref, watch } from 'vue'
|
import { computed, onUnmounted, ref, watch } from 'vue'
|
||||||
import { Code2, Download, Eye, Globe, Maximize2, Pencil, Save, X } from 'lucide-vue-next'
|
import { Code2, Download, Eye, Globe, Maximize2, PanelRightClose, Pencil, Save, X } from 'lucide-vue-next'
|
||||||
import { MdPreview } from 'md-editor-v3'
|
import { MdPreview } from 'md-editor-v3'
|
||||||
import hljs from 'highlight.js/lib/common'
|
import hljs from 'highlight.js/lib/common'
|
||||||
import 'md-editor-v3/lib/preview.css'
|
import 'md-editor-v3/lib/preview.css'
|
||||||
@ -274,6 +280,11 @@ const props = defineProps({
|
|||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
},
|
},
|
||||||
|
closeVariant: {
|
||||||
|
type: String,
|
||||||
|
default: 'close',
|
||||||
|
validator: (value) => ['close', 'collapse-right'].includes(value)
|
||||||
|
},
|
||||||
fullHeight: {
|
fullHeight: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
@ -300,6 +311,8 @@ const emit = defineEmits(['close', 'download', 'save'])
|
|||||||
|
|
||||||
const themeStore = useThemeStore()
|
const themeStore = useThemeStore()
|
||||||
const theme = computed(() => (themeStore.isDark ? 'dark' : 'light'))
|
const theme = computed(() => (themeStore.isDark ? 'dark' : 'light'))
|
||||||
|
const closeTitle = computed(() => (props.closeVariant === 'collapse-right' ? '收起预览面板' : '关闭预览'))
|
||||||
|
const closeIconComponent = computed(() => (props.closeVariant === 'collapse-right' ? PanelRightClose : X))
|
||||||
const htmlPreviewMode = ref('render')
|
const htmlPreviewMode = ref('render')
|
||||||
const editMode = ref('preview')
|
const editMode = ref('preview')
|
||||||
const draftContent = ref('')
|
const draftContent = ref('')
|
||||||
|
|||||||
@ -82,6 +82,7 @@
|
|||||||
:filePath="currentFilePath"
|
:filePath="currentFilePath"
|
||||||
:fullHeight="true"
|
:fullHeight="true"
|
||||||
:showClose="true"
|
:showClose="true"
|
||||||
|
closeVariant="collapse-right"
|
||||||
:showDownload="true"
|
:showDownload="true"
|
||||||
:showFullscreen="true"
|
:showFullscreen="true"
|
||||||
@download="downloadFile"
|
@download="downloadFile"
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
:file-path="filePath"
|
:file-path="filePath"
|
||||||
:show-download="false"
|
:show-download="false"
|
||||||
:show-close="true"
|
:show-close="true"
|
||||||
|
close-variant="collapse-right"
|
||||||
:show-fullscreen="true"
|
:show-fullscreen="true"
|
||||||
:full-height="true"
|
:full-height="true"
|
||||||
:editable="editable"
|
:editable="editable"
|
||||||
|
|||||||
@ -95,7 +95,7 @@ defineEmits(['select-personal', 'select-database', 'select-path'])
|
|||||||
min-width: 0;
|
min-width: 0;
|
||||||
padding: 14px 10px;
|
padding: 14px 10px;
|
||||||
border-right: 1px solid var(--gray-100);
|
border-right: 1px solid var(--gray-100);
|
||||||
background: var(--gray-25);
|
background: var(--gray-0);
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -566,12 +566,20 @@ onUnmounted(() => {
|
|||||||
revokePreviewObjectUrl()
|
revokePreviewObjectUrl()
|
||||||
})
|
})
|
||||||
|
|
||||||
watch(useInlinePreview, (isInline) => {
|
watch(useInlinePreview, (isInline, wasInline) => {
|
||||||
if (!previewFile.value) {
|
if (!previewFile.value) {
|
||||||
previewModalVisible.value = false
|
previewModalVisible.value = false
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
previewModalVisible.value = !isInline
|
|
||||||
|
if (isInline) {
|
||||||
|
previewModalVisible.value = false
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wasInline) {
|
||||||
|
closePreview()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user