koishi-plugin-chatluna-affinity 0.3.0 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,9 @@
1
+ import { createRoot, type Root } from "react-dom/client";
2
+ import React from "react";
3
+ import { AffinityDashboard } from "./AffinityDashboard";
4
+
5
+ export function mountAffinityDashboard(element: Element): () => void {
6
+ const root: Root = createRoot(element);
7
+ root.render(<AffinityDashboard />);
8
+ return () => root.unmount();
9
+ }
@@ -0,0 +1,85 @@
1
+ export interface DashboardTopUser {
2
+ userId: string;
3
+ name: string;
4
+ avatarUrl: string | null;
5
+ affinity: number;
6
+ longTermAffinity: number;
7
+ relation: string;
8
+ relationTone: "custom" | "low" | "medium" | "high" | "unknown";
9
+ chatCount: number;
10
+ lastInteractionAt: string | null;
11
+ historyPoints: DashboardUserHistoryPoint[];
12
+ }
13
+
14
+ export interface DashboardRelationStat {
15
+ relation: string;
16
+ kind: "preset" | "custom";
17
+ count: number;
18
+ }
19
+
20
+ export interface DashboardTrendPoint {
21
+ label: string;
22
+ users: number;
23
+ averageAffinity: number;
24
+ chatCount: number;
25
+ blacklisted: number;
26
+ }
27
+
28
+ export interface DashboardMetricChange {
29
+ current: number;
30
+ previous: number;
31
+ percent: number | null;
32
+ }
33
+
34
+ export interface DashboardUserHistoryPoint {
35
+ label: string;
36
+ timestamp: string | null;
37
+ affinity: number;
38
+ longTermAffinity: number;
39
+ chatCount: number;
40
+ }
41
+
42
+ export interface DashboardBlacklistItem {
43
+ platform: string;
44
+ userId: string;
45
+ name: string;
46
+ avatarUrl: string | null;
47
+ affinity: number | null;
48
+ mode: "permanent" | "temporary";
49
+ blockedAt: string | null;
50
+ expiresAt: string | null;
51
+ note: string;
52
+ }
53
+
54
+ export interface DashboardData {
55
+ scopeId: string;
56
+ generatedAt: string;
57
+ totals: {
58
+ users: number;
59
+ blacklisted: number;
60
+ permanentBlacklisted: number;
61
+ temporaryBlacklisted: number;
62
+ aliases: number;
63
+ chatCount: number;
64
+ };
65
+ averages: {
66
+ affinity: number;
67
+ longTermAffinity: number;
68
+ shortTermAffinity: number;
69
+ };
70
+ latestInteractionAt: string | null;
71
+ weeklyChanges: {
72
+ users: DashboardMetricChange;
73
+ averageAffinity: DashboardMetricChange;
74
+ chatCount: DashboardMetricChange;
75
+ aliases: DashboardMetricChange;
76
+ };
77
+ trends: {
78
+ week: DashboardTrendPoint[];
79
+ month: DashboardTrendPoint[];
80
+ all: DashboardTrendPoint[];
81
+ };
82
+ relationStats: DashboardRelationStat[];
83
+ blacklistItems: DashboardBlacklistItem[];
84
+ topUsers: DashboardTopUser[];
85
+ }
package/client/index.ts CHANGED
@@ -5,8 +5,21 @@
5
5
 
6
6
  import { Context } from '@koishijs/client'
7
7
  import AffinityDetailsLoader from './AffinityDetailsLoader.vue'
8
+ import AffinityDashboardPage from './AffinityDashboardPage.vue'
9
+ import './style.css'
8
10
 
