chatGPT部分完成
This commit is contained in:
@@ -17,7 +17,7 @@ export default {
|
|||||||
components: {Settings, Chat},
|
components: {Settings, Chat},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
showSettings: false,
|
showSettings: true,
|
||||||
setting: {
|
setting: {
|
||||||
model: new ChatGPT(),
|
model: new ChatGPT(),
|
||||||
stream: true
|
stream: true
|
||||||
|
|||||||
@@ -13,10 +13,10 @@
|
|||||||
<el-form-item label="API KEY">
|
<el-form-item label="API KEY">
|
||||||
<el-input v-model="settings.model.apiKey" clearable @change="v=>settings.model.setApiKey(v),getModelAccount()"/>
|
<el-input v-model="settings.model.apiKey" clearable @change="v=>settings.model.setApiKey(v),getModelAccount()"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-button type="text" @click="getModelAccount">刷新账号信息</el-button>
|
<el-row v-loading="loadingAccount" element-loading-background="#272A37">
|
||||||
<el-row>
|
<el-form-item label="账号用户" class="fill">{{ account.username }}</el-form-item>
|
||||||
<el-form-item label="账号用户" class="fill color-999">{{ account.username }}</el-form-item>
|
<el-form-item label="账户余额" class="fill">{{ [account.usage, account.total].join(" / ") }}</el-form-item>
|
||||||
<el-form-item label="账户余额" class="fill color-999">{{ [account.usage, account.total].join(" / ") }}</el-form-item>
|
<el-button type="text" @click="getModelAccount">刷新</el-button>
|
||||||
</el-row>
|
</el-row>
|
||||||
</el-form>
|
</el-form>
|
||||||
</section>
|
</section>
|
||||||
@@ -26,7 +26,6 @@
|
|||||||
import AiModel from "../ui/AiModel";
|
import AiModel from "../ui/AiModel";
|
||||||
import AiSelect from "../ui/AiSelect";
|
import AiSelect from "../ui/AiSelect";
|
||||||
import * as models from "../utils/models";
|
import * as models from "../utils/models";
|
||||||
import {scopy} from "../utils/tools";
|
|
||||||
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -38,14 +37,15 @@ export default {
|
|||||||
emits: ["update:modelValue"],
|
emits: ["update:modelValue"],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
settings: {}
|
settings: {},
|
||||||
|
loadingAccount: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
modelValue: {
|
modelValue: {
|
||||||
immediate: true,
|
immediate: true,
|
||||||
handler(v) {
|
handler(v) {
|
||||||
this.settings = scopy(v)
|
this.settings = v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -55,8 +55,11 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getModelAccount() {
|
getModelAccount() {
|
||||||
console.log(this.settings.model)
|
const ai = this.settings.model
|
||||||
this.settings.model.getAccount?.().then(v => this.settings.account = v)
|
if (ai.getAccount) {
|
||||||
|
this.loadingAccount = true
|
||||||
|
ai.getAccount().then(v => this.settings.account = v).finally(() => this.loadingAccount = false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
@@ -70,6 +73,10 @@ export default {
|
|||||||
|
|
||||||
:deep(.el-form) {
|
:deep(.el-form) {
|
||||||
.el-form-item__label {
|
.el-form-item__label {
|
||||||
|
color: #bbb;
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-form-item__content {
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ export class ChatGPT extends BaseModel {
|
|||||||
if (endDate) {
|
if (endDate) {
|
||||||
const startDate = new Date(endDate - 90 * 24 * 60 * 60);
|
const startDate = new Date(endDate - 90 * 24 * 60 * 60);
|
||||||
const formattedDate = time => dayjs(time).format("YYYY-MM-DD")
|
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 => {
|
{headers}).then(res => res.json()).then(res => {
|
||||||
usages.total_usage = res.total_usage
|
usages.total_usage = res.total_usage
|
||||||
const names = usages.account_name.split(" ")
|
const names = usages.account_name.split(" ")
|
||||||
|
|||||||
Reference in New Issue
Block a user