fix: restore dashboard runtime home
This commit is contained in:
@@ -38,6 +38,10 @@ const widgetComponents: Record<
|
||||
'announcement-list': defineAsyncComponent(
|
||||
() => import('./widgets/AnnouncementList.vue'),
|
||||
),
|
||||
'approval-center': defineAsyncComponent(
|
||||
() => import('./widgets/ApprovalCenter.vue'),
|
||||
),
|
||||
'my-apps': defineAsyncComponent(() => import('./widgets/MyApps.vue')),
|
||||
'notice-list': defineAsyncComponent(() => import('./widgets/NoticeList.vue')),
|
||||
'quick-links': defineAsyncComponent(() => import('./widgets/QuickLinks.vue')),
|
||||
'server-monitor': defineAsyncComponent(
|
||||
|
||||
@@ -15,18 +15,34 @@ const props = defineProps<{
|
||||
widget: DashboardWidget;
|
||||
}>();
|
||||
|
||||
type AppLink = Pick<ApplicationListItem, 'code' | 'icon' | 'id' | 'name'> & {
|
||||
path?: string;
|
||||
};
|
||||
|
||||
// 应用列表
|
||||
const appList = ref<ApplicationListItem[]>([]);
|
||||
const appList = ref<AppLink[]>([]);
|
||||
const loading = ref(false);
|
||||
|
||||
const configuredApps = computed<AppLink[]>(() => props.widget.props.apps || []);
|
||||
|
||||
// 最大显示数量
|
||||
const maxCount = computed(() => props.widget.props.maxCount || 8);
|
||||
|
||||
// 显示的应用列表
|
||||
const displayApps = computed(() => appList.value.slice(0, maxCount.value));
|
||||
const displayApps = computed(() =>
|
||||
(configuredApps.value.length > 0 ? configuredApps.value : appList.value).slice(
|
||||
0,
|
||||
maxCount.value,
|
||||
),
|
||||
);
|
||||
|
||||
// 加载已发布的应用列表
|
||||
const loadApps = async () => {
|
||||
if (configuredApps.value.length > 0) {
|
||||
appList.value = configuredApps.value;
|
||||
return;
|
||||
}
|
||||
|
||||
loading.value = true;
|
||||
try {
|
||||
const res = await getApplicationListApi({
|
||||
@@ -43,8 +59,13 @@ const loadApps = async () => {
|
||||
};
|
||||
|
||||
// 点击应用
|
||||
const handleClick = (app: ApplicationListItem) => {
|
||||
window.open(`${window.location.origin}/app/${app.code}`, '_blank');
|
||||
const handleClick = (app: AppLink) => {
|
||||
const path = app.path || `/app/${app.code}`;
|
||||
if (path.startsWith('http://') || path.startsWith('https://')) {
|
||||
window.open(path, '_blank');
|
||||
return;
|
||||
}
|
||||
window.open(`${window.location.origin}${path}`, '_blank');
|
||||
};
|
||||
|
||||
// 点击更多
|
||||
|
||||
Reference in New Issue
Block a user