fix: #589 improve unauthorized tips

This commit is contained in:
Yidadaa
2023-04-09 23:51:12 +08:00
parent 4a492264a1
commit 0e05733bbb
6 changed files with 66 additions and 48 deletions

View File

@@ -19,6 +19,7 @@ import {
BOT_HELLO,
ROLES,
createMessage,
useAccessStore,
} from "../store";
import {
@@ -485,11 +486,17 @@ export function Chat(props: {
const context: RenderMessage[] = session.context.slice();
const accessStore = useAccessStore();
if (
context.length === 0 &&
session.messages.at(0)?.content !== BOT_HELLO.content
) {
context.push(BOT_HELLO);
const copiedHello = Object.assign({}, BOT_HELLO);
if (!accessStore.isAuthorized()) {
copiedHello.content = Locale.Error.Unauthorized;
}
context.push(copiedHello);
}
// preview messages