feat: add click-to-click event support to the WorkenchProject and WorkenchQuickNav components (#4831)
* feat(@vben/common-ui): add click event emission to WorkbenchProject and WorkbenchQuickNav components * feat: add navigation and project link functionality to dashboard workspace * feat: add URL property to WorkbenchProjectItem and WorkbenchQuickNavItem for enhanced navigation --------- Co-authored-by: XiaoyuDing <xiaoyuding@keymedbio.com>pull/48/MERGE
parent
8f1e397077
commit
da7d61b160
|
@ -7,6 +7,7 @@ import type {
|
||||||
} from '@vben/common-ui';
|
} from '@vben/common-ui';
|
||||||
|
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
|
import { useRouter } from 'vue-router';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
AnalysisChartCard,
|
AnalysisChartCard,
|
||||||
|
@ -18,11 +19,15 @@ import {
|
||||||
} from '@vben/common-ui';
|
} from '@vben/common-ui';
|
||||||
import { preferences } from '@vben/preferences';
|
import { preferences } from '@vben/preferences';
|
||||||
import { useUserStore } from '@vben/stores';
|
import { useUserStore } from '@vben/stores';
|
||||||
|
import { openWindow } from '@vben/utils';
|
||||||
|
|
||||||
import AnalyticsVisitsSource from '../analytics/analytics-visits-source.vue';
|
import AnalyticsVisitsSource from '../analytics/analytics-visits-source.vue';
|
||||||
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
|
|
||||||
|
// 这是一个示例数据,实际项目中需要根据实际情况进行调整
|
||||||
|
// url 也可以是内部路由,在 navTo 方法中识别处理,进行内部跳转
|
||||||
|
// 例如:url: /dashboard/workspace
|
||||||
const projectItems: WorkbenchProjectItem[] = [
|
const projectItems: WorkbenchProjectItem[] = [
|
||||||
{
|
{
|
||||||
color: '',
|
color: '',
|
||||||
|
@ -31,6 +36,7 @@ const projectItems: WorkbenchProjectItem[] = [
|
||||||
group: '开源组',
|
group: '开源组',
|
||||||
icon: 'carbon:logo-github',
|
icon: 'carbon:logo-github',
|
||||||
title: 'Github',
|
title: 'Github',
|
||||||
|
url: 'https://github.com',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
color: '#3fb27f',
|
color: '#3fb27f',
|
||||||
|
@ -39,6 +45,7 @@ const projectItems: WorkbenchProjectItem[] = [
|
||||||
group: '算法组',
|
group: '算法组',
|
||||||
icon: 'ion:logo-vue',
|
icon: 'ion:logo-vue',
|
||||||
title: 'Vue',
|
title: 'Vue',
|
||||||
|
url: 'https://vuejs.org',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
color: '#e18525',
|
color: '#e18525',
|
||||||
|
@ -47,6 +54,7 @@ const projectItems: WorkbenchProjectItem[] = [
|
||||||
group: '上班摸鱼',
|
group: '上班摸鱼',
|
||||||
icon: 'ion:logo-html5',
|
icon: 'ion:logo-html5',
|
||||||
title: 'Html5',
|
title: 'Html5',
|
||||||
|
url: 'https://developer.mozilla.org/zh-CN/docs/Web/HTML',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
color: '#bf0c2c',
|
color: '#bf0c2c',
|
||||||
|
@ -55,6 +63,7 @@ const projectItems: WorkbenchProjectItem[] = [
|
||||||
group: 'UI',
|
group: 'UI',
|
||||||
icon: 'ion:logo-angular',
|
icon: 'ion:logo-angular',
|
||||||
title: 'Angular',
|
title: 'Angular',
|
||||||
|
url: 'https://angular.io',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
color: '#00d8ff',
|
color: '#00d8ff',
|
||||||
|
@ -63,6 +72,7 @@ const projectItems: WorkbenchProjectItem[] = [
|
||||||
group: '技术牛',
|
group: '技术牛',
|
||||||
icon: 'bx:bxl-react',
|
icon: 'bx:bxl-react',
|
||||||
title: 'React',
|
title: 'React',
|
||||||
|
url: 'https://reactjs.org',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
color: '#EBD94E',
|
color: '#EBD94E',
|
||||||
|
@ -71,39 +81,47 @@ const projectItems: WorkbenchProjectItem[] = [
|
||||||
group: '架构组',
|
group: '架构组',
|
||||||
icon: 'ion:logo-javascript',
|
icon: 'ion:logo-javascript',
|
||||||
title: 'Js',
|
title: 'Js',
|
||||||
|
url: 'https://developer.mozilla.org/zh-CN/docs/Web/JavaScript',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// 同样,这里的 url 也可以使用以 http 开头的外部链接
|
||||||
const quickNavItems: WorkbenchQuickNavItem[] = [
|
const quickNavItems: WorkbenchQuickNavItem[] = [
|
||||||
{
|
{
|
||||||
color: '#1fdaca',
|
color: '#1fdaca',
|
||||||
icon: 'ion:home-outline',
|
icon: 'ion:home-outline',
|
||||||
title: '首页',
|
title: '首页',
|
||||||
|
url: '/',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
color: '#bf0c2c',
|
color: '#bf0c2c',
|
||||||
icon: 'ion:grid-outline',
|
icon: 'ion:grid-outline',
|
||||||
title: '仪表盘',
|
title: '仪表盘',
|
||||||
|
url: '/dashboard',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
color: '#e18525',
|
color: '#e18525',
|
||||||
icon: 'ion:layers-outline',
|
icon: 'ion:layers-outline',
|
||||||
title: '组件',
|
title: '组件',
|
||||||
|
url: '/demos/features/icons',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
color: '#3fb27f',
|
color: '#3fb27f',
|
||||||
icon: 'ion:settings-outline',
|
icon: 'ion:settings-outline',
|
||||||
title: '系统管理',
|
title: '系统管理',
|
||||||
|
url: '/demos/features/login-expired', // 这里的 URL 是示例,实际项目中需要根据实际情况进行调整
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
color: '#4daf1bc9',
|
color: '#4daf1bc9',
|
||||||
icon: 'ion:key-outline',
|
icon: 'ion:key-outline',
|
||||||
title: '权限管理',
|
title: '权限管理',
|
||||||
|
url: '/demos/access/page-control',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
color: '#00d8ff',
|
color: '#00d8ff',
|
||||||
icon: 'ion:bar-chart-outline',
|
icon: 'ion:bar-chart-outline',
|
||||||
title: '图表',
|
title: '图表',
|
||||||
|
url: '/analytics',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -195,6 +213,24 @@ const trendItems: WorkbenchTrendItem[] = [
|
||||||
title: 'Vben',
|
title: 'Vben',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
|
// 这是一个示例方法,实际项目中需要根据实际情况进行调整
|
||||||
|
// This is a sample method, adjust according to the actual project requirements
|
||||||
|
function navTo(nav: WorkbenchProjectItem | WorkbenchQuickNavItem) {
|
||||||
|
if (nav.url?.startsWith('http')) {
|
||||||
|
openWindow(nav.url);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (nav.url?.startsWith('/')) {
|
||||||
|
router.push(nav.url).catch((error) => {
|
||||||
|
console.error('Navigation failed:', error);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
console.warn(`Unknown URL for navigation item: ${nav.title} -> ${nav.url}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -210,7 +246,7 @@ const trendItems: WorkbenchTrendItem[] = [
|
||||||
|
|
||||||
<div class="mt-5 flex flex-col lg:flex-row">
|
<div class="mt-5 flex flex-col lg:flex-row">
|
||||||
<div class="mr-4 w-full lg:w-3/5">
|
<div class="mr-4 w-full lg:w-3/5">
|
||||||
<WorkbenchProject :items="projectItems" title="项目" />
|
<WorkbenchProject :items="projectItems" title="项目" @click="navTo" />
|
||||||
<WorkbenchTrends :items="trendItems" class="mt-5" title="最新动态" />
|
<WorkbenchTrends :items="trendItems" class="mt-5" title="最新动态" />
|
||||||
</div>
|
</div>
|
||||||
<div class="w-full lg:w-2/5">
|
<div class="w-full lg:w-2/5">
|
||||||
|
@ -218,6 +254,7 @@ const trendItems: WorkbenchTrendItem[] = [
|
||||||
:items="quickNavItems"
|
:items="quickNavItems"
|
||||||
class="mt-5 lg:mt-0"
|
class="mt-5 lg:mt-0"
|
||||||
title="快捷导航"
|
title="快捷导航"
|
||||||
|
@click="navTo"
|
||||||
/>
|
/>
|
||||||
<WorkbenchTodo :items="todoItems" class="mt-5" title="待办事项" />
|
<WorkbenchTodo :items="todoItems" class="mt-5" title="待办事项" />
|
||||||
<AnalysisChartCard class="mt-5" title="访问来源">
|
<AnalysisChartCard class="mt-5" title="访问来源">
|
||||||
|
|
|
@ -7,6 +7,7 @@ import type {
|
||||||
} from '@vben/common-ui';
|
} from '@vben/common-ui';
|
||||||
|
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
|
import { useRouter } from 'vue-router';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
AnalysisChartCard,
|
AnalysisChartCard,
|
||||||
|
@ -18,11 +19,15 @@ import {
|
||||||
} from '@vben/common-ui';
|
} from '@vben/common-ui';
|
||||||
import { preferences } from '@vben/preferences';
|
import { preferences } from '@vben/preferences';
|
||||||
import { useUserStore } from '@vben/stores';
|
import { useUserStore } from '@vben/stores';
|
||||||
|
import { openWindow } from '@vben/utils';
|
||||||
|
|
||||||
import AnalyticsVisitsSource from '../analytics/analytics-visits-source.vue';
|
import AnalyticsVisitsSource from '../analytics/analytics-visits-source.vue';
|
||||||
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
|
|
||||||
|
// 这是一个示例数据,实际项目中需要根据实际情况进行调整
|
||||||
|
// url 也可以是内部路由,在 navTo 方法中识别处理,进行内部跳转
|
||||||
|
// 例如:url: /dashboard/workspace
|
||||||
const projectItems: WorkbenchProjectItem[] = [
|
const projectItems: WorkbenchProjectItem[] = [
|
||||||
{
|
{
|
||||||
color: '',
|
color: '',
|
||||||
|
@ -31,6 +36,7 @@ const projectItems: WorkbenchProjectItem[] = [
|
||||||
group: '开源组',
|
group: '开源组',
|
||||||
icon: 'carbon:logo-github',
|
icon: 'carbon:logo-github',
|
||||||
title: 'Github',
|
title: 'Github',
|
||||||
|
url: 'https://github.com',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
color: '#3fb27f',
|
color: '#3fb27f',
|
||||||
|
@ -39,6 +45,7 @@ const projectItems: WorkbenchProjectItem[] = [
|
||||||
group: '算法组',
|
group: '算法组',
|
||||||
icon: 'ion:logo-vue',
|
icon: 'ion:logo-vue',
|
||||||
title: 'Vue',
|
title: 'Vue',
|
||||||
|
url: 'https://vuejs.org',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
color: '#e18525',
|
color: '#e18525',
|
||||||
|
@ -47,6 +54,7 @@ const projectItems: WorkbenchProjectItem[] = [
|
||||||
group: '上班摸鱼',
|
group: '上班摸鱼',
|
||||||
icon: 'ion:logo-html5',
|
icon: 'ion:logo-html5',
|
||||||
title: 'Html5',
|
title: 'Html5',
|
||||||
|
url: 'https://developer.mozilla.org/zh-CN/docs/Web/HTML',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
color: '#bf0c2c',
|
color: '#bf0c2c',
|
||||||
|
@ -55,6 +63,7 @@ const projectItems: WorkbenchProjectItem[] = [
|
||||||
group: 'UI',
|
group: 'UI',
|
||||||
icon: 'ion:logo-angular',
|
icon: 'ion:logo-angular',
|
||||||
title: 'Angular',
|
title: 'Angular',
|
||||||
|
url: 'https://angular.io',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
color: '#00d8ff',
|
color: '#00d8ff',
|
||||||
|
@ -63,6 +72,7 @@ const projectItems: WorkbenchProjectItem[] = [
|
||||||
group: '技术牛',
|
group: '技术牛',
|
||||||
icon: 'bx:bxl-react',
|
icon: 'bx:bxl-react',
|
||||||
title: 'React',
|
title: 'React',
|
||||||
|
url: 'https://reactjs.org',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
color: '#EBD94E',
|
color: '#EBD94E',
|
||||||
|
@ -71,39 +81,47 @@ const projectItems: WorkbenchProjectItem[] = [
|
||||||
group: '架构组',
|
group: '架构组',
|
||||||
icon: 'ion:logo-javascript',
|
icon: 'ion:logo-javascript',
|
||||||
title: 'Js',
|
title: 'Js',
|
||||||
|
url: 'https://developer.mozilla.org/zh-CN/docs/Web/JavaScript',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// 同样,这里的 url 也可以使用以 http 开头的外部链接
|
||||||
const quickNavItems: WorkbenchQuickNavItem[] = [
|
const quickNavItems: WorkbenchQuickNavItem[] = [
|
||||||
{
|
{
|
||||||
color: '#1fdaca',
|
color: '#1fdaca',
|
||||||
icon: 'ion:home-outline',
|
icon: 'ion:home-outline',
|
||||||
title: '首页',
|
title: '首页',
|
||||||
|
url: '/',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
color: '#bf0c2c',
|
color: '#bf0c2c',
|
||||||
icon: 'ion:grid-outline',
|
icon: 'ion:grid-outline',
|
||||||
title: '仪表盘',
|
title: '仪表盘',
|
||||||
|
url: '/dashboard',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
color: '#e18525',
|
color: '#e18525',
|
||||||
icon: 'ion:layers-outline',
|
icon: 'ion:layers-outline',
|
||||||
title: '组件',
|
title: '组件',
|
||||||
|
url: '/demos/features/icons',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
color: '#3fb27f',
|
color: '#3fb27f',
|
||||||
icon: 'ion:settings-outline',
|
icon: 'ion:settings-outline',
|
||||||
title: '系统管理',
|
title: '系统管理',
|
||||||
|
url: '/demos/features/login-expired', // 这里的 URL 是示例,实际项目中需要根据实际情况进行调整
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
color: '#4daf1bc9',
|
color: '#4daf1bc9',
|
||||||
icon: 'ion:key-outline',
|
icon: 'ion:key-outline',
|
||||||
title: '权限管理',
|
title: '权限管理',
|
||||||
|
url: '/demos/access/page-control',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
color: '#00d8ff',
|
color: '#00d8ff',
|
||||||
icon: 'ion:bar-chart-outline',
|
icon: 'ion:bar-chart-outline',
|
||||||
title: '图表',
|
title: '图表',
|
||||||
|
url: '/analytics',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -195,6 +213,24 @@ const trendItems: WorkbenchTrendItem[] = [
|
||||||
title: 'Vben',
|
title: 'Vben',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
|
// 这是一个示例方法,实际项目中需要根据实际情况进行调整
|
||||||
|
// This is a sample method, adjust according to the actual project requirements
|
||||||
|
function navTo(nav: WorkbenchProjectItem | WorkbenchQuickNavItem) {
|
||||||
|
if (nav.url?.startsWith('http')) {
|
||||||
|
openWindow(nav.url);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (nav.url?.startsWith('/')) {
|
||||||
|
router.push(nav.url).catch((error) => {
|
||||||
|
console.error('Navigation failed:', error);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
console.warn(`Unknown URL for navigation item: ${nav.title} -> ${nav.url}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -210,7 +246,7 @@ const trendItems: WorkbenchTrendItem[] = [
|
||||||
|
|
||||||
<div class="mt-5 flex flex-col lg:flex-row">
|
<div class="mt-5 flex flex-col lg:flex-row">
|
||||||
<div class="mr-4 w-full lg:w-3/5">
|
<div class="mr-4 w-full lg:w-3/5">
|
||||||
<WorkbenchProject :items="projectItems" title="项目" />
|
<WorkbenchProject :items="projectItems" title="项目" @click="navTo" />
|
||||||
<WorkbenchTrends :items="trendItems" class="mt-5" title="最新动态" />
|
<WorkbenchTrends :items="trendItems" class="mt-5" title="最新动态" />
|
||||||
</div>
|
</div>
|
||||||
<div class="w-full lg:w-2/5">
|
<div class="w-full lg:w-2/5">
|
||||||
|
@ -218,6 +254,7 @@ const trendItems: WorkbenchTrendItem[] = [
|
||||||
:items="quickNavItems"
|
:items="quickNavItems"
|
||||||
class="mt-5 lg:mt-0"
|
class="mt-5 lg:mt-0"
|
||||||
title="快捷导航"
|
title="快捷导航"
|
||||||
|
@click="navTo"
|
||||||
/>
|
/>
|
||||||
<WorkbenchTodo :items="todoItems" class="mt-5" title="待办事项" />
|
<WorkbenchTodo :items="todoItems" class="mt-5" title="待办事项" />
|
||||||
<AnalysisChartCard class="mt-5" title="访问来源">
|
<AnalysisChartCard class="mt-5" title="访问来源">
|
||||||
|
|
|
@ -7,6 +7,7 @@ import type {
|
||||||
} from '@vben/common-ui';
|
} from '@vben/common-ui';
|
||||||
|
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
|
import { useRouter } from 'vue-router';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
AnalysisChartCard,
|
AnalysisChartCard,
|
||||||
|
@ -18,11 +19,15 @@ import {
|
||||||
} from '@vben/common-ui';
|
} from '@vben/common-ui';
|
||||||
import { preferences } from '@vben/preferences';
|
import { preferences } from '@vben/preferences';
|
||||||
import { useUserStore } from '@vben/stores';
|
import { useUserStore } from '@vben/stores';
|
||||||
|
import { openWindow } from '@vben/utils';
|
||||||
|
|
||||||
import AnalyticsVisitsSource from '../analytics/analytics-visits-source.vue';
|
import AnalyticsVisitsSource from '../analytics/analytics-visits-source.vue';
|
||||||
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
|
|
||||||
|
// 这是一个示例数据,实际项目中需要根据实际情况进行调整
|
||||||
|
// url 也可以是内部路由,在 navTo 方法中识别处理,进行内部跳转
|
||||||
|
// 例如:url: /dashboard/workspace
|
||||||
const projectItems: WorkbenchProjectItem[] = [
|
const projectItems: WorkbenchProjectItem[] = [
|
||||||
{
|
{
|
||||||
color: '',
|
color: '',
|
||||||
|
@ -31,6 +36,7 @@ const projectItems: WorkbenchProjectItem[] = [
|
||||||
group: '开源组',
|
group: '开源组',
|
||||||
icon: 'carbon:logo-github',
|
icon: 'carbon:logo-github',
|
||||||
title: 'Github',
|
title: 'Github',
|
||||||
|
url: 'https://github.com',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
color: '#3fb27f',
|
color: '#3fb27f',
|
||||||
|
@ -39,6 +45,7 @@ const projectItems: WorkbenchProjectItem[] = [
|
||||||
group: '算法组',
|
group: '算法组',
|
||||||
icon: 'ion:logo-vue',
|
icon: 'ion:logo-vue',
|
||||||
title: 'Vue',
|
title: 'Vue',
|
||||||
|
url: 'https://vuejs.org',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
color: '#e18525',
|
color: '#e18525',
|
||||||
|
@ -47,6 +54,7 @@ const projectItems: WorkbenchProjectItem[] = [
|
||||||
group: '上班摸鱼',
|
group: '上班摸鱼',
|
||||||
icon: 'ion:logo-html5',
|
icon: 'ion:logo-html5',
|
||||||
title: 'Html5',
|
title: 'Html5',
|
||||||
|
url: 'https://developer.mozilla.org/zh-CN/docs/Web/HTML',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
color: '#bf0c2c',
|
color: '#bf0c2c',
|
||||||
|
@ -55,6 +63,7 @@ const projectItems: WorkbenchProjectItem[] = [
|
||||||
group: 'UI',
|
group: 'UI',
|
||||||
icon: 'ion:logo-angular',
|
icon: 'ion:logo-angular',
|
||||||
title: 'Angular',
|
title: 'Angular',
|
||||||
|
url: 'https://angular.io',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
color: '#00d8ff',
|
color: '#00d8ff',
|
||||||
|
@ -63,6 +72,7 @@ const projectItems: WorkbenchProjectItem[] = [
|
||||||
group: '技术牛',
|
group: '技术牛',
|
||||||
icon: 'bx:bxl-react',
|
icon: 'bx:bxl-react',
|
||||||
title: 'React',
|
title: 'React',
|
||||||
|
url: 'https://reactjs.org',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
color: '#EBD94E',
|
color: '#EBD94E',
|
||||||
|
@ -71,39 +81,47 @@ const projectItems: WorkbenchProjectItem[] = [
|
||||||
group: '架构组',
|
group: '架构组',
|
||||||
icon: 'ion:logo-javascript',
|
icon: 'ion:logo-javascript',
|
||||||
title: 'Js',
|
title: 'Js',
|
||||||
|
url: 'https://developer.mozilla.org/zh-CN/docs/Web/JavaScript',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// 同样,这里的 url 也可以使用以 http 开头的外部链接
|
||||||
const quickNavItems: WorkbenchQuickNavItem[] = [
|
const quickNavItems: WorkbenchQuickNavItem[] = [
|
||||||
{
|
{
|
||||||
color: '#1fdaca',
|
color: '#1fdaca',
|
||||||
icon: 'ion:home-outline',
|
icon: 'ion:home-outline',
|
||||||
title: '首页',
|
title: '首页',
|
||||||
|
url: '/',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
color: '#bf0c2c',
|
color: '#bf0c2c',
|
||||||
icon: 'ion:grid-outline',
|
icon: 'ion:grid-outline',
|
||||||
title: '仪表盘',
|
title: '仪表盘',
|
||||||
|
url: '/dashboard',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
color: '#e18525',
|
color: '#e18525',
|
||||||
icon: 'ion:layers-outline',
|
icon: 'ion:layers-outline',
|
||||||
title: '组件',
|
title: '组件',
|
||||||
|
url: '/demos/features/icons',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
color: '#3fb27f',
|
color: '#3fb27f',
|
||||||
icon: 'ion:settings-outline',
|
icon: 'ion:settings-outline',
|
||||||
title: '系统管理',
|
title: '系统管理',
|
||||||
|
url: '/demos/features/login-expired', // 这里的 URL 是示例,实际项目中需要根据实际情况进行调整
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
color: '#4daf1bc9',
|
color: '#4daf1bc9',
|
||||||
icon: 'ion:key-outline',
|
icon: 'ion:key-outline',
|
||||||
title: '权限管理',
|
title: '权限管理',
|
||||||
|
url: '/demos/access/page-control',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
color: '#00d8ff',
|
color: '#00d8ff',
|
||||||
icon: 'ion:bar-chart-outline',
|
icon: 'ion:bar-chart-outline',
|
||||||
title: '图表',
|
title: '图表',
|
||||||
|
url: '/analytics',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -195,6 +213,24 @@ const trendItems: WorkbenchTrendItem[] = [
|
||||||
title: 'Vben',
|
title: 'Vben',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
|
// 这是一个示例方法,实际项目中需要根据实际情况进行调整
|
||||||
|
// This is a sample method, adjust according to the actual project requirements
|
||||||
|
function navTo(nav: WorkbenchProjectItem | WorkbenchQuickNavItem) {
|
||||||
|
if (nav.url?.startsWith('http')) {
|
||||||
|
openWindow(nav.url);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (nav.url?.startsWith('/')) {
|
||||||
|
router.push(nav.url).catch((error) => {
|
||||||
|
console.error('Navigation failed:', error);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
console.warn(`Unknown URL for navigation item: ${nav.title} -> ${nav.url}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -210,7 +246,7 @@ const trendItems: WorkbenchTrendItem[] = [
|
||||||
|
|
||||||
<div class="mt-5 flex flex-col lg:flex-row">
|
<div class="mt-5 flex flex-col lg:flex-row">
|
||||||
<div class="mr-4 w-full lg:w-3/5">
|
<div class="mr-4 w-full lg:w-3/5">
|
||||||
<WorkbenchProject :items="projectItems" title="项目" />
|
<WorkbenchProject :items="projectItems" title="项目" @click="navTo" />
|
||||||
<WorkbenchTrends :items="trendItems" class="mt-5" title="最新动态" />
|
<WorkbenchTrends :items="trendItems" class="mt-5" title="最新动态" />
|
||||||
</div>
|
</div>
|
||||||
<div class="w-full lg:w-2/5">
|
<div class="w-full lg:w-2/5">
|
||||||
|
@ -218,6 +254,7 @@ const trendItems: WorkbenchTrendItem[] = [
|
||||||
:items="quickNavItems"
|
:items="quickNavItems"
|
||||||
class="mt-5 lg:mt-0"
|
class="mt-5 lg:mt-0"
|
||||||
title="快捷导航"
|
title="快捷导航"
|
||||||
|
@click="navTo"
|
||||||
/>
|
/>
|
||||||
<WorkbenchTodo :items="todoItems" class="mt-5" title="待办事项" />
|
<WorkbenchTodo :items="todoItems" class="mt-5" title="待办事项" />
|
||||||
<AnalysisChartCard class="mt-5" title="访问来源">
|
<AnalysisChartCard class="mt-5" title="访问来源">
|
||||||
|
|
|
@ -15,6 +15,7 @@ interface WorkbenchProjectItem {
|
||||||
group: string;
|
group: string;
|
||||||
icon: Component | string;
|
icon: Component | string;
|
||||||
title: string;
|
title: string;
|
||||||
|
url?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface WorkbenchTrendItem {
|
interface WorkbenchTrendItem {
|
||||||
|
@ -35,6 +36,7 @@ interface WorkbenchQuickNavItem {
|
||||||
color?: string;
|
color?: string;
|
||||||
icon: Component | string;
|
icon: Component | string;
|
||||||
title: string;
|
title: string;
|
||||||
|
url?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type {
|
export type {
|
||||||
|
|
|
@ -21,6 +21,8 @@ defineOptions({
|
||||||
withDefaults(defineProps<Props>(), {
|
withDefaults(defineProps<Props>(), {
|
||||||
items: () => [],
|
items: () => [],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
defineEmits(['click']);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -43,6 +45,7 @@ withDefaults(defineProps<Props>(), {
|
||||||
:color="item.color"
|
:color="item.color"
|
||||||
:icon="item.icon"
|
:icon="item.icon"
|
||||||
class="size-8 transition-all duration-300 group-hover:scale-110"
|
class="size-8 transition-all duration-300 group-hover:scale-110"
|
||||||
|
@click="$emit('click', item)"
|
||||||
/>
|
/>
|
||||||
<span class="ml-4 text-lg font-medium">{{ item.title }}</span>
|
<span class="ml-4 text-lg font-medium">{{ item.title }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -21,6 +21,8 @@ defineOptions({
|
||||||
withDefaults(defineProps<Props>(), {
|
withDefaults(defineProps<Props>(), {
|
||||||
items: () => [],
|
items: () => [],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
defineEmits(['click']);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -37,6 +39,7 @@ withDefaults(defineProps<Props>(), {
|
||||||
'border-b-0': index < 3,
|
'border-b-0': index < 3,
|
||||||
}"
|
}"
|
||||||
class="flex-col-center border-border group w-1/3 cursor-pointer border-b border-r border-t py-8 hover:shadow-xl"
|
class="flex-col-center border-border group w-1/3 cursor-pointer border-b border-r border-t py-8 hover:shadow-xl"
|
||||||
|
@click="$emit('click', item)"
|
||||||
>
|
>
|
||||||
<VbenIcon
|
<VbenIcon
|
||||||
:color="item.color"
|
:color="item.color"
|
||||||
|
|
|
@ -7,6 +7,7 @@ import type {
|
||||||
} from '@vben/common-ui';
|
} from '@vben/common-ui';
|
||||||
|
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
|
import { useRouter } from 'vue-router';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
AnalysisChartCard,
|
AnalysisChartCard,
|
||||||
|
@ -18,11 +19,15 @@ import {
|
||||||
} from '@vben/common-ui';
|
} from '@vben/common-ui';
|
||||||
import { preferences } from '@vben/preferences';
|
import { preferences } from '@vben/preferences';
|
||||||
import { useUserStore } from '@vben/stores';
|
import { useUserStore } from '@vben/stores';
|
||||||
|
import { openWindow } from '@vben/utils';
|
||||||
|
|
||||||
import AnalyticsVisitsSource from '../analytics/analytics-visits-source.vue';
|
import AnalyticsVisitsSource from '../analytics/analytics-visits-source.vue';
|
||||||
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
|
|
||||||
|
// 这是一个示例数据,实际项目中需要根据实际情况进行调整
|
||||||
|
// url 也可以是内部路由,在 navTo 方法中识别处理,进行内部跳转
|
||||||
|
// 例如:url: /dashboard/workspace
|
||||||
const projectItems: WorkbenchProjectItem[] = [
|
const projectItems: WorkbenchProjectItem[] = [
|
||||||
{
|
{
|
||||||
color: '',
|
color: '',
|
||||||
|
@ -31,6 +36,7 @@ const projectItems: WorkbenchProjectItem[] = [
|
||||||
group: '开源组',
|
group: '开源组',
|
||||||
icon: 'carbon:logo-github',
|
icon: 'carbon:logo-github',
|
||||||
title: 'Github',
|
title: 'Github',
|
||||||
|
url: 'https://github.com',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
color: '#3fb27f',
|
color: '#3fb27f',
|
||||||
|
@ -39,6 +45,7 @@ const projectItems: WorkbenchProjectItem[] = [
|
||||||
group: '算法组',
|
group: '算法组',
|
||||||
icon: 'ion:logo-vue',
|
icon: 'ion:logo-vue',
|
||||||
title: 'Vue',
|
title: 'Vue',
|
||||||
|
url: 'https://vuejs.org',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
color: '#e18525',
|
color: '#e18525',
|
||||||
|
@ -47,6 +54,7 @@ const projectItems: WorkbenchProjectItem[] = [
|
||||||
group: '上班摸鱼',
|
group: '上班摸鱼',
|
||||||
icon: 'ion:logo-html5',
|
icon: 'ion:logo-html5',
|
||||||
title: 'Html5',
|
title: 'Html5',
|
||||||
|
url: 'https://developer.mozilla.org/zh-CN/docs/Web/HTML',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
color: '#bf0c2c',
|
color: '#bf0c2c',
|
||||||
|
@ -55,6 +63,7 @@ const projectItems: WorkbenchProjectItem[] = [
|
||||||
group: 'UI',
|
group: 'UI',
|
||||||
icon: 'ion:logo-angular',
|
icon: 'ion:logo-angular',
|
||||||
title: 'Angular',
|
title: 'Angular',
|
||||||
|
url: 'https://angular.io',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
color: '#00d8ff',
|
color: '#00d8ff',
|
||||||
|
@ -63,6 +72,7 @@ const projectItems: WorkbenchProjectItem[] = [
|
||||||
group: '技术牛',
|
group: '技术牛',
|
||||||
icon: 'bx:bxl-react',
|
icon: 'bx:bxl-react',
|
||||||
title: 'React',
|
title: 'React',
|
||||||
|
url: 'https://reactjs.org',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
color: '#EBD94E',
|
color: '#EBD94E',
|
||||||
|
@ -71,39 +81,47 @@ const projectItems: WorkbenchProjectItem[] = [
|
||||||
group: '架构组',
|
group: '架构组',
|
||||||
icon: 'ion:logo-javascript',
|
icon: 'ion:logo-javascript',
|
||||||
title: 'Js',
|
title: 'Js',
|
||||||
|
url: 'https://developer.mozilla.org/zh-CN/docs/Web/JavaScript',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// 同样,这里的 url 也可以使用以 http 开头的外部链接
|
||||||
const quickNavItems: WorkbenchQuickNavItem[] = [
|
const quickNavItems: WorkbenchQuickNavItem[] = [
|
||||||
{
|
{
|
||||||
color: '#1fdaca',
|
color: '#1fdaca',
|
||||||
icon: 'ion:home-outline',
|
icon: 'ion:home-outline',
|
||||||
title: '首页',
|
title: '首页',
|
||||||
|
url: '/',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
color: '#bf0c2c',
|
color: '#bf0c2c',
|
||||||
icon: 'ion:grid-outline',
|
icon: 'ion:grid-outline',
|
||||||
title: '仪表盘',
|
title: '仪表盘',
|
||||||
|
url: '/dashboard',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
color: '#e18525',
|
color: '#e18525',
|
||||||
icon: 'ion:layers-outline',
|
icon: 'ion:layers-outline',
|
||||||
title: '组件',
|
title: '组件',
|
||||||
|
url: '/demos/features/icons',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
color: '#3fb27f',
|
color: '#3fb27f',
|
||||||
icon: 'ion:settings-outline',
|
icon: 'ion:settings-outline',
|
||||||
title: '系统管理',
|
title: '系统管理',
|
||||||
|
url: '/demos/features/login-expired', // 这里的 URL 是示例,实际项目中需要根据实际情况进行调整
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
color: '#4daf1bc9',
|
color: '#4daf1bc9',
|
||||||
icon: 'ion:key-outline',
|
icon: 'ion:key-outline',
|
||||||
title: '权限管理',
|
title: '权限管理',
|
||||||
|
url: '/demos/access/page-control',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
color: '#00d8ff',
|
color: '#00d8ff',
|
||||||
icon: 'ion:bar-chart-outline',
|
icon: 'ion:bar-chart-outline',
|
||||||
title: '图表',
|
title: '图表',
|
||||||
|
url: '/analytics',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -195,6 +213,24 @@ const trendItems: WorkbenchTrendItem[] = [
|
||||||
title: 'Vben',
|
title: 'Vben',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
|
// 这是一个示例方法,实际项目中需要根据实际情况进行调整
|
||||||
|
// This is a sample method, adjust according to the actual project requirements
|
||||||
|
function navTo(nav: WorkbenchProjectItem | WorkbenchQuickNavItem) {
|
||||||
|
if (nav.url?.startsWith('http')) {
|
||||||
|
openWindow(nav.url);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (nav.url?.startsWith('/')) {
|
||||||
|
router.push(nav.url).catch((error) => {
|
||||||
|
console.error('Navigation failed:', error);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
console.warn(`Unknown URL for navigation item: ${nav.title} -> ${nav.url}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -210,7 +246,7 @@ const trendItems: WorkbenchTrendItem[] = [
|
||||||
|
|
||||||
<div class="mt-5 flex flex-col lg:flex-row">
|
<div class="mt-5 flex flex-col lg:flex-row">
|
||||||
<div class="mr-4 w-full lg:w-3/5">
|
<div class="mr-4 w-full lg:w-3/5">
|
||||||
<WorkbenchProject :items="projectItems" title="项目" />
|
<WorkbenchProject :items="projectItems" title="项目" @click="navTo" />
|
||||||
<WorkbenchTrends :items="trendItems" class="mt-5" title="最新动态" />
|
<WorkbenchTrends :items="trendItems" class="mt-5" title="最新动态" />
|
||||||
</div>
|
</div>
|
||||||
<div class="w-full lg:w-2/5">
|
<div class="w-full lg:w-2/5">
|
||||||
|
@ -218,6 +254,7 @@ const trendItems: WorkbenchTrendItem[] = [
|
||||||
:items="quickNavItems"
|
:items="quickNavItems"
|
||||||
class="mt-5 lg:mt-0"
|
class="mt-5 lg:mt-0"
|
||||||
title="快捷导航"
|
title="快捷导航"
|
||||||
|
@click="navTo"
|
||||||
/>
|
/>
|
||||||
<WorkbenchTodo :items="todoItems" class="mt-5" title="待办事项" />
|
<WorkbenchTodo :items="todoItems" class="mt-5" title="待办事项" />
|
||||||
<AnalysisChartCard class="mt-5" title="访问来源">
|
<AnalysisChartCard class="mt-5" title="访问来源">
|
||||||
|
|
Loading…
Reference in New Issue