mirror of
https://github.com/Megghy/vtsuru.live.git
synced 2025-12-06 18:36:55 +08:00
1011
This commit is contained in:
@@ -15,6 +15,7 @@
|
|||||||
"@vueuse/router": "^10.1.2",
|
"@vueuse/router": "^10.1.2",
|
||||||
"core-js": "^3.8.3",
|
"core-js": "^3.8.3",
|
||||||
"grapheme-splitter": "^1.0.4",
|
"grapheme-splitter": "^1.0.4",
|
||||||
|
"linqts": "^1.15.0",
|
||||||
"universal-cookie": "^4.0.4",
|
"universal-cookie": "^4.0.4",
|
||||||
"vite": "^4.3.9",
|
"vite": "^4.3.9",
|
||||||
"vue": "^3.2.13",
|
"vue": "^3.2.13",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<NMessageProvider>
|
<NMessageProvider>
|
||||||
<NNotificationProvider>
|
<NNotificationProvider>
|
||||||
<NConfigProvider :theme-overrides="themeOverrides" :locale="zhCN" style="height: 100vh">
|
<NConfigProvider :theme-overrides="themeOverrides" style="height: 100vh" :locale="zhCN" :date-locale="dateZhCN">
|
||||||
<ViewerLayout v-if="layout == 'viewer'" />
|
<ViewerLayout v-if="layout == 'viewer'" />
|
||||||
<ManageLayout v-else-if="layout == 'manage'" />
|
<ManageLayout v-else-if="layout == 'manage'" />
|
||||||
<template v-else>
|
<template v-else>
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
import ViewerLayout from '@/views/ViewerLayout.vue'
|
import ViewerLayout from '@/views/ViewerLayout.vue'
|
||||||
import ManageLayout from '@/views/ManageLayout.vue'
|
import ManageLayout from '@/views/ManageLayout.vue'
|
||||||
import { useRoute } from 'vue-router'
|
import { useRoute } from 'vue-router'
|
||||||
import { NConfigProvider, NMessageProvider, NNotificationProvider, zhCN } from 'naive-ui'
|
import { NConfigProvider, NMessageProvider, NNotificationProvider, zhCN, dateZhCN } from 'naive-ui'
|
||||||
import { computed } from 'vue'
|
import { computed } from 'vue'
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
|
|||||||
@@ -17,13 +17,13 @@ export async function GetSelfAccount() {
|
|||||||
ACCOUNT.value = result.data
|
ACCOUNT.value = result.data
|
||||||
console.log('[vtsuru] 已获取账户信息')
|
console.log('[vtsuru] 已获取账户信息')
|
||||||
return result.data
|
return result.data
|
||||||
} else if (result.code == 403) {
|
} else if (result.code == 401) {
|
||||||
cookie.value = ''
|
localStorage.removeItem('JWT_Token')
|
||||||
console.warn('[vtsuru] Cookie 已失效, 需要重新登陆')
|
console.warn('[vtsuru] Cookie 已失效, 需要重新登陆')
|
||||||
message.error('Cookie 已失效, 需要重新登陆')
|
message.error('Cookie 已失效, 需要重新登陆')
|
||||||
}
|
location.reload()
|
||||||
else {
|
} else {
|
||||||
console.warn('[vtsuru] '+ result.message)
|
console.warn('[vtsuru] ' + result.message)
|
||||||
message.error(result.message)
|
message.error(result.message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,3 +95,19 @@ export interface QAInfo {
|
|||||||
isFavorite:boolean
|
isFavorite:boolean
|
||||||
sendAt: number
|
sendAt: number
|
||||||
}
|
}
|
||||||
|
export interface LotteryUserInfo {
|
||||||
|
name: string
|
||||||
|
uId: number
|
||||||
|
level?: number
|
||||||
|
avatar: string
|
||||||
|
location?: string
|
||||||
|
isVIP?: boolean
|
||||||
|
card?: LotteryUserCardInfo
|
||||||
|
}
|
||||||
|
export interface LotteryUserCardInfo {
|
||||||
|
name: string
|
||||||
|
level: number
|
||||||
|
guardLevel: number
|
||||||
|
isGuard: boolean
|
||||||
|
isCharge: boolean
|
||||||
|
}
|
||||||
|
|||||||
@@ -16,6 +16,20 @@ export async function QueryPostAPI<T>(url: string, body?: unknown, headers?: [st
|
|||||||
}) // 不处理异常, 在页面处理
|
}) // 不处理异常, 在页面处理
|
||||||
return (await data.json()) as APIRoot<T>
|
return (await data.json()) as APIRoot<T>
|
||||||
}
|
}
|
||||||
|
export async function QueryPostAPIWithParams<T>(urlString: string, params?: any, body?: any, contentType?: string, headers?: [string, string][]): Promise<APIRoot<T>> {
|
||||||
|
const url = new URL(urlString)
|
||||||
|
url.search = new URLSearchParams(params).toString()
|
||||||
|
headers ??= []
|
||||||
|
headers?.push(['Authorization', `Bearer ${cookie.value}`])
|
||||||
|
if (contentType) headers?.push(['Content-Type', contentType])
|
||||||
|
|
||||||
|
const data = await fetch(url, {
|
||||||
|
method: 'post',
|
||||||
|
headers: headers,
|
||||||
|
body: body,
|
||||||
|
}) // 不处理异常, 在页面处理
|
||||||
|
return (await data.json()) as APIRoot<T>
|
||||||
|
}
|
||||||
export async function QueryGetAPI<T>(urlString: string, params?: any, headers?: [string, string][]): Promise<APIRoot<T>> {
|
export async function QueryGetAPI<T>(urlString: string, params?: any, headers?: [string, string][]): Promise<APIRoot<T>> {
|
||||||
const url = new URL(urlString)
|
const url = new URL(urlString)
|
||||||
url.search = new URLSearchParams(params).toString()
|
url.search = new URLSearchParams(params).toString()
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { GetSelfAccount } from '@/api/account'
|
import { GetSelfAccount } from '@/api/account'
|
||||||
|
import { AccountInfo } from '@/api/api-models'
|
||||||
import { QueryGetAPI, QueryPostAPI } from '@/api/query'
|
import { QueryGetAPI, QueryPostAPI } from '@/api/query'
|
||||||
import { ACCOUNT_API_URL, TURNSTILE_KEY } from '@/data/constants'
|
import { ACCOUNT_API_URL, TURNSTILE_KEY } from '@/data/constants'
|
||||||
import { GetNotifactions } from '@/data/notifactions'
|
import { GetNotifactions } from '@/data/notifactions'
|
||||||
@@ -128,7 +129,10 @@ function onLoginButtonClick(e: MouseEvent) {
|
|||||||
|
|
||||||
formRef.value?.validate().then(async () => {
|
formRef.value?.validate().then(async () => {
|
||||||
isLoading.value = true
|
isLoading.value = true
|
||||||
await QueryPostAPI<string>(
|
await QueryPostAPI<{
|
||||||
|
account: AccountInfo
|
||||||
|
token: string
|
||||||
|
}>(
|
||||||
ACCOUNT_API_URL + 'login',
|
ACCOUNT_API_URL + 'login',
|
||||||
{
|
{
|
||||||
nameOrEmail: loginModel.value.account,
|
nameOrEmail: loginModel.value.account,
|
||||||
@@ -138,13 +142,11 @@ function onLoginButtonClick(e: MouseEvent) {
|
|||||||
)
|
)
|
||||||
.then(async (data) => {
|
.then(async (data) => {
|
||||||
if (data.code == 200) {
|
if (data.code == 200) {
|
||||||
cookie.value = data.data
|
localStorage.setItem('JWT_Token', data.data.token)
|
||||||
|
message.success(`成功登陆为 ${data?.data.account.name}`)
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
GetSelfAccount().then((data) => {
|
location.reload()
|
||||||
message.success(`成功登陆为 ${data?.name}`)
|
}, 1000)
|
||||||
GetNotifactions();
|
|
||||||
})
|
|
||||||
}, 1)
|
|
||||||
} else {
|
} else {
|
||||||
message.error(data.message)
|
message.error(data.message)
|
||||||
}
|
}
|
||||||
@@ -161,57 +163,51 @@ function onLoginButtonClick(e: MouseEvent) {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<NSpin :show="isLoading">
|
<NCard embedded>
|
||||||
<NCard embedded>
|
<template #header-extra>
|
||||||
<template #header-extra>
|
<slot name="header-extra"> </slot>
|
||||||
<slot name="header-extra"> </slot>
|
</template>
|
||||||
</template>
|
<template v-if="cookie">
|
||||||
<template v-if="cookie">
|
<NAlert type="warning"> 你已经登录 </NAlert>
|
||||||
<NAlert type="warning"> 你已经登录 </NAlert>
|
</template>
|
||||||
</template>
|
<template v-else>
|
||||||
<template v-else>
|
<NTabs default-value="login" size="large" animated pane-wrapper-style="margin: 0 -4px" pane-style="padding-left: 4px; padding-right: 4px; box-sizing: border-box;">
|
||||||
<NTabs default-value="login" size="large" animated pane-wrapper-style="margin: 0 -4px" pane-style="padding-left: 4px; padding-right: 4px; box-sizing: border-box;">
|
<NTabPane name="login" tab="登陆">
|
||||||
<NTabPane name="login" tab="登陆">
|
<NForm ref="formRef" :rules="loginRules" :model="loginModel">
|
||||||
<NForm ref="formRef" :rules="loginRules" :model="loginModel">
|
<NFormItem path="account" label="用户名或邮箱">
|
||||||
<NFormItem path="account" label="用户名或邮箱">
|
<NInput v-model:value="loginModel.account" />
|
||||||
<NInput v-model:value="loginModel.account" />
|
</NFormItem>
|
||||||
</NFormItem>
|
<NFormItem path="password" label="密码">
|
||||||
<NFormItem path="password" label="密码">
|
<NInput v-model:value="loginModel.password" type="password" @input="onPasswordInput" @keydown.enter.prevent />
|
||||||
<NInput v-model:value="loginModel.password" type="password" @input="onPasswordInput" @keydown.enter.prevent />
|
</NFormItem>
|
||||||
</NFormItem>
|
</NForm>
|
||||||
</NForm>
|
<NSpace vertical justify="center" align="center">
|
||||||
<NSpace vertical justify="center" align="center">
|
<NButton :loading="!token || isLoading" type="primary" size="large" @click="onLoginButtonClick"> 登陆 </NButton>
|
||||||
<NSpin :show="!token">
|
</NSpace>
|
||||||
<NButton type="primary" size="large" @click="onLoginButtonClick"> 登陆 </NButton>
|
</NTabPane>
|
||||||
</NSpin>
|
<NTabPane name="register" tab="注册">
|
||||||
</NSpace>
|
<NForm ref="formRef" :rules="registerRules" :model="registerModel">
|
||||||
</NTabPane>
|
<NFormItem path="username" label="用户名">
|
||||||
<NTabPane name="register" tab="注册">
|
<NInput v-model:value="registerModel.username" />
|
||||||
<NForm ref="formRef" :rules="registerRules" :model="registerModel">
|
</NFormItem>
|
||||||
<NFormItem path="username" label="用户名">
|
<NFormItem path="email" label="邮箱">
|
||||||
<NInput v-model:value="registerModel.username" />
|
<NInput v-model:value="registerModel.email" />
|
||||||
</NFormItem>
|
</NFormItem>
|
||||||
<NFormItem path="email" label="邮箱">
|
<NFormItem path="password" label="密码">
|
||||||
<NInput v-model:value="registerModel.email" />
|
<NInput v-model:value="registerModel.password" type="password" @input="onPasswordInput" @keydown.enter.prevent />
|
||||||
</NFormItem>
|
</NFormItem>
|
||||||
<NFormItem path="password" label="密码">
|
<NFormItem ref="rPasswordFormItemRef" first path="reenteredPassword" label="重复密码">
|
||||||
<NInput v-model:value="registerModel.password" type="password" @input="onPasswordInput" @keydown.enter.prevent />
|
<NInput v-model:value="registerModel.reenteredPassword" :disabled="!registerModel.password" type="password" @keydown.enter.prevent />
|
||||||
</NFormItem>
|
</NFormItem>
|
||||||
<NFormItem ref="rPasswordFormItemRef" first path="reenteredPassword" label="重复密码">
|
</NForm>
|
||||||
<NInput v-model:value="registerModel.reenteredPassword" :disabled="!registerModel.password" type="password" @keydown.enter.prevent />
|
<NSpace vertical justify="center" align="center">
|
||||||
</NFormItem>
|
<NButton :loading="!token || isLoading" type="primary" size="large" @click="onregisterButtonClick"> 注册 </NButton>
|
||||||
</NForm>
|
</NSpace>
|
||||||
<NSpace vertical justify="center" align="center">
|
</NTabPane>
|
||||||
<NSpin :show="!token">
|
</NTabs>
|
||||||
<NButton type="primary" size="large" @click="onregisterButtonClick"> 注册 </NButton>
|
|
||||||
</NSpin>
|
|
||||||
</NSpace>
|
|
||||||
</NTabPane>
|
|
||||||
</NTabs>
|
|
||||||
|
|
||||||
<NDivider />
|
<NDivider />
|
||||||
<VueTurnstile ref="turnstile" :site-key="TURNSTILE_KEY" v-model="token" theme="auto" style="text-align: center" />
|
<VueTurnstile ref="turnstile" :site-key="TURNSTILE_KEY" v-model="token" theme="auto" style="text-align: center" />
|
||||||
</template>
|
</template>
|
||||||
</NCard>
|
</NCard>
|
||||||
</NSpin>
|
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
import { SongAuthorInfo, SongFrom, SongLanguage, SongsInfo } from '@/api/api-models'
|
import { SongAuthorInfo, SongFrom, SongLanguage, SongsInfo } from '@/api/api-models'
|
||||||
import { QueryPostAPI } from '@/api/query'
|
import { QueryPostAPI } from '@/api/query'
|
||||||
import { SONG_API_URL } from '@/data/constants'
|
import { SONG_API_URL } from '@/data/constants'
|
||||||
|
import { List } from 'linqts'
|
||||||
import {
|
import {
|
||||||
DataTableColumns,
|
DataTableColumns,
|
||||||
FormInst,
|
FormInst,
|
||||||
@@ -25,7 +26,9 @@ import {
|
|||||||
NText,
|
NText,
|
||||||
useMessage,
|
useMessage,
|
||||||
} from 'naive-ui'
|
} from 'naive-ui'
|
||||||
import { onMounted, h, ref, watch } from 'vue'
|
import { FilterOptionValue } from 'naive-ui/es/data-table/src/interface'
|
||||||
|
import { nextTick } from 'process'
|
||||||
|
import { onMounted, h, ref, watch, computed } from 'vue'
|
||||||
import APlayer from 'vue3-aplayer'
|
import APlayer from 'vue3-aplayer'
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
@@ -104,118 +107,135 @@ const songSelectOption = [
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
const tagsSelectOption = ref<{ label: string; value: string }[]>([])
|
const tagsSelectOption = ref<{ label: string; value: string }[]>([])
|
||||||
|
const tags = ref<string[]>([])
|
||||||
|
const tagsOptions = computed(() => {
|
||||||
|
return tags.value.map((t) => ({
|
||||||
|
label: t,
|
||||||
|
value: t,
|
||||||
|
}))
|
||||||
|
})
|
||||||
|
|
||||||
const createColumns = (): DataTableColumns<SongsInfo> => [
|
function createColumns(): DataTableColumns<SongsInfo> {
|
||||||
{
|
return [
|
||||||
title: '名称',
|
{
|
||||||
key: 'name',
|
title: '名称',
|
||||||
resizable: true,
|
key: 'name',
|
||||||
minWidth: 100,
|
resizable: true,
|
||||||
width: 300,
|
minWidth: 100,
|
||||||
sorter: 'default',
|
width: 300,
|
||||||
render(data) {
|
sorter: 'default',
|
||||||
return h(NSpace, { size: 5 }, () => [h(NText, () => data.name), h(NText, { depth: '3' }, () => data.translateName)])
|
render(data) {
|
||||||
|
return h(NSpace, { size: 5 }, () => [h(NText, () => data.name), h(NText, { depth: '3' }, () => data.translateName)])
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
{
|
||||||
{
|
title: '作者',
|
||||||
title: '作者',
|
key: 'artist',
|
||||||
key: 'artist',
|
width: 200,
|
||||||
width: 200,
|
resizable: true,
|
||||||
resizable: true,
|
render(data) {
|
||||||
render(data) {
|
return h(NSpace, { size: 5 }, () => data.author.map((a) => h(NTag, { bordered: false, size: 'small', type: 'info' }, () => a)))
|
||||||
return h(NSpace, { size: 5 }, () => data.author.map((a) => h(NTag, { bordered: false, size: 'small', type: 'info' }, () => a)))
|
},
|
||||||
},
|
},
|
||||||
},
|
{
|
||||||
{
|
title: '语言',
|
||||||
title: '语言',
|
key: 'language',
|
||||||
key: 'language',
|
width: 150,
|
||||||
width: 150,
|
resizable: true,
|
||||||
resizable: true,
|
render(data) {
|
||||||
render(data) {
|
return (data.language?.length ?? 0) > 0
|
||||||
return (data.language?.length ?? 0) > 0
|
? h(NSpace, { size: 5 }, () => data.language?.map((a) => h(NTag, { bordered: false, size: 'small' }, () => songSelectOption.find((s) => s.value == a)?.label)))
|
||||||
? h(NSpace, { size: 5 }, () => data.language?.map((a) => h(NTag, { bordered: false, size: 'small' }, () => songSelectOption.find((s) => s.value == a)?.label)))
|
: null
|
||||||
: null
|
},
|
||||||
},
|
},
|
||||||
},
|
{
|
||||||
{
|
title: '描述',
|
||||||
title: '描述',
|
key: 'description',
|
||||||
key: 'description',
|
resizable: true,
|
||||||
resizable: true,
|
render(data) {
|
||||||
render(data) {
|
return h(NEllipsis, () => data.description)
|
||||||
return h(NEllipsis, () => data.description)
|
},
|
||||||
},
|
},
|
||||||
},
|
{
|
||||||
{
|
title: '标签',
|
||||||
title: '标签',
|
key: 'tags',
|
||||||
key: 'tags',
|
resizable: true,
|
||||||
resizable: true,
|
filter(value, row) {
|
||||||
render(data) {
|
return (row.tags?.findIndex((t) => t == value.toString()) ?? -1) > -1
|
||||||
return (data.tags?.length ?? 0) > 0 ? h(NSpace, { size: 5 }, () => data.tags?.map((a) => h(NTag, { bordered: false, size: 'small' }, () => a))) : null
|
},
|
||||||
|
filterOptions: tagsOptions.value,
|
||||||
|
render(data) {
|
||||||
|
return (data.tags?.length ?? 0) > 0 ? h(NSpace, { size: 5 }, () => data.tags?.map((a) => h(NTag, { bordered: false, size: 'small' }, () => a))) : null
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
{
|
||||||
{
|
title: '操作',
|
||||||
title: '操作',
|
key: 'manage',
|
||||||
key: 'manage',
|
disabled: () => !props.canEdit,
|
||||||
disabled: () => !props.canEdit,
|
width: 200,
|
||||||
width: 200,
|
render(data) {
|
||||||
render(data) {
|
return h(
|
||||||
return h(NSpace, {
|
NSpace,
|
||||||
justify: 'space-around'
|
|
||||||
}, () => [
|
|
||||||
h(
|
|
||||||
NButton,
|
|
||||||
{
|
{
|
||||||
size: 'small',
|
justify: 'space-around',
|
||||||
onClick: () => {
|
|
||||||
updateSongModel.value = JSON.parse(JSON.stringify(data))
|
|
||||||
showModal.value = true
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
() => [
|
||||||
default: () => '修改',
|
h(
|
||||||
}
|
NButton,
|
||||||
),
|
{
|
||||||
h(
|
size: 'small',
|
||||||
NButton,
|
onClick: () => {
|
||||||
{
|
updateSongModel.value = JSON.parse(JSON.stringify(data))
|
||||||
type: 'primary',
|
showModal.value = true
|
||||||
size: 'small',
|
},
|
||||||
onClick: () => {
|
},
|
||||||
aplayerMusic.value = {
|
{
|
||||||
title: data.name,
|
default: () => '修改',
|
||||||
artist: data.author.join('/') ?? '',
|
|
||||||
src: data.url,
|
|
||||||
pic: '',
|
|
||||||
}
|
}
|
||||||
},
|
),
|
||||||
},
|
h(
|
||||||
{
|
NButton,
|
||||||
default: () => '播放',
|
{
|
||||||
}
|
type: 'primary',
|
||||||
),
|
size: 'small',
|
||||||
h(
|
onClick: () => {
|
||||||
NButton,
|
aplayerMusic.value = {
|
||||||
{
|
title: data.name,
|
||||||
type: 'error',
|
artist: data.author.join('/') ?? '',
|
||||||
size: 'small',
|
src: data.url,
|
||||||
onClick: () => {
|
pic: '',
|
||||||
aplayerMusic.value = {
|
}
|
||||||
title: data.name,
|
},
|
||||||
artist: data.author.join('/') ?? '',
|
},
|
||||||
src: data.url,
|
{
|
||||||
pic: '',
|
default: () => '播放',
|
||||||
}
|
}
|
||||||
},
|
),
|
||||||
},
|
h(
|
||||||
{
|
NButton,
|
||||||
default: () => '删除',
|
{
|
||||||
}
|
type: 'error',
|
||||||
),
|
size: 'small',
|
||||||
GetPlayButton(data),
|
onClick: () => {
|
||||||
])
|
aplayerMusic.value = {
|
||||||
|
title: data.name,
|
||||||
|
artist: data.author.join('/') ?? '',
|
||||||
|
src: data.url,
|
||||||
|
pic: '',
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
default: () => '删除',
|
||||||
|
}
|
||||||
|
),
|
||||||
|
GetPlayButton(data),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
]
|
||||||
]
|
}
|
||||||
function GetPlayButton(song: SongsInfo) {
|
function GetPlayButton(song: SongsInfo) {
|
||||||
switch (song.from) {
|
switch (song.from) {
|
||||||
case SongFrom.FiveSing: {
|
case SongFrom.FiveSing: {
|
||||||
@@ -273,7 +293,13 @@ async function updateSong() {
|
|||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
songsInternal.value = props.songs
|
songsInternal.value = props.songs
|
||||||
columns.value = createColumns()
|
tags.value = new List(songsInternal.value)
|
||||||
|
.SelectMany((s) => new List(s?.tags))
|
||||||
|
.Distinct()
|
||||||
|
.ToArray()
|
||||||
|
setTimeout(() => {
|
||||||
|
columns.value = createColumns()
|
||||||
|
}, 1)
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -12,3 +12,4 @@ export const BILI_API_URL = `${BASE_API}bili/`
|
|||||||
export const SONG_API_URL = `${BASE_API}song-list/`
|
export const SONG_API_URL = `${BASE_API}song-list/`
|
||||||
export const NOTIFACTION_API_URL = `${BASE_API}notifaction/`
|
export const NOTIFACTION_API_URL = `${BASE_API}notifaction/`
|
||||||
export const QUESTION_API_URL = `${BASE_API}qa/`
|
export const QUESTION_API_URL = `${BASE_API}qa/`
|
||||||
|
export const LOTTERY_API_URL = `${BASE_API}lottery/`
|
||||||
|
|||||||
@@ -65,6 +65,11 @@ const routes: Array<RouteRecordRaw> = [
|
|||||||
name: 'manage-questionBox',
|
name: 'manage-questionBox',
|
||||||
component: () => import('@/views/manage/QuestionBoxManageView.vue'),
|
component: () => import('@/views/manage/QuestionBoxManageView.vue'),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: 'lottery',
|
||||||
|
name: 'manage-lottery',
|
||||||
|
component: () => import('@/views/manage/LotteryView.vue'),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: 'bili-verify',
|
path: 'bili-verify',
|
||||||
name: 'manage-biliVerify',
|
name: 'manage-biliVerify',
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ const menuOptions = [
|
|||||||
},
|
},
|
||||||
{ default: () => '歌单' }
|
{ default: () => '歌单' }
|
||||||
),
|
),
|
||||||
key: 'song-list',
|
key: 'manage-songList',
|
||||||
icon: renderIcon(BookOutline),
|
icon: renderIcon(BookOutline),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -36,9 +36,9 @@ const menuOptions = [
|
|||||||
name: 'manage-questionBox',
|
name: 'manage-questionBox',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ default: () => '棉花糖(提问箱' }
|
{ default: () => '棉花糖 (提问箱' }
|
||||||
),
|
),
|
||||||
key: 'song-list',
|
key: 'manage-questionBox',
|
||||||
icon: renderIcon(BookOutline),
|
icon: renderIcon(BookOutline),
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
@@ -52,7 +52,7 @@ const menuOptions = [
|
|||||||
<NButton>
|
<NButton>
|
||||||
<RouterLink :to="{ name: 'manage-index' }"> 个人中心 </RouterLink>
|
<RouterLink :to="{ name: 'manage-index' }"> 个人中心 </RouterLink>
|
||||||
</NButton>
|
</NButton>
|
||||||
<NMenu :collapsed-width="64" :collapsed-icon-size="22" :options="menuOptions" />
|
<NMenu :default-value="$route.name?.toString()" :collapsed-width="64" :collapsed-icon-size="22" :options="menuOptions" />
|
||||||
</NLayoutSider>
|
</NLayoutSider>
|
||||||
<NLayout style="height: 100%">
|
<NLayout style="height: 100%">
|
||||||
<div style="box-sizing: border-box; padding: 20px">
|
<div style="box-sizing: border-box; padding: 20px">
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<!-- eslint-disable vue/component-name-in-template-casing -->
|
<!-- eslint-disable vue/component-name-in-template-casing -->
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { NAvatar, NCard, NIcon, NLayout, NLayoutFooter, NLayoutHeader, NLayoutSider, NMenu, NSpace, NText, NButton, NEmpty, NResult, NPageHeader, NSwitch, useOsTheme } from 'naive-ui'
|
import { NAvatar, NCard, NIcon, NLayout, NLayoutFooter, NLayoutHeader, NLayoutSider, NMenu, NSpace, NText, NButton, NEmpty, NResult, NPageHeader, NSwitch, useOsTheme, NModal } from 'naive-ui'
|
||||||
import { computed, h, onMounted, ref } from 'vue'
|
import { computed, h, onMounted, ref } from 'vue'
|
||||||
import { BookOutline as BookIcon, PersonOutline as PersonIcon, WineOutline as WineIcon } from '@vicons/ionicons5'
|
import { BookOutline as BookIcon, PersonOutline as PersonIcon, WineOutline as WineIcon } from '@vicons/ionicons5'
|
||||||
import { GetInfo, useUser, useUserWithUId } from '@/api/user'
|
import { GetInfo, useUser, useUserWithUId } from '@/api/user'
|
||||||
@@ -8,6 +8,7 @@ import { RouterLink, useRoute } from 'vue-router'
|
|||||||
import { UserInfo } from '@/api/api-models'
|
import { UserInfo } from '@/api/api-models'
|
||||||
import { FETCH_API } from '@/data/constants'
|
import { FETCH_API } from '@/data/constants'
|
||||||
import { useAccount } from '@/api/account'
|
import { useAccount } from '@/api/account'
|
||||||
|
import RegisterAndLogin from '@/components/RegisterAndLogin.vue'
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const id = computed(() => {
|
const id = computed(() => {
|
||||||
@@ -19,6 +20,8 @@ const userInfo = ref<UserInfo>()
|
|||||||
const biliUserInfo = ref()
|
const biliUserInfo = ref()
|
||||||
const accountInfo = useAccount()
|
const accountInfo = useAccount()
|
||||||
|
|
||||||
|
const registerAndLoginModalVisiable = ref(false)
|
||||||
|
|
||||||
function renderIcon(icon: unknown) {
|
function renderIcon(icon: unknown) {
|
||||||
return () => h(NIcon, null, { default: () => h(icon as any) })
|
return () => h(NIcon, null, { default: () => h(icon as any) })
|
||||||
}
|
}
|
||||||
@@ -100,7 +103,7 @@ onMounted(async () => {
|
|||||||
<NButton style="right: 0px; position: relative" type="primary" @click="$router.push({ name: 'manage-index' })"> 个人中心 </NButton>
|
<NButton style="right: 0px; position: relative" type="primary" @click="$router.push({ name: 'manage-index' })"> 个人中心 </NButton>
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<NButton style="right: 0px; position: relative" type="primary"> 注册 / 登陆 </NButton>
|
<NButton style="right: 0px; position: relative" type="primary" @click="registerAndLoginModalVisiable = true"> 注册 / 登陆 </NButton>
|
||||||
</template>
|
</template>
|
||||||
</NSpace>
|
</NSpace>
|
||||||
</template>
|
</template>
|
||||||
@@ -134,6 +137,9 @@ onMounted(async () => {
|
|||||||
</NLayout>
|
</NLayout>
|
||||||
</NLayout>
|
</NLayout>
|
||||||
</NLayout>
|
</NLayout>
|
||||||
|
<NModal v-model:show="registerAndLoginModalVisiable" style="width: 500px; max-width: 90vw;">
|
||||||
|
<RegisterAndLogin />
|
||||||
|
</NModal>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="stylus" scoped>
|
<style lang="stylus" scoped>
|
||||||
|
|||||||
49
src/views/manage/LotteryView.vue
Normal file
49
src/views/manage/LotteryView.vue
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { LotteryUserInfo } from '@/api/api-models'
|
||||||
|
import { QueryGetAPI } from '@/api/query'
|
||||||
|
import { LOTTERY_API_URL, TURNSTILE_KEY } from '@/data/constants'
|
||||||
|
import { NButton, NTabPane, NTabs, useMessage } from 'naive-ui'
|
||||||
|
import { ref } from 'vue'
|
||||||
|
import VueTurnstile from 'vue-turnstile'
|
||||||
|
|
||||||
|
interface TempLotteryResponseModel {
|
||||||
|
users: LotteryUserInfo[]
|
||||||
|
createTime: number
|
||||||
|
total: number
|
||||||
|
}
|
||||||
|
const message = useMessage()
|
||||||
|
const token = ref()
|
||||||
|
const turnstile = ref()
|
||||||
|
|
||||||
|
const commentUsers = ref<TempLotteryResponseModel>()
|
||||||
|
|
||||||
|
async function getCommentsUsers() {
|
||||||
|
await QueryGetAPI<TempLotteryResponseModel>(
|
||||||
|
LOTTERY_API_URL + 'comments',
|
||||||
|
{
|
||||||
|
id: 803541974225256452n,
|
||||||
|
},
|
||||||
|
[['Turnstile', token.value]]
|
||||||
|
)
|
||||||
|
.then((data) => {
|
||||||
|
if (data.code == 200) {
|
||||||
|
commentUsers.value = data.data
|
||||||
|
} else {
|
||||||
|
message.error('获取用户失败: ' + data.message)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.error(err)
|
||||||
|
message.error('获取失败')
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
turnstile.value?.reset()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<template>
|
||||||
|
<NTabs>
|
||||||
|
<NTabPane name="dynamic" tab="动态抽奖"> <NButton @click="getCommentsUsers" :loading="!token"> 11 </NButton> </NTabPane>
|
||||||
|
</NTabs>
|
||||||
|
<VueTurnstile ref="turnstile" :site-key="TURNSTILE_KEY" v-model="token" theme="auto" style="text-align: center" />
|
||||||
|
</template>
|
||||||
@@ -1,22 +1,38 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { QAInfo } from '@/api/api-models'
|
import { QAInfo } from '@/api/api-models'
|
||||||
import { QueryGetAPI } from '@/api/query'
|
import { QueryGetAPI, QueryPostAPI } from '@/api/query'
|
||||||
import { BASE_API, QUESTION_API_URL } from '@/data/constants'
|
import { BASE_API, QUESTION_API_URL } from '@/data/constants'
|
||||||
import { HeartOutline } from '@vicons/ionicons5'
|
import { Heart, HeartOutline } from '@vicons/ionicons5'
|
||||||
import { NButton, NCard, NDivider, NIcon, NImage, NList, NListItem, NTabPane, NTabs, NTag, useMessage } from 'naive-ui'
|
import { NButton, NCard, NDivider, NIcon, NImage, NInput, NList, NListItem, NModal, NSpace, NSwitch, NTabPane, NTabs, NTag, NText, NTime, NTooltip, useMessage } from 'naive-ui'
|
||||||
import { onMounted, ref } from 'vue'
|
import { computed, onMounted, ref } from 'vue'
|
||||||
|
import { List } from 'linqts'
|
||||||
|
import router from '@/router'
|
||||||
|
|
||||||
const recieveQuestions = ref<QAInfo[]>([])
|
const recieveQuestions = ref<QAInfo[]>([])
|
||||||
|
const recieveQuestionsFiltered = computed(() => {
|
||||||
|
return onlyFavorite.value ? recieveQuestions.value.filter((d) => d.isFavorite) : recieveQuestions.value
|
||||||
|
})
|
||||||
const sendQuestions = ref<QAInfo[]>([])
|
const sendQuestions = ref<QAInfo[]>([])
|
||||||
const message = useMessage()
|
const message = useMessage()
|
||||||
|
|
||||||
const selectedTabItem = ref('0')
|
const selectedTabItem = ref('0')
|
||||||
|
const isRepling = ref(false)
|
||||||
|
const onlyFavorite = ref(false)
|
||||||
|
|
||||||
|
const replyModalVisiable = ref(false)
|
||||||
|
const currentQuestion = ref<QAInfo>()
|
||||||
|
const replyMessage = ref()
|
||||||
|
|
||||||
async function GetRecieveQAInfo() {
|
async function GetRecieveQAInfo() {
|
||||||
await QueryGetAPI<QAInfo[]>(QUESTION_API_URL + 'get-recieve')
|
await QueryGetAPI<QAInfo[]>(QUESTION_API_URL + 'get-recieve')
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
if (data.code == 200) {
|
if (data.code == 200) {
|
||||||
recieveQuestions.value = data.data
|
if (data.data.length > 0) {
|
||||||
|
recieveQuestions.value = new List(data.data)
|
||||||
|
.OrderBy((d) => d.isReaded)
|
||||||
|
.ThenByDescending((d) => d.sendAt)
|
||||||
|
.ToArray()
|
||||||
|
}
|
||||||
message.success('共收取 ' + data.data.length + ' 条提问')
|
message.success('共收取 ' + data.data.length + ' 条提问')
|
||||||
isRevieveGetted = true
|
isRevieveGetted = true
|
||||||
} else {
|
} else {
|
||||||
@@ -43,6 +59,67 @@ async function GetSendQAInfo() {
|
|||||||
console.error(err)
|
console.error(err)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
async function reply() {
|
||||||
|
isRepling.value = true
|
||||||
|
await QueryPostAPI<QAInfo>(QUESTION_API_URL + 'reply', {
|
||||||
|
Id: currentQuestion.value?.id,
|
||||||
|
Message: replyMessage.value,
|
||||||
|
})
|
||||||
|
.then((data) => {
|
||||||
|
if (data.code == 200) {
|
||||||
|
var index = recieveQuestions.value.findIndex((q) => q.id == currentQuestion.value?.id)
|
||||||
|
if (index > -1) {
|
||||||
|
recieveQuestions.value[index] = data.data
|
||||||
|
}
|
||||||
|
message.success('回复成功')
|
||||||
|
currentQuestion.value = undefined
|
||||||
|
replyModalVisiable.value = false
|
||||||
|
} else {
|
||||||
|
message.error('发送失败: ' + data.message)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.error(err)
|
||||||
|
message.error('发送失败')
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
isRepling.value = false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
async function read(question: QAInfo, read: boolean) {
|
||||||
|
await QueryGetAPI(QUESTION_API_URL + 'read', {
|
||||||
|
id: question.id,
|
||||||
|
read: read ? 'true' : 'false',
|
||||||
|
})
|
||||||
|
.then((data) => {
|
||||||
|
if (data.code == 200) {
|
||||||
|
question.isReaded = read
|
||||||
|
} else {
|
||||||
|
message.error('修改失败: ' + data.message)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.error(err)
|
||||||
|
message.error('修改失败')
|
||||||
|
})
|
||||||
|
}
|
||||||
|
async function favorite(question: QAInfo, fav: boolean) {
|
||||||
|
await QueryGetAPI(QUESTION_API_URL + 'read', {
|
||||||
|
id: question.id,
|
||||||
|
read: fav ? 'true' : 'false',
|
||||||
|
})
|
||||||
|
.then((data) => {
|
||||||
|
if (data.code == 200) {
|
||||||
|
question.isFavorite = fav
|
||||||
|
} else {
|
||||||
|
message.error('修改失败: ' + data.message)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.error(err)
|
||||||
|
message.error('修改失败')
|
||||||
|
})
|
||||||
|
}
|
||||||
let isRevieveGetted = false
|
let isRevieveGetted = false
|
||||||
let isSendGetted = false
|
let isSendGetted = false
|
||||||
async function onTabChange(value: string) {
|
async function onTabChange(value: string) {
|
||||||
@@ -54,6 +131,11 @@ async function onTabChange(value: string) {
|
|||||||
isSendGetted = true
|
isSendGetted = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function onOpenModal(question: QAInfo) {
|
||||||
|
currentQuestion.value = question
|
||||||
|
replyMessage.value = question.answer?.message
|
||||||
|
replyModalVisiable.value = true
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
GetRecieveQAInfo()
|
GetRecieveQAInfo()
|
||||||
@@ -65,33 +147,107 @@ onMounted(() => {
|
|||||||
<NDivider style="margin: 10px 0 10px 0" />
|
<NDivider style="margin: 10px 0 10px 0" />
|
||||||
<NTabs animated @update:value="onTabChange" v-model:value="selectedTabItem">
|
<NTabs animated @update:value="onTabChange" v-model:value="selectedTabItem">
|
||||||
<NTabPane tab="我收到的" name="0">
|
<NTabPane tab="我收到的" name="0">
|
||||||
|
只显示收藏 <NSwitch v-model:value="onlyFavorite" />
|
||||||
<NList>
|
<NList>
|
||||||
<NListItem v-for="item in recieveQuestions" :key="item.id">
|
<NListItem v-for="item in recieveQuestionsFiltered" :key="item.id">
|
||||||
<NCard>
|
<NCard :embedded="!item.isReaded" hoverable size="small">
|
||||||
<template #header>
|
<template #header>
|
||||||
匿名用户
|
<NSpace :size="0" align="center">
|
||||||
<NTag v-if="item.isSenderRegisted" size="small"> 已注册 </NTag>
|
<template v-if="!item.isReaded">
|
||||||
|
<NTag type="warning" size="tiny"> 未读 </NTag>
|
||||||
|
<NDivider vertical />
|
||||||
|
</template>
|
||||||
|
<NText :depth="item.sender?.name ? 1 : 3" style="margin-top: 3px">
|
||||||
|
{{ item.sender?.name ?? '匿名用户' }}
|
||||||
|
</NText>
|
||||||
|
<NTag v-if="item.isSenderRegisted" size="small" type="info" :bordered="false" style="margin-left: 5px"> 已注册 </NTag>
|
||||||
|
<NDivider vertical />
|
||||||
|
<NText depth="3" style="font-size: small">
|
||||||
|
<NTooltip>
|
||||||
|
<template #trigger>
|
||||||
|
<NTime :time="item.sendAt" :to="Date.now()" type="relative" />
|
||||||
|
</template>
|
||||||
|
<NTime />
|
||||||
|
</NTooltip>
|
||||||
|
</NText>
|
||||||
|
</NSpace>
|
||||||
</template>
|
</template>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<NButton>
|
<NSpace>
|
||||||
<template #icon>
|
<NButton size="small" @click="favorite(item, !item.isFavorite)">
|
||||||
<NIcon :component="HeartOutline"/>
|
<template #icon>
|
||||||
</template>
|
<NIcon :component="item.isFavorite ? Heart : HeartOutline" :color="item.isFavorite ? '#dd484f' : ''"/>
|
||||||
收藏
|
</template>
|
||||||
</NButton>
|
收藏
|
||||||
<NButton>
|
</NButton>
|
||||||
举报
|
<NButton size="small"> 举报 </NButton>
|
||||||
</NButton>
|
<NButton size="small"> 拉黑 </NButton>
|
||||||
<NButton>
|
</NSpace>
|
||||||
拉黑
|
|
||||||
</NButton>
|
|
||||||
</template>
|
</template>
|
||||||
<NImage v-if="item.question.image" :src="item.question.image" />
|
<template #header-extra>
|
||||||
{{ item.question.message }}
|
<NButton @click="onOpenModal(item)" :type="item.isReaded ? 'default' : 'primary'" :secondary="item.isReaded"> {{ item.answer ? '查看回复' : '回复' }} </NButton>
|
||||||
|
</template>
|
||||||
|
<template v-if="item.question?.image">
|
||||||
|
<NImage v-if="item.question?.image" :src="item.question.image" height="100" lazy />
|
||||||
|
<br />
|
||||||
|
</template>
|
||||||
|
<NButton text @click="onOpenModal(item)">
|
||||||
|
{{ item.question?.message }}
|
||||||
|
</NButton>
|
||||||
|
</NCard>
|
||||||
|
</NListItem>
|
||||||
|
</NList>
|
||||||
|
</NTabPane>
|
||||||
|
<NTabPane tab="我发送的" name="1">
|
||||||
|
<NList>
|
||||||
|
<NListItem v-for="item in sendQuestions" :key="item.id">
|
||||||
|
<NCard hoverable size="small">
|
||||||
|
<template #header>
|
||||||
|
<NSpace :size="0" align="center">
|
||||||
|
发给
|
||||||
|
<NDivider vertical />
|
||||||
|
<NButton text type="info" @click="router.push('/user/' + item.target.id)">
|
||||||
|
{{ item.target.name }}
|
||||||
|
</NButton>
|
||||||
|
<NDivider vertical />
|
||||||
|
<NText depth="3" style="font-size: small">
|
||||||
|
<NTooltip>
|
||||||
|
<template #trigger>
|
||||||
|
<NTime :time="item.sendAt" :to="Date.now()" type="relative" />
|
||||||
|
</template>
|
||||||
|
<NTime />
|
||||||
|
</NTooltip>
|
||||||
|
</NText>
|
||||||
|
</NSpace>
|
||||||
|
</template>
|
||||||
|
<template v-if="item.answer" #footer>
|
||||||
|
<NDivider style="margin: 0" />
|
||||||
|
<NCard :bordered="false" size="small">
|
||||||
|
<template #header>
|
||||||
|
<NSpace align="center">
|
||||||
|
<NTag size="small" type="warning" :bordered="false">
|
||||||
|
{{ item.target.name }}
|
||||||
|
</NTag>
|
||||||
|
回复
|
||||||
|
</NSpace>
|
||||||
|
</template>
|
||||||
|
{{ item.answer.message }}
|
||||||
|
</NCard>
|
||||||
|
</template>
|
||||||
|
<template v-if="item.question?.image">
|
||||||
|
<NImage :src="item.question.image" height="100" lazy />
|
||||||
|
<br />
|
||||||
|
</template>
|
||||||
|
{{ item.question?.message }}
|
||||||
</NCard>
|
</NCard>
|
||||||
</NListItem>
|
</NListItem>
|
||||||
</NList>
|
</NList>
|
||||||
</NTabPane>
|
</NTabPane>
|
||||||
<NTabPane tab="我发送的" name="1"> </NTabPane>
|
|
||||||
</NTabs>
|
</NTabs>
|
||||||
|
<NModal preset="card" v-model:show="replyModalVisiable" style="max-width: 600px">
|
||||||
|
<template #header> 回复 </template>
|
||||||
|
<NInput placeholder="请输入回复" type="textarea" v-model:value="replyMessage" maxlength="1000" show-count clearable />
|
||||||
|
<NDivider style="margin: 10px 0 10px 0" />
|
||||||
|
<NButton :loading="isRepling" @click="reply" type="primary"> 发送 </NButton>
|
||||||
|
</NModal>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { NAlert, NButton, NCard, NCheckbox, NDivider, NInput, NSpace, NTab, NTabPane, NTabs, NText, useMessage } from 'naive-ui'
|
import { NAlert, NButton, NCard, NCheckbox, NDivider, NInput, NSpace, NTab, NTabPane, NTabs, NText, NUpload, UploadFileInfo, useMessage } from 'naive-ui'
|
||||||
import GraphemeSplitter from 'grapheme-splitter'
|
import GraphemeSplitter from 'grapheme-splitter'
|
||||||
import { computed, onMounted, ref } from 'vue'
|
import { computed, onMounted, ref } from 'vue'
|
||||||
import { useAccount } from '@/api/account'
|
import { useAccount } from '@/api/account'
|
||||||
import { useUser } from '@/api/user'
|
import { useUser } from '@/api/user'
|
||||||
import { QAInfo, UserInfo } from '@/api/api-models'
|
import { QAInfo, UserInfo } from '@/api/api-models'
|
||||||
import { QueryPostAPI } from '@/api/query'
|
import { QueryPostAPI, QueryPostAPIWithParams } from '@/api/query'
|
||||||
import { QUESTION_API_URL, TURNSTILE_KEY } from '@/data/constants'
|
import { QUESTION_API_URL, TURNSTILE_KEY } from '@/data/constants'
|
||||||
import VueTurnstile from 'vue-turnstile'
|
import VueTurnstile from 'vue-turnstile'
|
||||||
|
|
||||||
@@ -22,6 +22,7 @@ const isSelf = computed(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const questionMessage = ref('')
|
const questionMessage = ref('')
|
||||||
|
const fileList = ref<UploadFileInfo[]>([])
|
||||||
|
|
||||||
const isAnonymous = ref(true)
|
const isAnonymous = ref(true)
|
||||||
const isSending = ref(false)
|
const isSending = ref(false)
|
||||||
@@ -41,13 +42,14 @@ async function SendQuestion() {
|
|||||||
Target: userInfo.value?.id,
|
Target: userInfo.value?.id,
|
||||||
IsAnonymous: !accountInfo.value || isAnonymous.value,
|
IsAnonymous: !accountInfo.value || isAnonymous.value,
|
||||||
Message: questionMessage.value,
|
Message: questionMessage.value,
|
||||||
Image: '',
|
ImageBase64: fileList.value?.length > 0 ? await getBase64(fileList.value[0].file) : undefined,
|
||||||
},
|
},
|
||||||
[['Turnstile', token.value]]
|
[['Turnstile', token.value]]
|
||||||
)
|
)
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
if (data.code == 200) {
|
if (data.code == 200) {
|
||||||
message.success('成功发送棉花糖')
|
message.success('成功发送棉花糖')
|
||||||
|
questionMessage.value = ''
|
||||||
} else {
|
} else {
|
||||||
message.error(data.message)
|
message.error(data.message)
|
||||||
}
|
}
|
||||||
@@ -61,6 +63,24 @@ async function SendQuestion() {
|
|||||||
turnstile.value?.reset()
|
turnstile.value?.reset()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
function getBase64(file: File | undefined | null) {
|
||||||
|
if (!file) return null
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const reader = new FileReader()
|
||||||
|
reader.readAsDataURL(file)
|
||||||
|
reader.onload = () => resolve(reader.result?.toString().split(',')[1])
|
||||||
|
reader.onerror = (error) => reject(error)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
function OnFileListChange(files: UploadFileInfo[]) {
|
||||||
|
if (files.length == 1) {
|
||||||
|
var file = files[0]
|
||||||
|
if ((file.file?.size ?? 0) > 10 * 1024 * 1024) {
|
||||||
|
message.error('文件大小不能超过10MB')
|
||||||
|
fileList.value = []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
userInfo.value = await useUser()
|
userInfo.value = await useUser()
|
||||||
@@ -72,6 +92,20 @@ onMounted(async () => {
|
|||||||
<NSpace vertical>
|
<NSpace vertical>
|
||||||
<NInput :disabled="isSelf" show-count maxlength="1000" type="textarea" :count-graphemes="countGraphemes" v-model:value="questionMessage"> </NInput>
|
<NInput :disabled="isSelf" show-count maxlength="1000" type="textarea" :count-graphemes="countGraphemes" v-model:value="questionMessage"> </NInput>
|
||||||
<NDivider style="margin: 10px 0 10px 0" />
|
<NDivider style="margin: 10px 0 10px 0" />
|
||||||
|
<NSpace align="center">
|
||||||
|
<NUpload
|
||||||
|
:max="1"
|
||||||
|
accept=".png,.jpg,.jpeg,.gif,.svg,.webp,.ico"
|
||||||
|
list-type="image-card"
|
||||||
|
:disabled="!accountInfo || isSelf"
|
||||||
|
:default-upload="false"
|
||||||
|
v-model:file-list="fileList"
|
||||||
|
@update:file-list="OnFileListChange"
|
||||||
|
>
|
||||||
|
+ 上传图片
|
||||||
|
</NUpload>
|
||||||
|
<NAlert v-if="!accountInfo && !isSelf" type="warning"> 只有注册用户才能够上传图片 </NAlert>
|
||||||
|
</NSpace>
|
||||||
<NSpace vertical>
|
<NSpace vertical>
|
||||||
<NCheckbox v-if="accountInfo" :disabled="isSelf" v-model:checked="isAnonymous" label="匿名提问" />
|
<NCheckbox v-if="accountInfo" :disabled="isSelf" v-model:checked="isAnonymous" label="匿名提问" />
|
||||||
</NSpace>
|
</NSpace>
|
||||||
|
|||||||
@@ -6,18 +6,24 @@ import { SONG_API_URL, USER_API_URL } from '@/data/constants'
|
|||||||
import { onMounted, ref } from 'vue'
|
import { onMounted, ref } from 'vue'
|
||||||
import { useRouteParams } from '@vueuse/router'
|
import { useRouteParams } from '@vueuse/router'
|
||||||
import { useAccount } from '@/api/account'
|
import { useAccount } from '@/api/account'
|
||||||
|
import { NAlert } from 'naive-ui'
|
||||||
|
|
||||||
const accountInfo = useAccount()
|
const accountInfo = useAccount()
|
||||||
const songs = ref<SongsInfo[]>()
|
const songs = ref<SongsInfo[]>()
|
||||||
const uId = useRouteParams('id', '-1', { transform: Number })
|
const uId = useRouteParams('id', '-1', { transform: Number })
|
||||||
|
|
||||||
|
const errMessage = ref('')
|
||||||
|
|
||||||
async function getSongs() {
|
async function getSongs() {
|
||||||
await QueryGetAPI<SongsInfo[]>(SONG_API_URL + 'get', {
|
await QueryGetAPI<SongsInfo[]>(SONG_API_URL + 'get', {
|
||||||
uId: uId.value,
|
id: uId.value,
|
||||||
}).then((data) => {
|
}).then((data) => {
|
||||||
if (data.code == 200) {
|
if (data.code == 200) {
|
||||||
songs.value = data.data
|
songs.value = data.data
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
errMessage.value = data.message
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -27,6 +33,8 @@ onMounted(async () => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
歌单
|
<SongList v-if="songs" :songs="songs ?? []" />
|
||||||
<SongList :songs="songs ?? []" />
|
<NAlert v-else-if="errMessage" type="error">
|
||||||
|
{{ errMessage }}
|
||||||
|
</NAlert>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1933,6 +1933,11 @@ lines-and-columns@^1.1.6:
|
|||||||
resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.2.4.tgz#eca284f75d2965079309dc0ad9255abb2ebc1632"
|
resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.2.4.tgz#eca284f75d2965079309dc0ad9255abb2ebc1632"
|
||||||
integrity sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==
|
integrity sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==
|
||||||
|
|
||||||
|
linqts@^1.15.0:
|
||||||
|
version "1.15.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/linqts/-/linqts-1.15.0.tgz#99195db380da7c039961c00e637e6ae57d5dee5e"
|
||||||
|
integrity sha512-DYRi1eGy8R0/dPzTTE0q3gQKvAj960CumYNikVGaUBc8TJCs/zeIbEmHb9lGx7Y9ALvTKle2cuBpkKgIeCSRTg==
|
||||||
|
|
||||||
lint-staged@^11.1.2:
|
lint-staged@^11.1.2:
|
||||||
version "11.2.6"
|
version "11.2.6"
|
||||||
resolved "https://registry.yarnpkg.com/lint-staged/-/lint-staged-11.2.6.tgz#f477b1af0294db054e5937f171679df63baa4c43"
|
resolved "https://registry.yarnpkg.com/lint-staged/-/lint-staged-11.2.6.tgz#f477b1af0294db054e5937f171679df63baa4c43"
|
||||||
|
|||||||
Reference in New Issue
Block a user