feat: add entitlement plans and topic sessions
This commit is contained in:
@@ -304,7 +304,7 @@ function showToast(message: string) {
|
||||
<LoginPanel v-else-if="!user" @logged-in="onLoggedIn" />
|
||||
<template v-else>
|
||||
<ChatHeader :user="user" :status-text="statusText" @open-history="drawerOpen = true" @logout="logoutDialogOpen = true" />
|
||||
<SessionQuota :used="user.todayUsed" :limit="user.dailyLimit" />
|
||||
<SessionQuota :used="user.todayUsed" :limit="user.dailyLimit" :entitlement="user.entitlement" />
|
||||
<MessageList
|
||||
ref="messageList"
|
||||
:messages="messages"
|
||||
|
||||
@@ -1,18 +1,30 @@
|
||||
<script setup lang="ts">
|
||||
import { Layers3 } from "@lucide/vue";
|
||||
import { computed } from "vue";
|
||||
|
||||
defineProps<{
|
||||
import type { UserEntitlementSummary } from "../types/api";
|
||||
|
||||
const props = defineProps<{
|
||||
used: number;
|
||||
limit: number;
|
||||
entitlement?: UserEntitlementSummary | null;
|
||||
}>();
|
||||
|
||||
const hasEntitlement = computed(() => Boolean(props.entitlement));
|
||||
const displayUsed = computed(() => props.entitlement?.monthlyTopicUsed ?? props.used);
|
||||
const displayLimit = computed(() => props.entitlement?.monthlyTopicLimit ?? props.limit);
|
||||
const exhausted = computed(() => displayLimit.value !== null && displayLimit.value > 0 && displayUsed.value >= displayLimit.value);
|
||||
const title = computed(() => props.entitlement ? "本月主题额度" : "当前会话额度");
|
||||
const limitText = computed(() => displayLimit.value === null ? "不限" : String(displayLimit.value));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="session-quota" :class="{ exhausted: limit > 0 && used >= limit }" aria-label="当前会话额度">
|
||||
<section class="session-quota" :class="{ exhausted }" :aria-label="title">
|
||||
<div>
|
||||
<Layers3 :size="18" aria-hidden="true" />
|
||||
<span>当前会话额度</span>
|
||||
<span>{{ title }}</span>
|
||||
<small v-if="hasEntitlement">{{ entitlement?.name }}</small>
|
||||
</div>
|
||||
<strong>{{ used }}/{{ limit }}</strong>
|
||||
<strong>{{ displayUsed }}/{{ limitText }}</strong>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
@@ -1218,6 +1218,16 @@ textarea:focus-visible {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.session-quota small {
|
||||
overflow: hidden;
|
||||
max-width: 150px;
|
||||
color: #6c8078;
|
||||
font-size: 11px;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.session-quota svg,
|
||||
|
||||
@@ -12,6 +12,24 @@ export interface UserProfile {
|
||||
dailyLimit: number;
|
||||
todayUsed: number;
|
||||
status: number;
|
||||
entitlement?: UserEntitlementSummary | null;
|
||||
}
|
||||
|
||||
export interface UserEntitlementSummary {
|
||||
planId: number | null;
|
||||
name: string;
|
||||
planType: string;
|
||||
monthlyTopicLimit: number | null;
|
||||
monthlyTopicUsed: number;
|
||||
monthlyTopicRemaining: number | null;
|
||||
enableGrowthProfile: boolean;
|
||||
enablePeriodicReports: boolean;
|
||||
allowHelpCard: boolean;
|
||||
allowShareDraft: boolean;
|
||||
deductQuota: boolean;
|
||||
effectiveAt?: string | null;
|
||||
expiredAt?: string | null;
|
||||
source: string;
|
||||
}
|
||||
|
||||
export interface LoginResult {
|
||||
|
||||
Reference in New Issue
Block a user