Add QR code login and user management endpoints

Introduces endpoints for QR code-based login and user management in the stream-gears server. Adds support for creating, deleting, and listing users, as well as endpoints for QR code generation and login via QR code. Refactors configuration management to use a global LazyLock, updates model serialization for streamer hooks, and improves context and service registration to support stateless clients. Also updates the frontend to handle new user and QR code flows, and adds an image resource for donation display in the README.
This commit is contained in:
ForgQi committed 2025-09-20 21:43:51 +08:00
1 parent fe163af02d
commit a5faefb533
31 files changed
+265 -161

No files matched your search

+1
View File
@@ -23,6 +23,7 @@ export function useBiliUsers() {
const [list, setList] = useState<any[]>([]);
useEffect(() => {
if (!data || data.length === 0) {
setList([])
return;
}
const updateList = async (item: User) => {
+5 -6
View File
@@ -29,16 +29,11 @@ const Qrcode: React.FC<QrcodeProps> = ({ onSuccess }) => {
body: JSON.stringify(qrData),
signal: signal,
})
if (!(res.status >= 200 && res.status < 300)) {
throw new Error(await res.text())
}
const data = await res.json()
if (!res.ok) {
throw new Error(data.message)
}
onSuccess(data['filename'])
})().catch(e => {
console.log(e)
setUrl(e.message)
Notification.error({
title: 'QRcode',
content: <Typography.Paragraph style={{ maxWidth: 450 }}>{e.message}</Typography.Paragraph>,
@@ -53,6 +48,10 @@ const Qrcode: React.FC<QrcodeProps> = ({ onSuccess }) => {
if (url === '') {
return <Spin />
}
if (!url.startsWith("http")) {
return <> {url} </>
}
return (
<div
style={{
+7 -5
View File
@@ -37,7 +37,7 @@ type UserListProps = {
children?: React.ReactNode
}
const UserList: React.FC<UserListProps> = ({ onCancel, visible }) => {
const { trigger } = useSWRMutation('/v1/users', sendRequest<User>)
const { trigger } = useSWRMutation('/v1/users', sendRequest)
const { trigger: deleteUser } = useSWRMutation('/v1/users', requestDelete)
const { biliUsers: list } = useBiliUsers()
const [modalVisible, setVisible] = useState(false)
@@ -55,10 +55,12 @@ const UserList: React.FC<UserListProps> = ({ onCancel, visible }) => {
throw new Error(ret.message)
}
await trigger({
id: 0,
name: value,
value: value,
platform: 'bilibili-cookies',
// id: 0,
// name: value,
// value: value,
// platform: 'bilibili-cookies',
key: 'bilibili-cookies',
value: value
})
setVisible(false)
Toast.success('创建成功')