feat(projects): 工作台小组件设计
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { computed, inject } from 'vue';
|
||||
|
||||
defineOptions({ name: 'WorkbenchModuleCard' });
|
||||
|
||||
// 由 src/views/workbench/index.vue provide 的"进入编辑模式"动作;
|
||||
// 卡片正常态的"编辑布局"按钮直接调它,避免每个 widget 都透传 emit
|
||||
const enterEditing = inject<(() => void) | null>('workbenchEnterEditing', null);
|
||||
|
||||
interface Props {
|
||||
title: string;
|
||||
icon?: string;
|
||||
@@ -13,6 +17,8 @@ interface Props {
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
icon: undefined,
|
||||
badgeCount: undefined,
|
||||
editing: false,
|
||||
collapsed: false,
|
||||
hasSettings: false
|
||||
@@ -58,6 +64,9 @@ const showBody = computed(() => !props.collapsed);
|
||||
<ElButton v-if="!editing" link size="small" title="跳详情" @click="emit('navigate')">
|
||||
<SvgIcon icon="mdi:open-in-new" />
|
||||
</ElButton>
|
||||
<ElButton v-if="!editing && enterEditing" link size="small" title="编辑工作台布局" @click="enterEditing()">
|
||||
<SvgIcon icon="mdi:view-dashboard-edit-outline" />
|
||||
</ElButton>
|
||||
<ElButton v-if="editing" link size="small" title="隐藏此模块" type="danger" @click="emit('hide')">
|
||||
<SvgIcon icon="mdi:close" />
|
||||
</ElButton>
|
||||
|
||||
Reference in New Issue
Block a user