-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(analytics): move numeric card to analytics package
- Loading branch information
Showing
10 changed files
with
177 additions
and
180 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<template> | ||
<div class="card-grid profile-grid"><k-slot name="numeric"></k-slot></div> | ||
<div class="card-grid chart-grid"><k-slot name="chart"></k-slot></div> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
</script> | ||
|
||
<style lang="scss"> | ||
.card-grid { | ||
display: grid; | ||
margin: var(--card-margin); | ||
grid-gap: var(--card-margin); | ||
} | ||
.profile-grid { | ||
grid-template-columns: repeat(3, 1fr); | ||
@media screen and (min-width: 1440px) { | ||
grid-template-columns: repeat(4, 1fr); | ||
} | ||
@media screen and (max-width: 1024px) { | ||
grid-template-columns: repeat(2, 1fr); | ||
} | ||
} | ||
.chart-grid { | ||
.echarts { | ||
max-width: 100%; | ||
margin: 0 auto; | ||
} | ||
@media (min-width: 1024px) { | ||
grid-template-columns: repeat(2, 1fr); | ||
@media (min-width: 1600px) { | ||
.echarts { | ||
width: 600px; | ||
height: 400px; | ||
max-width: 100%; | ||
margin: 0 auto; | ||
} | ||
} | ||
@media (max-width: 1600px) { | ||
.echarts { | ||
width: 480px; | ||
height: 360px; | ||
} | ||
} | ||
} | ||
@media (max-width: 1024px) { | ||
grid-template-columns: 1fr; | ||
@media (min-width: 768px) { | ||
.echarts { | ||
width: 800px; | ||
height: 400px; | ||
} | ||
} | ||
@media (max-width: 768px) { | ||
.echarts { | ||
width: 600px; | ||
height: 400px; | ||
} | ||
} | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,18 @@ | ||
import { Card, defineExtension } from '@koishijs/client' | ||
import { defineExtension } from '@koishijs/client' | ||
import {} from '@koishijs/plugin-analytics/src' | ||
import Charts from './charts' | ||
import Numbers from './numbers' | ||
import Home from './home.vue' | ||
import './icons' | ||
|
||
export default defineExtension((ctx) => { | ||
// ctx.app.provide('ecTheme', 'koishi-dark') | ||
ctx.plugin(Charts) | ||
|
||
// 用户数量 群组数量 周均 DAU 当前 QPS | ||
// 昨日新增用户 昨日新增群组 昨日 DAU 昨日 QPS | ||
|
||
ctx.slot({ | ||
type: 'numeric', | ||
component: Card.numeric({ | ||
title: '用户数量', | ||
icon: 'heart', | ||
fields: ['analytics'], | ||
content: ({ analytics }) => analytics.userCount, | ||
}), | ||
}) | ||
|
||
ctx.slot({ | ||
type: 'numeric', | ||
component: Card.numeric({ | ||
title: '群组数量', | ||
icon: 'users', | ||
fields: ['analytics'], | ||
content: ({ analytics }) => analytics.guildCount, | ||
}), | ||
}) | ||
|
||
ctx.slot({ | ||
type: 'numeric', | ||
component: Card.numeric({ | ||
title: '今日 DAU', | ||
icon: 'heart', | ||
fields: ['analytics'], | ||
content: ({ analytics }) => analytics.dauHistory[0], | ||
}), | ||
}) | ||
|
||
ctx.slot({ | ||
type: 'numeric', | ||
component: Card.numeric({ | ||
title: '昨日用户增量', | ||
icon: 'heart', | ||
fields: ['analytics'], | ||
content: ({ analytics }) => analytics.userIncrement, | ||
}), | ||
}) | ||
|
||
ctx.slot({ | ||
type: 'numeric', | ||
component: Card.numeric({ | ||
title: '昨日群组增量', | ||
icon: 'users', | ||
fields: ['analytics'], | ||
content: ({ analytics }) => analytics.guildIncrement, | ||
}), | ||
}) | ||
ctx.plugin(Numbers) | ||
|
||
ctx.slot({ | ||
type: 'numeric', | ||
component: Card.numeric({ | ||
title: '上周 DAU', | ||
icon: 'heart', | ||
fields: ['analytics'], | ||
content: ({ analytics }) => (analytics.dauHistory.slice(1).reduce((a, b) => a + b, 0) / 7).toFixed(1), | ||
}), | ||
type: 'home', | ||
component: Home, | ||
order: 0, | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import { defineExtension } from '@koishijs/client' | ||
import { createNumeric } from './utils' | ||
import {} from '@koishijs/plugin-analytics/src' | ||
|
||
export default defineExtension((ctx) => { | ||
// 用户数量 群组数量 周均 DAU 当前 QPS | ||
// 昨日新增用户 昨日新增群组 昨日 DAU 昨日 QPS | ||
|
||
ctx.slot({ | ||
type: 'numeric', | ||
component: createNumeric({ | ||
title: '用户数量', | ||
icon: 'heart', | ||
fields: ['analytics'], | ||
content: ({ analytics }) => analytics.userCount, | ||
}), | ||
}) | ||
|
||
ctx.slot({ | ||
type: 'numeric', | ||
component: createNumeric({ | ||
title: '群组数量', | ||
icon: 'users', | ||
fields: ['analytics'], | ||
content: ({ analytics }) => analytics.guildCount, | ||
}), | ||
}) | ||
|
||
ctx.slot({ | ||
type: 'numeric', | ||
component: createNumeric({ | ||
title: '今日 DAU', | ||
icon: 'heart', | ||
fields: ['analytics'], | ||
content: ({ analytics }) => analytics.dauHistory[0], | ||
}), | ||
}) | ||
|
||
ctx.slot({ | ||
type: 'numeric', | ||
component: createNumeric({ | ||
title: '当前 QPS', | ||
icon: 'heart', | ||
fields: ['analytics'], | ||
content: ({ analytics }) => analytics.messageByHour[0].receive / 60, | ||
}), | ||
}) | ||
|
||
ctx.slot({ | ||
type: 'numeric', | ||
component: createNumeric({ | ||
title: '昨日用户增量', | ||
icon: 'heart', | ||
fields: ['analytics'], | ||
content: ({ analytics }) => analytics.userIncrement, | ||
}), | ||
}) | ||
|
||
ctx.slot({ | ||
type: 'numeric', | ||
component: createNumeric({ | ||
title: '昨日群组增量', | ||
icon: 'users', | ||
fields: ['analytics'], | ||
content: ({ analytics }) => analytics.guildIncrement, | ||
}), | ||
}) | ||
|
||
ctx.slot({ | ||
type: 'numeric', | ||
component: createNumeric({ | ||
title: '上周 DAU', | ||
icon: 'heart', | ||
fields: ['analytics'], | ||
content: ({ analytics }) => (analytics.dauHistory.slice(1).reduce((a, b) => a + b, 0) / 7).toFixed(1), | ||
}), | ||
}) | ||
}) |
File renamed without changes.
Oops, something went wrong.