mirror of
https://github.com/Megghy/vtsuru.live.git
synced 2025-12-06 18:36:55 +08:00
improve point functions
This commit is contained in:
@@ -16,9 +16,12 @@ export enum IndexTypes {
|
||||
export enum SongListTypes {
|
||||
Default,
|
||||
}
|
||||
export interface UserInfo {
|
||||
export interface UserBasicInfo {
|
||||
name: string
|
||||
id: number
|
||||
isBiliAuthed: boolean
|
||||
}
|
||||
export interface UserInfo extends UserBasicInfo {
|
||||
createAt: number
|
||||
biliId?: number
|
||||
biliRoomId?: number
|
||||
@@ -234,7 +237,7 @@ export enum FunctionTypes {
|
||||
SongRequest,
|
||||
Queue,
|
||||
Point,
|
||||
VideoCollect
|
||||
VideoCollect,
|
||||
}
|
||||
export interface SongAuthorInfo {
|
||||
name: string
|
||||
@@ -293,8 +296,8 @@ export interface NotifactionInfo {
|
||||
}
|
||||
export interface QAInfo {
|
||||
id: number
|
||||
sender: UserInfo
|
||||
target: UserInfo
|
||||
sender: UserBasicInfo
|
||||
target: UserBasicInfo
|
||||
question: { message: string; image?: string }
|
||||
answer?: { message: string; image?: string }
|
||||
isReaded?: boolean
|
||||
@@ -356,7 +359,7 @@ export interface VideoCollectTable {
|
||||
isFinish: boolean
|
||||
videoCount: number
|
||||
maxVideoCount: number
|
||||
owner: UserInfo
|
||||
owner: UserBasicInfo
|
||||
}
|
||||
export interface VideoCollectVideo {
|
||||
id: string
|
||||
|
||||
@@ -70,7 +70,22 @@ const historyColumn: DataTableColumns<ResponsePointHisrotyModel> = [
|
||||
const get = () => {
|
||||
switch (row.from) {
|
||||
case PointFrom.Danmaku:
|
||||
return h(NTag, { type: 'info', bordered: false, size: 'small' }, () => '直播间')
|
||||
return h(NFlex, { align: 'center' }, () => [
|
||||
h(NTag, { type: 'info', bordered: false, size: 'small' }, () => '直播间'),
|
||||
row.extra?.user
|
||||
? h(
|
||||
NButton,
|
||||
{
|
||||
tag: 'a',
|
||||
href: '/@' + row.extra.user?.name,
|
||||
target: '_blank',
|
||||
text: true,
|
||||
type: 'success',
|
||||
},
|
||||
() => row.extra.user?.name,
|
||||
)
|
||||
: null,
|
||||
])
|
||||
case PointFrom.Manual:
|
||||
return h(
|
||||
NTag,
|
||||
@@ -95,17 +110,22 @@ const historyColumn: DataTableColumns<ResponsePointHisrotyModel> = [
|
||||
case EventDataTypes.Guard:
|
||||
return h(NFlex, { justify: 'center', align: 'center' }, () => [
|
||||
h(NTag, { type: 'error', size: 'small' }, () => '上舰'),
|
||||
row.extra?.msg,
|
||||
row.extra?.danmaku.msg,
|
||||
])
|
||||
case EventDataTypes.Gift:
|
||||
return h(NFlex, { justify: 'center' }, () => [
|
||||
return h(NFlex, { justify: 'center', align: 'center' }, () => [
|
||||
h(NTag, { type: 'info', size: 'small', style: { margin: '0' } }, () => '礼物'),
|
||||
row.extra?.msg,
|
||||
row.extra?.danmaku.msg,
|
||||
h(
|
||||
NTag,
|
||||
{ type: 'warning', size: 'tiny', style: { margin: '0' }, bordered: false },
|
||||
() => (row.extra?.danmaku.num ?? 1) + '个',
|
||||
),
|
||||
])
|
||||
case EventDataTypes.SC:
|
||||
return h(NFlex, { justify: 'center' }, () => [
|
||||
h(NTag, { type: 'warning', size: 'small', style: { margin: '0' } }, () => 'SC'),
|
||||
row.extra?.price,
|
||||
row.extra?.danmaku.price,
|
||||
])
|
||||
}
|
||||
case PointFrom.Manual:
|
||||
|
||||
@@ -120,6 +120,12 @@ export const useAuthStore = defineStore('BiliAuth', () => {
|
||||
}
|
||||
return []
|
||||
}
|
||||
function logout() {
|
||||
biliAuth.value = {} as BiliAuthModel
|
||||
biliTokens.value = biliTokens.value.filter((t) => t.token != currentToken.value)
|
||||
currentToken.value = ''
|
||||
console.log('[bili-auth] 已登出 Bilibili 认证')
|
||||
}
|
||||
|
||||
return {
|
||||
biliAuth,
|
||||
@@ -134,5 +140,6 @@ export const useAuthStore = defineStore('BiliAuth', () => {
|
||||
GetSpecificPoint,
|
||||
GetGoods,
|
||||
setCurrentAuth,
|
||||
logout,
|
||||
}
|
||||
})
|
||||
|
||||
@@ -21,6 +21,7 @@ import {
|
||||
NTimelineItem,
|
||||
NSteps,
|
||||
NStep,
|
||||
NPopconfirm,
|
||||
} from 'naive-ui'
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
@@ -78,8 +79,8 @@ async function checkStatus() {
|
||||
clearInterval(timer.value)
|
||||
message.success('认证成功')
|
||||
|
||||
currentToken.value = data.data as string
|
||||
useAuth.getAuthInfo()
|
||||
guidKey.value = uuidv4()
|
||||
useAuth.setCurrentAuth(data.data as string)
|
||||
|
||||
currentStep.value = 2
|
||||
|
||||
@@ -194,8 +195,8 @@ onMounted(async () => {
|
||||
</NInputGroup>
|
||||
<NFlex>
|
||||
<NButton @click="$router.push({ name: 'bili-user' })" type="primary"> 前往个人中心 </NButton>
|
||||
<NButton
|
||||
@click="
|
||||
<NPopconfirm
|
||||
@positive-click="
|
||||
() => {
|
||||
currentStep = 0
|
||||
//@ts-ignore
|
||||
@@ -203,10 +204,13 @@ onMounted(async () => {
|
||||
guidKey = uuidv4()
|
||||
}
|
||||
"
|
||||
type="warning"
|
||||
positive-text="继续"
|
||||
>
|
||||
重新认证
|
||||
</NButton>
|
||||
<template #trigger>
|
||||
<NButton type="warning"> 认证其他账号 </NButton>
|
||||
</template>
|
||||
这将会登出当前已认证的账号, 请先在认证其他账号前保存你的登陆链接
|
||||
</NPopconfirm>
|
||||
</NFlex>
|
||||
</NFlex>
|
||||
</template>
|
||||
|
||||
@@ -164,11 +164,12 @@ function gotoAuthPage() {
|
||||
message.error('你尚未进行 Bilibili 认证, 请前往面板进行认证和绑定')
|
||||
return
|
||||
}
|
||||
useAuthStore()
|
||||
/*useAuthStore()
|
||||
.setCurrentAuth(accountInfo.value?.biliUserAuthInfo.token)
|
||||
.then(() => {
|
||||
NavigateToNewTab('/bili-user')
|
||||
})
|
||||
})*/
|
||||
NavigateToNewTab('/bili-user')
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
@@ -212,7 +213,13 @@ onMounted(async () => {
|
||||
<NFlex justify="space-between" align="center">
|
||||
<NTooltip>
|
||||
<template #trigger>
|
||||
<NButton :disabled="getTooltip(item) != '开始兑换'" size="small" type="primary" @click="onBuyClick(item)">兑换</NButton>
|
||||
<NButton
|
||||
:disabled="getTooltip(item) != '开始兑换'"
|
||||
size="small"
|
||||
type="primary"
|
||||
@click="onBuyClick(item)"
|
||||
>兑换</NButton
|
||||
>
|
||||
</template>
|
||||
{{ getTooltip(item) }}
|
||||
</NTooltip>
|
||||
|
||||
@@ -124,8 +124,16 @@ onMounted(async () => {
|
||||
<template>
|
||||
<NLayout>
|
||||
<NSpin v-if="!biliAuth.id && useAuth.currentToken" :show="useAuth.isLoading" />
|
||||
<NLayoutContent v-else-if="!useAuth.currentToken && useAuth.biliTokens.length > 0" style="height: 100vh">
|
||||
<NLayoutContent
|
||||
v-else-if="!useAuth.currentToken && useAuth.biliTokens.length > 0"
|
||||
style="height: 100vh; padding: 50px"
|
||||
>
|
||||
<NCard title="选择B站账号" embedded>
|
||||
<template #header-extra>
|
||||
<NButton type="primary" @click="$router.push({ name: 'bili-auth' })" size="small" secondary
|
||||
>认证其他账号</NButton
|
||||
>
|
||||
</template>
|
||||
<NList clickable bordered>
|
||||
<NListItem v-for="item in useAuth.biliTokens" :key="item.token" @click="switchAuth(item.token)">
|
||||
<NFlex align="center"> {{ item.name }} - {{ item.uId }} </NFlex>
|
||||
@@ -151,12 +159,15 @@ onMounted(async () => {
|
||||
<div style="max-width: 95vw; width: 900px">
|
||||
<NCard title="我的信息">
|
||||
<NDescriptions label-placement="left" bordered size="small">
|
||||
<NDescriptionsItem label="OpenId">
|
||||
{{ biliAuth.openId }}
|
||||
<NDescriptionsItem label="用户名">
|
||||
{{ biliAuth.name ?? '未知' }}
|
||||
</NDescriptionsItem>
|
||||
<NDescriptionsItem label="UserId">
|
||||
{{ biliAuth.userId }}
|
||||
</NDescriptionsItem>
|
||||
<NDescriptionsItem label="OpenId">
|
||||
{{ biliAuth.openId }}
|
||||
</NDescriptionsItem>
|
||||
</NDescriptions>
|
||||
</NCard>
|
||||
<NDivider />
|
||||
|
||||
@@ -25,7 +25,7 @@ NScrollbar,
|
||||
NSelect,
|
||||
NSpin,
|
||||
NTag,
|
||||
useMessage
|
||||
useMessage,
|
||||
} from 'naive-ui'
|
||||
import { computed, ref } from 'vue'
|
||||
//@ts-expect-error 导入有点问题
|
||||
@@ -223,6 +223,10 @@ function switchAuth(token: string) {
|
||||
useAuth.setCurrentAuth(token)
|
||||
message.success('已切换账号')
|
||||
}
|
||||
|
||||
function logout() {
|
||||
useAuth.logout()
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -261,9 +265,20 @@ function switchAuth(token: string) {
|
||||
</NList>
|
||||
</NFlex>
|
||||
</NCollapseItem>
|
||||
<NCollapseItem title="登录链接" name="2">
|
||||
<NInput type="textarea" :value="'https://vtsuru.live/bili-user?auth=' + useAuth.biliToken" readonly />
|
||||
</NCollapseItem>
|
||||
</NCollapse>
|
||||
</NCard>
|
||||
<NCard title="账号操作" embedded>
|
||||
<NFlex>
|
||||
<NPopconfirm @positive-click="logout">
|
||||
<template #trigger>
|
||||
<NButton type="warning" size="small"> 登出 </NButton>
|
||||
</template>
|
||||
确定要登出吗?
|
||||
</NPopconfirm>
|
||||
</NFlex>
|
||||
<NDivider> 切换账号 </NDivider>
|
||||
<NList clickable bordered>
|
||||
<NListItem v-for="item in useAuth.biliTokens" :key="item.token" @click="switchAuth(item.token)">
|
||||
|
||||
Reference in New Issue
Block a user