Skip to content

Commit

Permalink
2.13.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Dooy committed Dec 24, 2023
1 parent fbf1b7e commit c0e2c21
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 7 deletions.
3 changes: 3 additions & 0 deletions changlog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# 功能升级日志

## 2.13.3
- 😄 更新: 更新本月使用量、余额的请求方式

## 2.13.2
- 🐞 修复: midjourney 刷新错误
- ✅ 新增: tts whisper 界面支持
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chatgpt-web-midjourney-proxy",
"version": "2.13.2",
"version": "2.13.3",
"private": false,
"description": "ChatGPT Web Midjourney Proxy",
"author": "Dooy <[email protected]>",
Expand Down
33 changes: 32 additions & 1 deletion src/api/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,4 +226,35 @@ export const bolbObj= ( blob:Blob )=>{
player.load();
})

}
}

function formatDate(): string[] {
const today = new Date()
const year = today.getFullYear()
const month = today.getMonth() + 1
const lastDay = new Date(year, month, 0)
const formattedFirstDay = `${year}-${month.toString().padStart(2, '0')}-01`
const formattedLastDay = `${year}-${month.toString().padStart(2, '0')}-${lastDay.getDate().toString().padStart(2, '0')}`
return [formattedFirstDay, formattedLastDay]
}

//

export const gptUsage=async ()=>{

// fetch(getUrl(url), opt )
// .then(d=>d.json().then(d=> resolve(d))
// .catch(e=>reject(e)))
// .catch(e=>reject(e))
const [startDate, endDate] = formatDate();
const urlUsage = `/v1/dashboard/billing/usage?start_date=${startDate}&end_date=${endDate}`
const usageData = await gptFetch(urlUsage);
const billData = await gptFetch('/v1/dashboard/billing/subscription');

const usage = Math.round(usageData.total_usage) / 100
mlog('gpt', usage , billData );
//remaining = subscriptionData.system_hard_limit_usd - totalUsage;
return {usage,remaining:Math.round(billData.system_hard_limit_usd- usageData.total_usage ) / 100 } ;

}

24 changes: 19 additions & 5 deletions src/components/common/Setting/About.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { NSpin } from 'naive-ui'
import pkg from '../../../../package.json'
import { fetchChatConfig ,getLastVersion} from '@/api'
import { useAuthStore } from '@/store'
import { gptUsage } from "@/api";
interface ConfigState {
timeoutMs?: number
Expand All @@ -12,6 +13,7 @@ interface ConfigState {
socksProxy?: string
httpsProxy?: string
usage?: string
remaining?: string
}
const authStore = useAuthStore()
Expand All @@ -26,8 +28,19 @@ const isChatGPTAPI = computed<boolean>(() => !!authStore.isChatGPTAPI)
async function fetchConfig() {
try {
loading.value = true
const { data } = await fetchChatConfig<ConfigState>()
config.value = data
// const { data } = await fetchChatConfig<ConfigState>()
// config.value = data
const dd= await gptUsage();
config.value= {usage:dd.usage?`${dd.usage}`:'-'
,remaining:dd.remaining?`${dd.remaining}`:'-'
, "apiModel": "ChatGPTAPI",
"reverseProxy": "-",
"timeoutMs": 100000,
"socksProxy": "-",
"httpsProxy": "-", } ;
}
finally {
loading.value = false
Expand Down Expand Up @@ -93,9 +106,10 @@ const isShow = computed(()=>{
<p v-if="!isChatGPTAPI">
{{ $t("setting.reverseProxy") }}:{{ config?.reverseProxy ?? '-' }}
</p>
<p>{{ $t("setting.timeout") }}:{{ config?.timeoutMs ?? '-' }}</p>
<p>{{ $t("setting.socks") }}:{{ config?.socksProxy ?? '-' }}</p>
<p>{{ $t("setting.httpsProxy") }}:{{ config?.httpsProxy ?? '-' }}</p>
<p>余额:{{ config?.remaining ?? '-' }}</p>
<!-- <p>{{ $t("setting.timeout") }}:{{ config?.timeoutMs ?? '-' }}</p> -->
<!-- <p>{{ $t("setting.socks") }}:{{ config?.socksProxy ?? '-' }}</p>
<p>{{ $t("setting.httpsProxy") }}:{{ config?.httpsProxy ?? '-' }}</p> -->
</div>
</NSpin>
</template>

0 comments on commit c0e2c21

Please sign in to comment.