update music obs component avatar

This commit is contained in:
2024-01-31 17:20:23 +08:00
parent 8de805de9c
commit b8c6b52d6c
7 changed files with 163 additions and 65 deletions

View File

@@ -525,7 +525,7 @@ export interface ResponsePointGoodModel {
content?: string content?: string
count?: number count?: number
price: number price: number
tags: TagInfo[] tags: string[]
cover?: string cover?: string
images: string[] images: string[]
status: GoodsStatus status: GoodsStatus
@@ -540,7 +540,7 @@ export interface PointGoodsModel {
name: string name: string
count: number count: number
price: number price: number
tags: TagInfo[] tags: string[]
cover?: ImageUploadModel cover?: ImageUploadModel
status: GoodsStatus status: GoodsStatus
type: GoodsTypes type: GoodsTypes
@@ -549,3 +549,21 @@ export interface PointGoodsModel {
description: string description: string
content?: string content?: string
} }
export interface AddressInfo {
province: string
city: string
district: string
address: string
phone: number
name: string
}
export interface BiliAuthModel {
id: number
userId: number
openId: string
address?: AddressInfo
}
export interface PointOrderModel{
id: number
}

View File

@@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { ResponsePointGoodModel } from '@/api/api-models' import { ResponsePointGoodModel } from '@/api/api-models'
import { NButton, NCard, NDropdown, NEllipsis, NFlex, NIcon, NImage, NPopselect, NText } from 'naive-ui' import { NButton, NCard, NDropdown, NEllipsis, NFlex, NIcon, NImage, NPopselect, NTag, NText } from 'naive-ui'
import { FILE_BASE_URL, IMGUR_URL } from '@/data/constants' import { FILE_BASE_URL, IMGUR_URL } from '@/data/constants'
import { computed, ref } from 'vue' import { computed, ref } from 'vue'
import { MoreHorizontal16Filled, MoreVertical16Filled } from '@vicons/fluent' import { MoreHorizontal16Filled, MoreVertical16Filled } from '@vicons/fluent'
@@ -25,9 +25,12 @@ const emptyCover = IMGUR_URL + 'None.png'
</NEllipsis> </NEllipsis>
</template> </template>
<NFlex vertical> <NFlex vertical>
<NText depth="3"> <NText depth="3" :italic="!goods.description">
{{ goods.description }} {{ goods.description }}
</NText> </NText>
<NFlex>
<NTag v-for="tag in goods.tags" :key="tag" :bordered="false">{{ tag }}</NTag>
</NFlex>
<NFlex justify="space-between"> <NFlex justify="space-between">
<NFlex> <NFlex>
<NText> 库存: </NText> <NText> 库存: </NText>

View File

@@ -39,26 +39,29 @@ import {
NDropdown, NDropdown,
NImage, NImage,
useDialog, useDialog,
NPopconfirm,
} from 'naive-ui' } from 'naive-ui'
import { computed, ref } from 'vue' import { computed, ref } from 'vue'
import PointOrderManage from './PointOrderManage.vue'
const message = useMessage() const message = useMessage()
const accountInfo = useAccount() const accountInfo = useAccount()
const dialog = useDialog() const dialog = useDialog()
const goods = ref<ResponsePointGoodModel[]>(await getGoods()) const goods = ref<ResponsePointGoodModel[]>(await getGoods())
const currentGoodsModel = ref<PointGoodsModel>({ const currentGoodsModel = ref<{ goods: PointGoodsModel; fileList: UploadFileInfo[] }>({
goods: {
type: GoodsTypes.Virtual, type: GoodsTypes.Virtual,
status: GoodsStatus.Normal, status: GoodsStatus.Normal,
} as PointGoodsModel) } as PointGoodsModel,
fileList: [],
})
const showAddGoodsModal = ref(false) const showAddGoodsModal = ref(false)
const isAllowedPrivacyPolicy = ref(false) const isAllowedPrivacyPolicy = ref(false)
const isUpdating = ref(false) const isUpdating = ref(false)
const fileList = ref<UploadFileInfo[]>([])
const rules = { const rules = {
name: { name: {
required: true, required: true,
@@ -72,14 +75,14 @@ const rules = {
required: true, required: true,
message: '请输入虚拟礼物的具体内容', message: '请输入虚拟礼物的具体内容',
validator: (rule: FormItemRule, value: string) => { validator: (rule: FormItemRule, value: string) => {
return currentGoodsModel.value.type != GoodsTypes.Virtual || (value?.length ?? 0) > 0 return currentGoodsModel.value.goods.type != GoodsTypes.Virtual || (value?.length ?? 0) > 0
}, },
}, },
privacy: { privacy: {
required: true, required: true,
message: '需要阅读并同意本站隐私政策', message: '需要阅读并同意本站隐私政策',
validator: (rule: FormItemRule, value: boolean) => { validator: (rule: FormItemRule, value: boolean) => {
return (currentGoodsModel.value.type != GoodsTypes.Physical && currentGoodsModel.value.collectUrl != undefined) || isAllowedPrivacyPolicy.value return (currentGoodsModel.value.goods.type != GoodsTypes.Physical && currentGoodsModel.value.goods.collectUrl != undefined) || isAllowedPrivacyPolicy.value
}, },
}, },
} }
@@ -90,7 +93,7 @@ const existTags = computed(() => {
return [] return []
} }
//获取所有已存在商品的tags并去重 //获取所有已存在商品的tags并去重
const tempSet = new Set<TagInfo>() const tempSet = new Set<string>()
for (let i = 0; i < goods.value.length; i++) { for (let i = 0; i < goods.value.length; i++) {
const goodsTags = goods.value[i].tags const goodsTags = goods.value[i].tags
if (!goodsTags || goodsTags.length == 0) { if (!goodsTags || goodsTags.length == 0) {
@@ -101,7 +104,7 @@ const existTags = computed(() => {
} }
} }
return Array.from(tempSet).map((item) => { return Array.from(tempSet).map((item) => {
return { label: item.name, value: item.name } return { label: item, value: item }
}) })
}) })
@@ -156,15 +159,15 @@ async function updateGoods(e: MouseEvent) {
await formRef.value await formRef.value
.validate() .validate()
.then(async () => { .then(async () => {
if (fileList.value.length > 0) { if (currentGoodsModel.value.fileList.length > 0) {
currentGoodsModel.value.cover = await getImageUploadModel(fileList.value) currentGoodsModel.value.goods.cover = await getImageUploadModel(currentGoodsModel.value.fileList)
} }
await QueryPostAPI<ResponsePointGoodModel>(POINT_API_URL + 'update-goods', currentGoodsModel.value) await QueryPostAPI<ResponsePointGoodModel>(POINT_API_URL + 'update-goods', currentGoodsModel.value.goods)
.then((data) => { .then((data) => {
if (data.code == 200) { if (data.code == 200) {
message.success('成功') message.success('成功')
showAddGoodsModal.value = false showAddGoodsModal.value = false
currentGoodsModel.value = {} as PointGoodsModel currentGoodsModel.value.goods = {} as PointGoodsModel
if (goods.value.find((g) => g.id == data.data.id)) { if (goods.value.find((g) => g.id == data.data.id)) {
goods.value[goods.value.findIndex((g) => g.id == data.data.id)] = data.data goods.value[goods.value.findIndex((g) => g.id == data.data.id)] = data.data
} else { } else {
@@ -192,17 +195,19 @@ function OnFileListChange(files: UploadFileInfo[]) {
var file = files[0] var file = files[0]
if ((file.file?.size ?? 0) > 10 * 1024 * 1024) { if ((file.file?.size ?? 0) > 10 * 1024 * 1024) {
message.error('文件大小不能超过10MB') message.error('文件大小不能超过10MB')
fileList.value = [] currentGoodsModel.value.fileList = []
} }
} }
} }
function onUpdateClick(item: ResponsePointGoodModel) { function onUpdateClick(item: ResponsePointGoodModel) {
currentGoodsModel.value = { currentGoodsModel.value = {
goods: {
...item, ...item,
count: item.count ?? 0, count: item.count ?? 0,
cover: undefined, cover: undefined,
} },
fileList.value = [ fileList: item.cover
? [
{ {
id: item.cover ?? 'cover', id: item.cover ?? 'cover',
thumbnailUrl: FILE_BASE_URL + item.cover, thumbnailUrl: FILE_BASE_URL + item.cover,
@@ -210,8 +215,47 @@ function onUpdateClick(item: ResponsePointGoodModel) {
status: 'finished', status: 'finished',
}, },
] ]
: [],
}
showAddGoodsModal.value = true showAddGoodsModal.value = true
} }
//下架
function onSetShelfClick(item: ResponsePointGoodModel, status: GoodsStatus) {
const d = dialog.warning({
title: '警告',
content: '你确定要下架这个礼物吗?',
positiveText: '确定',
negativeText: '取消',
onPositiveClick: async () => {
d.loading = true
const originStatus = item.status
item.status = status
try {
const data = await QueryGetAPI(POINT_API_URL + 'update-goods-status', {
id: item.id,
status: item.status,
})
if (data.code == 200) {
message.success('成功')
const index = goods.value.findIndex((g) => g.id == item.id)
if (index > -1) {
goods.value[index].status = status
}
} else {
message.error('失败: ' + data.message)
item.status = originStatus
console.error(data.message)
}
} catch (err) {
message.error('失败: ' + err)
item.status = originStatus
console.error(err)
} finally {
d.loading = false
}
},
})
}
function onDeleteClick(item: ResponsePointGoodModel) { function onDeleteClick(item: ResponsePointGoodModel) {
const d = dialog.warning({ const d = dialog.warning({
title: '警告', title: '警告',
@@ -240,6 +284,7 @@ function onDeleteClick(item: ResponsePointGoodModel) {
}, },
}) })
} }
function responseGoodsToModel(goods: ResponsePointGoodModel) {}
</script> </script>
<template> <template>
@@ -262,75 +307,70 @@ function onDeleteClick(item: ResponsePointGoodModel) {
<NGrid cols="1 500:2 700:3 1000:4 1200:5" :x-gap="12" :y-gap="8"> <NGrid cols="1 500:2 700:3 1000:4 1200:5" :x-gap="12" :y-gap="8">
<NGridItem v-for="item in goods" :key="item.id"> <NGridItem v-for="item in goods" :key="item.id">
<PointGoodsItem :goods="item"> <PointGoodsItem :goods="item">
<template #header-extra> <template #footer>
<NDropdown :options="dropDownOptions" trigger="click" @select="(v) => dropDownActions[v].action(item)"> <NFlex>
<NButton text style="font-size: 24px"> <NButton type="info" size="small" @click="onUpdateClick(item)"> 修改 </NButton>
<template #icon> <NButton v-if="item.status != GoodsStatus.Discontinued" type="warning" size="small" @click="onSetShelfClick(item, GoodsStatus.Discontinued)"> 下架 </NButton>
<NIcon :component="MoreVertical16Filled" /> <NButton v-else type="success" size="small" @click="onSetShelfClick(item, GoodsStatus.Normal)"> 上架 </NButton>
</template> <NButton type="error" size="small" @click="onDeleteClick(item)"> 删除 </NButton>
</NButton> </NFlex>
</NDropdown>
</template> </template>
</PointGoodsItem> </PointGoodsItem>
</NGridItem> </NGridItem>
</NGrid> </NGrid>
</NTabPane> </NTabPane>
<NTabPane name="orders" tab="订单"> <NTabPane name="orders" tab="订单" display-directive="show:lazy">
<PointOrderManage />
</NTabPane>
<NTabPane name="users" tab="用户">
</NTabPane>
<NTabPane name="settings" tab="设置">
</NTabPane> </NTabPane>
<NTabPane name="users" tab="用户" display-directive="show:lazy"> </NTabPane>
<NTabPane name="settings" tab="设置" display-directive="show:lazy"> </NTabPane>
</NTabs> </NTabs>
<NModal v-model:show="showAddGoodsModal" preset="card" style="width: 600px; max-width: 90%" title="添加/修改礼物信息"> <NModal v-model:show="showAddGoodsModal" preset="card" style="width: 600px; max-width: 90%" title="添加/修改礼物信息">
<NScrollbar style="max-height: 80vh"> <NScrollbar style="max-height: 80vh">
<NForm ref="formRef" :model="currentGoodsModel" :rules="rules" style="width: 95%"> <NForm ref="formRef" :model="currentGoodsModel" :rules="rules" style="width: 95%">
<NFormItem path="name" label="名称" required> <NFormItem path="name" label="名称" required>
<NInput v-model:value="currentGoodsModel.name" placeholder="必填, 礼物名称" /> <NInput v-model:value="currentGoodsModel.goods.name" placeholder="必填, 礼物名称" />
</NFormItem> </NFormItem>
<NFormItem path="price" label="所需积分" required> <NFormItem path="price" label="所需积分" required>
<NInputNumber v-model:value="currentGoodsModel.price" placeholder="必填, 兑换所需要的积分" min="0" /> <NInputNumber v-model:value="currentGoodsModel.goods.price" placeholder="必填, 兑换所需要的积分" min="0" />
</NFormItem> </NFormItem>
<NFormItem path="count" label="库存"> <NFormItem path="count" label="库存">
<NCheckbox :checked="currentGoodsModel.count && currentGoodsModel.count < 0" @update:checked="(v) => (currentGoodsModel.count = v ? -1 : 100)"> 不限 </NCheckbox> <NCheckbox :checked="currentGoodsModel.goods.count && currentGoodsModel.goods.count < 0" @update:checked="(v) => (currentGoodsModel.goods.count = v ? -1 : 100)"> 不限 </NCheckbox>
<NInputNumber v-if="currentGoodsModel.count > -1" v-model:value="currentGoodsModel.count" placeholder="可选, 礼物库存" style="max-width: 120px;"/> <NInputNumber v-if="currentGoodsModel.goods.count > -1" v-model:value="currentGoodsModel.goods.count" placeholder="可选, 礼物库存" style="max-width: 120px" />
</NFormItem> </NFormItem>
<NFormItem path="description" label="描述"> <NFormItem path="description" label="描述">
<NInput v-model:value="currentGoodsModel.description" placeholder="可选, 礼物描述" /> <NInput v-model:value="currentGoodsModel.goods.description" placeholder="可选, 礼物描述" maxlength="500" />
</NFormItem> </NFormItem>
<NFormItem path="tags" label="标签"> <NFormItem path="tags" label="标签">
<NSelect :value="currentGoodsModel.tags?.map((tag) => tag.name)" filterable multiple clearable tag placeholder="可选,输入后按回车添加" :options="existTags" /> <NSelect v-model:value="currentGoodsModel.goods.tags" filterable multiple clearable tag placeholder="可选,输入后按回车添加" :options="existTags" />
</NFormItem> </NFormItem>
<NFormItem path="cover" label="封面"> <NFormItem path="cover" label="封面">
<NFlex v-if="currentGoodsModel.cover"> <NFlex v-if="currentGoodsModel.goods.cover">
<NText>当前封面: </NText> <NText>当前封面: </NText>
<NImage :src="FILE_BASE_URL + currentGoodsModel.cover" height="50" object-fit="cover" /> <NImage :src="FILE_BASE_URL + currentGoodsModel.goods.cover" height="50" object-fit="cover" />
</NFlex> </NFlex>
<NUpload <NUpload
:max="1" :max="1"
accept=".png,.jpg,.jpeg,.gif,.svg,.webp,.ico,.bmp,.tif,.tiff,.jfif,.jpe,.jp,.psd,." accept=".png,.jpg,.jpeg,.gif,.svg,.webp,.ico,.bmp,.tif,.tiff,.jfif,.jpe,.jp,.psd,."
list-type="image-card" list-type="image-card"
:default-upload="false" :default-upload="false"
v-model:file-list="fileList" v-model:file-list="currentGoodsModel.fileList"
@update:file-list="OnFileListChange" @update:file-list="OnFileListChange"
> >
+ {{ currentGoodsModel.cover ? '更换' : '上传' }}封面 + {{ currentGoodsModel.goods.cover ? '更换' : '上传' }}封面
</NUpload> </NUpload>
</NFormItem> </NFormItem>
<NFormItem path="type" label="类型"> <NFormItem path="type" label="类型">
<NRadioGroup v-model:value="currentGoodsModel.type"> <NRadioGroup v-model:value="currentGoodsModel.goods.type">
<NRadioButton :value="GoodsTypes.Virtual">虚拟礼物</NRadioButton> <NRadioButton :value="GoodsTypes.Virtual">虚拟礼物</NRadioButton>
<NRadioButton :value="GoodsTypes.Physical">实体礼物</NRadioButton> <NRadioButton :value="GoodsTypes.Physical">实体礼物</NRadioButton>
</NRadioGroup> </NRadioGroup>
</NFormItem> </NFormItem>
<template v-if="currentGoodsModel.type == GoodsTypes.Physical"> <template v-if="currentGoodsModel.goods.type == GoodsTypes.Physical">
<NFormItem path="collectUrl" label="收货地址"> <NFormItem path="collectUrl" label="收货地址">
<NFlex vertical> <NFlex vertical>
<NRadioGroup :value="currentGoodsModel.collectUrl == undefined ? 0 : 1" @update:value="(v) => (currentGoodsModel.collectUrl = v == 1 ? '' : undefined)"> <NRadioGroup :value="currentGoodsModel.goods.collectUrl == undefined ? 0 : 1" @update:value="(v) => (currentGoodsModel.goods.collectUrl = v == 1 ? '' : undefined)">
<NRadioButton :value="0">通过本站收集收货地址</NRadioButton> <NRadioButton :value="0">通过本站收集收货地址</NRadioButton>
<NRadioButton :value="1"> <NRadioButton :value="1">
使用站外链接收集地址 使用站外链接收集地址
@@ -344,12 +384,12 @@ function onDeleteClick(item: ResponsePointGoodModel) {
</NRadioGroup> </NRadioGroup>
</NFlex> </NFlex>
</NFormItem> </NFormItem>
<template v-if="currentGoodsModel.collectUrl != undefined"> <template v-if="currentGoodsModel.goods.collectUrl != undefined">
<NFormItem path="url" label="收集链接"> <NFormItem path="url" label="收集链接">
<NInput v-model:value="currentGoodsModel.collectUrl" placeholder="用于给用户填写自己收货地址的表格的分享链接" /> <NInput v-model:value="currentGoodsModel.goods.collectUrl" placeholder="用于给用户填写自己收货地址的表格的分享链接" maxlength="300" />
</NFormItem> </NFormItem>
<NFormItem label="内嵌收集链接"> <NFormItem label="内嵌收集链接">
<NCheckbox v-model:checked="currentGoodsModel.embedCollectUrl"> 尝试将收集链接嵌入到网页中 </NCheckbox> <NCheckbox v-model:checked="currentGoodsModel.goods.embedCollectUrl"> 尝试将收集链接嵌入到网页中 </NCheckbox>
</NFormItem> </NFormItem>
</template> </template>
<template v-else> <template v-else>
@@ -369,10 +409,10 @@ function onDeleteClick(item: ResponsePointGoodModel) {
虚拟礼物的具体内容, 网盘链接什么之类的 虚拟礼物的具体内容, 网盘链接什么之类的
</NTooltip> </NTooltip>
</template> </template>
<NInput v-model:value="currentGoodsModel.content" type="textarea" placeholder="写这里咯" maxlength="10000" show-count clearable /> <NInput v-model:value="currentGoodsModel.goods.content" type="textarea" placeholder="写这里咯" maxlength="10000" show-count clearable />
</NFormItem> </NFormItem>
</template> </template>
<NButton @click="updateGoods" type="primary" :loading="isUpdating"> 添加 </NButton> <NButton @click="updateGoods" type="primary" :loading="isUpdating"> {{ currentGoodsModel.goods.id ? '修改' : '创建' }} </NButton>
</NForm> </NForm>
</NScrollbar> </NScrollbar>
</NModal> </NModal>

View File

@@ -0,0 +1,28 @@
<script setup lang="ts">
import { PointOrderModel } from '@/api/api-models'
import { QueryGetAPI } from '@/api/query'
import { POINT_API_URL } from '@/data/constants'
import { useMessage } from 'naive-ui'
import { ref } from 'vue'
const message = useMessage()
const orders = ref<PointOrderModel[]>(await getOrders())
async function getOrders() {
try {
const data = await QueryGetAPI<PointOrderModel[]>(POINT_API_URL + 'get-orders')
if (data.code == 200) {
return data.data
} else {
message.error('获取订单失败: ' + data.message)
}
} catch (err) {
console.log(err)
message.error('获取订单失败: ' + err)
}
return []
}
</script>
<template></template>

View File

@@ -77,7 +77,7 @@ onUnmounted(() => {
<div class="music-request-singing-container" :playing="originSongs.playing ? 'true' : 'false'" :from="originSongs.playing?.music.from ?? -1"> <div class="music-request-singing-container" :playing="originSongs.playing ? 'true' : 'false'" :from="originSongs.playing?.music.from ?? -1">
<div class="music-request-singing-prefix"></div> <div class="music-request-singing-prefix"></div>
<template v-if="originSongs.playing"> <template v-if="originSongs.playing">
<img class="music-request-singing-avatar" :src="AVATAR_URL + originSongs.playing.from?.uid" referrerpolicy="no-referrer" /> <img class="music-request-singing-avatar" :src="originSongs.playing.music.cover ?? AVATAR_URL + originSongs.playing.from?.uid" referrerpolicy="no-referrer" />
<p class="music-request-singing-song-name">{{ originSongs.playing.music.name }}</p> <p class="music-request-singing-song-name">{{ originSongs.playing.music.name }}</p>
<p class="music-request-singing-name">{{ originSongs.playing.from?.name }}</p> <p class="music-request-singing-name">{{ originSongs.playing.from?.name }}</p>
</template> </template>

View File

@@ -341,6 +341,15 @@ onUnmounted(() => {
color: rgba(204, 204, 204, 0.993); color: rgba(204, 204, 204, 0.993);
font-size: 12px; font-size: 12px;
} }
.queue-list-item-index[index='1'] {
color: #ebc34c;
}
.queue-list-item-index[index='2'] {
color: #c0c0c0;
}
.queue-list-item-index[index='3'] {
color: #b87333;
}
.queue-list-item-level { .queue-list-item-level {
text-align: center; text-align: center;
height: 18px; height: 18px;