修改剩余字数

master
ihzero 2023-08-22 00:10:04 +08:00
parent 9078f58b43
commit 6c6828f693
2 changed files with 22 additions and 1 deletions

View File

@ -1,5 +1,7 @@
import { ref, computed } from "vue";
import { defineStore } from "pinia";
import http from '@/io/request';
import { localCache } from '@/io/cache';
export const useUserInfo = defineStore("userInfo", () => {
const userData = ref({});
@ -7,5 +9,12 @@ export const useUserInfo = defineStore("userInfo", () => {
userData.value = data;
}
return { userData, updateUserInfo };
function getUserInfo() {
http.get('/api/user/profile').then(res => {
localCache.set('userInfo', res);
userData.value = res;
})
};
return { userData, updateUserInfo,getUserInfo };
});

View File

@ -22,6 +22,9 @@
name="stop"
class="text-white text-26px cursor-pointer mr-28px"
></SvgIcon>
<div class="flex-1 text-right text-22px">
剩余字数:{{ surplus }}
</div>
</div>
<van-field
ref="inputRef"
@ -109,6 +112,11 @@ const isLogin = computed(() => {
return !!userInfo.userData?.id ?? false
})
const surplus = computed(() => {
const { words_count=0 ,words_used = 0} = userInfo.userData?.equity ?? {}
return words_count - words_used
})
const authModal = useAuthModal()
const { proxy } = getCurrentInstance()
@ -133,6 +141,9 @@ const fileLoading = ref(false)
const currentChart = computed(() => chatStore.getCurrentChat)
async function handleFileChange(file) {
if (!isLogin.value) {
authModal.setAuthModalType('login')
@ -371,6 +382,7 @@ async function onConversation(action = 'next', file, fileText) {
})
} finally {
loading.value = false
userInfo.getUserInfo()
}
}