9
11
  export default (ctx: Context) => {
12
+ ctx.page({
13
+ id: 'chatluna-affinity-dashboard',
14
+ path: '/chatluna-affinity/dashboard',
15
+ name: '好感度仪表盘',
16
+ desc: '查看当前 scopeId 的好感度统计',
17
+ icon: 'star-empty',
18
+ order: 560,
19
+ authority: 1,
20
+ component: AffinityDashboardPage,
21
+ })
22
+
10
23
  ctx.slot({
11
24
  type: 'plugin-details',
12
25
  component: AffinityDetailsLoader,
@@ -0,0 +1,6 @@
1
+ import { clsx, type ClassValue } from "clsx";
2
+ import { twMerge } from "tailwind-merge";
3
+
4
+ export function cn(...inputs: ClassValue[]): string {
5
+ return twMerge(clsx(inputs));
6
+ }
@@ -0,0 +1,125 @@
1
+ @import "tailwindcss";
2
+ @import "tw-animate-css";
3
+ @import "@heroui/styles/base";
4
+ @import "@heroui/styles/themes/default";
5
+ @import "@heroui/styles/utilities";
6
+ @import "@heroui/styles/components/tabs.css";
7
+ @import "@heroui/styles/components/tooltip.css";
8
+
9
+ @theme inline {
10
+ --color-background: var(--background);
11
+ --color-foreground: var(--foreground);
12
+ --color-card: var(--card);
13
+ --color-card-foreground: var(--card-foreground);
14
+ --color-popover: var(--popover);
15
+ --color-popover-foreground: var(--popover-foreground);
16
+ --color-primary: var(--primary);
17
+ --color-primary-foreground: var(--primary-foreground);
18
+ --color-secondary: var(--secondary);
19
+ --color-secondary-foreground: var(--secondary-foreground);
20
+ --color-muted: var(--muted);
21
+ --color-muted-foreground: var(--muted-foreground);
22
+ --color-accent: var(--accent);
23
+ --color-accent-foreground: var(--accent-foreground);
24
+ --color-destructive: var(--destructive);
25
+ --color-destructive-foreground: var(--destructive-foreground);
26
+ --color-border: var(--border);
27
+ --color-input: var(--input);
28
+ --color-ring: var(--ring);
29
+ --color-chart-1: var(--chart-1);
30
+ --color-chart-2: var(--chart-2);
31
+ --color-chart-3: var(--chart-3);
32
+ }
33
+
34
+ .page-affinity-dashboard-shell,
35
+ .page-affinity-dashboard-shell .main-container,
36
+ .page-affinity-dashboard-shell .layout-header,
37
+ .page-affinity-dashboard,
38
+ .page-affinity-dashboard .el-scrollbar,
39
+ .page-affinity-dashboard .el-scrollbar__wrap,
40
+ .page-affinity-dashboard .el-scrollbar__view,
41
+ .page-affinity-dashboard .k-content {
42
+ background: #f8fafc;
43
+ }
44
+
45
+ .page-affinity-dashboard .k-content {
46
+ width: 100%;
47
+ max-width: 80rem;
48
+ }
49
+
50
+ .page-affinity-dashboard-shell .layout-header {
51
+ display: none;
52
+ }
53
+
54
+ .affinity-dashboard {
55
+ --background: #ffffff;
56
+ --foreground: #0f172a;
57
+ --card: #ffffff;
58
+ --card-foreground: #0f172a;
59
+ --popover: #ffffff;
60
+ --popover-foreground: #0f172a;
61
+ --primary: #0f172a;
62
+ --primary-foreground: #f8fafc;
63
+ --secondary: #f1f5f9;
64
+ --secondary-foreground: #0f172a;
65
+ --muted: #f1f5f9;
66
+ --muted-foreground: #64748b;
67
+ --accent: #e2e8f0;
68
+ --accent-foreground: #0f172a;
69
+ --destructive: #dc2626;
70
+ --destructive-foreground: #ffffff;
71
+ --border: #e2e8f0;
72
+ --input: #cbd5e1;
73
+ --ring: #94a3b8;
74
+ --chart-1: #2563eb;
75
+ --chart-2: #16a34a;
76
+ --chart-3: #d97706;
77
+ --chart-4: #dc2626;
78
+
79
+ box-sizing: border-box;
80
+ display: grid;
81
+ gap: 16px;
82
+ width: 100%;
83
+ max-width: 100%;
84
+ min-width: 0;
85
+ min-height: calc(100vh - 6rem);
86
+ padding: 0;
87
+ color: var(--foreground);
88
+ }
89
+
90
+ .affinity-dashboard > * {
91
+ max-width: 100%;
92
+ min-width: 0;
93
+ }
94
+
95
+ .affinity-dashboard .tabs__list {
96
+ width: fit-content;
97
+ }
98
+
99
+ .affinity-dashboard .tabs__tab:not([data-selected="true"]) {
100
+ color: var(--muted-foreground);
101
+ }
102
+
103
+ .affinity-dashboard *,
104
+ .affinity-dashboard *::before,
105
+ .affinity-dashboard *::after {
106
+ box-sizing: border-box;
107
+ }
108
+
109
+ .affinity-dashboard__empty {
110
+ margin: 0;
111
+ color: var(--muted-foreground);
112
+ font-size: 14px;
113
+ line-height: 1.6;
114
+ }
115
+
116
+ @media (max-width: 720px) {
117
+ .page-affinity-dashboard .k-content {
118
+ padding-right: 16px;
119
+ padding-left: 16px;
120
+ }
121
+
122
+ .affinity-dashboard {
123
+ min-height: auto;
124
+ }
125
+ }