diff --git a/src/App.vue b/src/App.vue index f1da970..ea4a015 100644 --- a/src/App.vue +++ b/src/App.vue @@ -17,7 +17,7 @@ export default { components: {Settings, Chat}, data() { return { - showSettings: false, + showSettings: true, setting: { model: new ChatGPT(), stream: true diff --git a/src/components/settings.vue b/src/components/settings.vue index a360ff9..5cf85b8 100644 --- a/src/components/settings.vue +++ b/src/components/settings.vue @@ -13,10 +13,10 @@ - 刷新账号信息 - - {{ account.username }} - {{ [account.usage, account.total].join(" / ") }} + + {{ account.username }} + {{ [account.usage, account.total].join(" / ") }} + 刷新 @@ -26,7 +26,6 @@ import AiModel from "../ui/AiModel"; import AiSelect from "../ui/AiSelect"; import * as models from "../utils/models"; -import {scopy} from "../utils/tools"; export default { @@ -38,14 +37,15 @@ export default { emits: ["update:modelValue"], data() { return { - settings: {} + settings: {}, + loadingAccount: false } }, watch: { modelValue: { immediate: true, handler(v) { - this.settings = scopy(v) + this.settings = v } } }, @@ -55,8 +55,11 @@ export default { }, methods: { getModelAccount() { - console.log(this.settings.model) - this.settings.model.getAccount?.().then(v => this.settings.account = v) + const ai = this.settings.model + if (ai.getAccount) { + this.loadingAccount = true + ai.getAccount().then(v => this.settings.account = v).finally(() => this.loadingAccount = false) + } } }, created() { @@ -70,6 +73,10 @@ export default { :deep(.el-form) { .el-form-item__label { + color: #bbb; + } + + .el-form-item__content { color: white; } diff --git a/src/utils/models.js b/src/utils/models.js index 4d50a8a..9136426 100644 --- a/src/utils/models.js +++ b/src/utils/models.js @@ -55,7 +55,7 @@ export class ChatGPT extends BaseModel { if (endDate) { const startDate = new Date(endDate - 90 * 24 * 60 * 60); const formattedDate = time => dayjs(time).format("YYYY-MM-DD") - return axios.get(`${ChatGPT.base}/v1/dashboard/billing/usage?start_date=${formattedDate(startDate * 1000)}&end_date=${formattedDate(endDate * 1000)}`, + return await axios.get(`${ChatGPT.base}/v1/dashboard/billing/usage?start_date=${formattedDate(startDate * 1000)}&end_date=${formattedDate(endDate * 1000)}`, {headers}).then(res => res.json()).then(res => { usages.total_usage = res.total_usage const names = usages.account_name.split(" ")