Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 94 additions & 29 deletions ui/console-src/modules/dashboard/widgets/defaults.ts
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

添加这个小部件即可,不建议修改已有的默认仪表盘配置,如果用户需要添加这个小部件,可以自行编辑。

Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,27 @@ const DefaultResponsiveLayouts: DashboardResponsiveLayout = {
},
},
{
i: "96a9ac85-ec47-4c4b-bd02-184ee047f6a5",
x: 6,
i: "ee42743e-06d8-4106-9481-42443bb8b2f0",
x: 3,
y: 0,
w: 3,
h: 3,
minW: 2,
minH: 2,
id: "core:comment:stats",
id: "core:user:stats",
config: {
enable_animation: true,
},
},
{
i: "ee42743e-06d8-4106-9481-42443bb8b2f0",
x: 3,
i: "96a9ac85-ec47-4c4b-bd02-184ee047f6a5",
x: 6,
y: 0,
w: 3,
h: 3,
minW: 2,
minH: 2,
id: "core:user:stats",
id: "core:comment:stats",
config: {
enable_animation: true,
},
Expand All @@ -55,9 +55,22 @@ const DefaultResponsiveLayouts: DashboardResponsiveLayout = {
},
},
{
i: "e45cd079-a406-42de-a196-e11c64f6d893",
i: "b8d790bb-3af4-4c4d-a8f8-0fd64dc6a93f",
x: 0,
y: 3,
w: 3,
h: 3,
minW: 2,
minH: 2,
id: "core:upvote:stats",
config: {
enable_animation: true,
},
},
{
i: "e45cd079-a406-42de-a196-e11c64f6d893",
x: 0,
y: 6,
w: 6,
h: 12,
minW: 3,
Expand All @@ -80,7 +93,7 @@ const DefaultResponsiveLayouts: DashboardResponsiveLayout = {
{
i: "3bcd12eb-44ee-48e8-a37f-3f5d73470e2d",
x: 6,
y: 3,
y: 6,
w: 6,
h: 12,
minW: 3,
Expand Down Expand Up @@ -143,9 +156,22 @@ const DefaultResponsiveLayouts: DashboardResponsiveLayout = {
},
},
{
i: "c3e467a7-9a15-4732-9ba1-45f36a49d25e",
i: "f1c9b07f-8c9a-45ab-8349-bff1436b7a1f",
x: 0,
y: 6,
w: 2,
h: 3,
minW: 2,
minH: 2,
id: "core:upvote:stats",
config: {
enable_animation: true,
},
},
{
i: "c3e467a7-9a15-4732-9ba1-45f36a49d25e",
x: 0,
y: 9,
w: 6,
h: 12,
minW: 3,
Expand All @@ -168,7 +194,7 @@ const DefaultResponsiveLayouts: DashboardResponsiveLayout = {
{
i: "24005fc4-e725-4e6d-95ae-f83026ffc178",
x: 0,
y: 18,
y: 21,
w: 6,
h: 12,
minW: 3,
Expand Down Expand Up @@ -231,9 +257,22 @@ const DefaultResponsiveLayouts: DashboardResponsiveLayout = {
},
},
{
i: "c3e467a7-9a15-4732-9ba1-45f36a49d25e",
i: "e7a898ee-6af6-4a8f-9726-7c2b5c001d26",
x: 0,
y: 6,
w: 2,
h: 3,
minW: 2,
minH: 2,
id: "core:upvote:stats",
config: {
enable_animation: true,
},
},
{
i: "c3e467a7-9a15-4732-9ba1-45f36a49d25e",
x: 0,
y: 9,
w: 6,
h: 12,
minW: 3,
Expand All @@ -256,7 +295,7 @@ const DefaultResponsiveLayouts: DashboardResponsiveLayout = {
{
i: "24005fc4-e725-4e6d-95ae-f83026ffc178",
x: 0,
y: 18,
y: 21,
w: 6,
h: 12,
minW: 3,
Expand All @@ -280,27 +319,27 @@ const DefaultResponsiveLayouts: DashboardResponsiveLayout = {
},
},
{
i: "31a29ecc-e2d6-449c-9850-994e2fd6d9c6",
x: 6,
i: "b3cc217f-5008-49bd-b6a3-b760c1afc4f9",
x: 3,
y: 0,
w: 3,
h: 3,
minW: 2,
minH: 2,
id: "core:comment:stats",
id: "core:user:stats",
config: {
enable_animation: true,
},
},
{
i: "b3cc217f-5008-49bd-b6a3-b760c1afc4f9",
x: 3,
i: "31a29ecc-e2d6-449c-9850-994e2fd6d9c6",
x: 6,
y: 0,
w: 3,
h: 3,
minW: 2,
minH: 2,
id: "core:user:stats",
id: "core:comment:stats",
config: {
enable_animation: true,
},
Expand All @@ -319,9 +358,22 @@ const DefaultResponsiveLayouts: DashboardResponsiveLayout = {
},
},
{
i: "1f329a9f-d1aa-4337-98b3-34d8732b9143",
i: "acc4cfff-5466-4dfa-8ca0-9b1f68ec64bf",
x: 0,
y: 3,
w: 3,
h: 3,
minW: 2,
minH: 2,
id: "core:upvote:stats",
config: {
enable_animation: true,
},
},
{
i: "1f329a9f-d1aa-4337-98b3-34d8732b9143",
x: 0,
y: 6,
w: 6,
h: 12,
minW: 3,
Expand All @@ -344,7 +396,7 @@ const DefaultResponsiveLayouts: DashboardResponsiveLayout = {
{
i: "ac9a9984-da16-4d81-adc6-8c64ffcbde5e",
x: 6,
y: 3,
y: 6,
w: 6,
h: 12,
minW: 3,
Expand All @@ -367,6 +419,19 @@ const DefaultResponsiveLayouts: DashboardResponsiveLayout = {
enable_animation: true,
},
},
{
i: "d6508199-b7a3-47dc-aabf-4e3634760b78",
x: 3,
y: 0,
w: 3,
h: 3,
minW: 2,
minH: 2,
id: "core:user:stats",
config: {
enable_animation: true,
},
},
{
i: "44932f76-7667-4b77-99e7-9778c8f54062",
x: 0,
Expand All @@ -381,35 +446,35 @@ const DefaultResponsiveLayouts: DashboardResponsiveLayout = {
},
},
{
i: "d6508199-b7a3-47dc-aabf-4e3634760b78",
i: "3525a65d-2c69-4c0f-a378-6c9f1f06ad4c",
x: 3,
y: 0,
y: 3,
w: 3,
h: 3,
minW: 2,
minH: 2,
id: "core:user:stats",
id: "core:view:stats",
config: {
enable_animation: true,
},
},
{
i: "3525a65d-2c69-4c0f-a378-6c9f1f06ad4c",
x: 3,
y: 3,
i: "6f6137b3-b99c-42b5-a6db-14318e403d30",
x: 0,
y: 6,
w: 3,
h: 3,
minW: 2,
minH: 2,
id: "core:view:stats",
id: "core:upvote:stats",
config: {
enable_animation: true,
},
},
{
i: "1bf7eba4-2805-495b-85cd-ebd9ecd9ab82",
x: 0,
y: 6,
y: 9,
w: 6,
h: 12,
minW: 3,
Expand All @@ -432,7 +497,7 @@ const DefaultResponsiveLayouts: DashboardResponsiveLayout = {
{
i: "06dc350c-db0e-46ea-9718-cef1e5bca339",
x: 0,
y: 18,
y: 21,
w: 6,
h: 12,
minW: 3,
Expand Down
24 changes: 24 additions & 0 deletions ui/console-src/modules/dashboard/widgets/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import PendingCommentsWidget from "./presets/comments/PendingCommentsWidget.vue"
import IframeWidget from "./presets/core/iframe/IframeWidget.vue";
import QuickActionWidget from "./presets/core/quick-action/QuickActionWidget.vue";
import StackWidget from "./presets/core/stack/StackWidget.vue";
import UpvoteStatsWidget from "./presets/core/upvote-stats/UpvoteStatsWidget.vue";
import ViewsStatsWidget from "./presets/core/view-stats/ViewsStatsWidget.vue";
import PostStatsWidget from "./presets/posts/PostStatsWidget.vue";
import RecentPublishedWidget from "./presets/posts/RecentPublishedWidget.vue";
Expand Down Expand Up @@ -157,6 +158,29 @@ export const internalWidgetDefinitions: DashboardWidgetDefinition[] = [
minW: 2,
},
},
{
id: "core:upvote:stats",
component: markRaw(UpvoteStatsWidget),
group: "core.dashboard.widgets.groups.other",
configFormKitSchema: () => [
{
$formkit: "checkbox",
label: i18n.global.t(
"core.dashboard.widgets.common_form.fields.enable_animation.label"
),
name: "enable_animation",
},
],
defaultConfig: {
enable_animation: true,
},
defaultSize: {
w: 3,
h: 3,
minH: 2,
minW: 2,
},
},
{
id: "core:quick-action",
component: markRaw(QuickActionWidget),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<script lang="ts" setup>
import { useDashboardStats } from "@console/composables/use-dashboard-stats";
import WidgetCard from "@console/modules/dashboard/components/WidgetCard.vue";
import { IconThumbUpLine } from "@halo-dev/components";
import NumberFlow from "@number-flow/vue";

defineProps<{
config: {
enable_animation: boolean;
};
}>();

const { data: stats } = useDashboardStats();
</script>

<template>
<WidgetCard>
<div class="flex h-full px-4 py-3">
<div class="flex items-center gap-4">
<span class="rounded-full bg-gray-100 p-2.5 text-gray-600">
<IconThumbUpLine class="h-5 w-5" />
</span>

<div class="flex flex-col">
<span class="text-sm text-gray-500">
{{ $t("core.dashboard.widgets.presets.upvote_stats.title") }}
</span>
<NumberFlow
v-if="config.enable_animation"
class="text-2xl font-medium text-gray-900"
:value="stats?.upvotes || 0"
:format="{ notation: 'compact' }"
>
</NumberFlow>
<span v-else class="text-2xl font-medium text-gray-900">
{{ stats?.upvotes || 0 }}
</span>
</div>
</div>
</div>
</WidgetCard>
</template>




2 changes: 2 additions & 0 deletions ui/packages/components/src/icons/icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ import IconTeam from "~icons/ri/team-fill";
import IconTerminalBoxLine from "~icons/ri/terminal-box-line";
import IconTimerLine from "~icons/ri/timer-line";
import IconToolsFill from "~icons/ri/tools-fill";
import IconThumbUpLine from "~icons/ri/thumb-up-line";
import IconRiUpload2Fill from "~icons/ri/upload-2-fill";
import IconUpload from "~icons/ri/upload-cloud-2-line";
import IconUserFollow from "~icons/ri/user-follow-line";
Expand Down Expand Up @@ -145,6 +146,7 @@ export {
IconTerminalBoxLine,
IconTimerLine,
IconToolsFill,
IconThumbUpLine,
IconUpload,
IconUserFollow,
IconUserLine,
Expand Down
2 changes: 2 additions & 0 deletions ui/src/locales/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ core:
title: No pending comments
views_stats:
title: Visits
upvote_stats:
title: Likes
iframe:
title: Iframe
empty:
Expand Down
2 changes: 2 additions & 0 deletions ui/src/locales/es.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ core:
title: Comentarios
views_stats:
title: Visitas
upvote_stats:
title: Me gusta
post:
title: Publicaciones
actions:
Expand Down
Loading