master
杜函宇 4 weeks ago
parent 288b78b8f1
commit 602f5b9527

@ -8,7 +8,7 @@ const userStore = useUserStore()
const userInfo = computed(() => userStore.userInfo) const userInfo = computed(() => userStore.userInfo)
const info = countStore() const info = countStore()
const nickName = Cookies.get('nickName') const userName = Cookies.get('userName')
</script> </script>
<template> <template>
@ -26,14 +26,14 @@ const nickName = Cookies.get('nickName')
</div> </div>
<div class="flex-1 min-w-0 ml-2"> <div class="flex-1 min-w-0 ml-2">
<h2 class="overflow-hidden font-bold text-md text-ellipsis whitespace-nowrap"> <h2 class="overflow-hidden font-bold text-md text-ellipsis whitespace-nowrap">
{{ nickName }} {{ userName }}
</h2> </h2>
<p class="overflow-hidden text-xs text-gray-500 text-ellipsis whitespace-nowrap"> <p class="overflow-hidden text-xs text-gray-500 text-ellipsis whitespace-nowrap">
<!-- <span <!-- <span
v-if="isString(userInfo.description) && userInfo.description !== ''" v-if="isString(userInfo.description) && userInfo.description !== ''"
v-html="userInfo.description" v-html="userInfo.description"
/> --> /> -->
今日剩余次数{{ info.count1 }}/10 今日剩余次数{{ info.count1 }}/50
</p> </p>
</div> </div>
</div> </div>

@ -3,25 +3,25 @@ import { defineStore } from 'pinia'
interface CountState { interface CountState {
count1: number count1: number
userId: any userId: any
nickName: string userName: string
} }
export const countStore = defineStore( export const countStore = defineStore(
'count-store', 'count-store',
{ {
state: (): CountState => ({ state: (): CountState => ({
count1: 10, count1: 50,
userId: null, userId: null,
nickName: '', userName: '',
}), }),
actions: { actions: {
randomizeCounter(count: number) { randomizeCounter(count: number) {
this.count1 = count this.count1 = count
}, },
setNameAId(userId: any, nickName: string) { setNameAId(userId: any, userName: string) {
return new Promise<void>((resolve) => { return new Promise<void>((resolve) => {
this.userId = userId this.userId = userId
this.nickName = nickName this.userName = userName
resolve() resolve()
}) })
}, },

@ -91,8 +91,8 @@ async function onConversation() {
}, },
) )
if (response.data.code == 200) { if (response.data.code == 200) {
a1.randomizeCounter(9 - response.data.data > 0 ? 9 - response.data.data : 0) a1.randomizeCounter(49 - response.data.data > 0 ? 49 - response.data.data : 0)
if (response.data.data < 10) { if (response.data.data < 50) {
try { try {
const response = await axios.post<AddResponse>( const response = await axios.post<AddResponse>(
`${import.meta.env.VITE_APP_API_BASE_URL}/deepSeekLog`, `${import.meta.env.VITE_APP_API_BASE_URL}/deepSeekLog`,
@ -540,8 +540,8 @@ const handleLogin = async () => {
) )
try { try {
if (response.data.code == 200) { if (response.data.code == 200) {
a1.randomizeCounter(10 - response.data.data) a1.randomizeCounter(50 - response.data.data)
if (response.data.data < 10) { if (response.data.data < 50) {
} }
else { else {
ElMessage({ ElMessage({

@ -32,7 +32,7 @@ interface InfoRes {
code: Number code: Number
user: { user: {
userId: Number userId: Number
nickName: string userName: string
} }
} }
@ -119,9 +119,9 @@ const executeLogin = async () => {
}, },
) )
if (res.data.code == 200) { if (res.data.code == 200) {
Cookies.set('nickName', res.data.user.nickName) Cookies.set('userName', res.data.user.userName)
info info
.setNameAId(res.data.user.userId, res.data.user.nickName) .setNameAId(res.data.user.userId, res.data.user.userName)
.then(() => { .then(() => {
router.replace('/chat').catch(() => {}) router.replace('/chat').catch(() => {})
}) })

Loading…
Cancel
Save