Skip to content

Commit b45a50f

Browse files
committed
fix: 使用sess-xxx查询余额
1 parent 29379d1 commit b45a50f

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

assets/js/openai.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const app = {
77
isValidated() {
88
const inputText = this.u.trim();
99
// 使用正则表达式匹配以 "sk-" 开头的密钥,并排除非匹配项
10-
const regex = /^sk-.{21,}$/;
10+
const regex = /^(sk-|sess-).{21,}$/;
1111
const keys = inputText.split('\n').filter(key => regex.test(key.trim()));
1212
return keys
1313
},
@@ -22,7 +22,7 @@ const app = {
2222

2323
async submit($refs) {
2424
if (!this.u) {
25-
this.alert = { type: 'error', message: '请输入以sk-开头的key...' }
25+
this.alert = { type: 'error', message: '请输入以sess-开头的Authorization...' }
2626
return
2727
}
2828
const keys = this.isValidated();
@@ -92,7 +92,7 @@ const app = {
9292
}
9393
this.total.push({
9494
key: key,
95-
msgkey: key.replace(/(sk-.{5}).+(.{5})/, '$1****$2'),
95+
msgkey: key.replace(/(sess-.{5}).+(.{5})/, '$1****$2'),
9696
total_granted: 0,
9797
total_used: 0,
9898
total_available: 0,

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ <h2>查询 OpenaiAPI 余额</h2>
4545
</div>
4646
<main x-data="app" x-cloak>
4747
<p x-show.transition.opacity="alert" :class="alert?.type" x-text="alert?.message"></p>
48-
<textarea class="form-control" rows="5" placeholder="请输入以sk-开头的key..." x-model="u"></textarea></p>
48+
<textarea class="form-control" rows="5" placeholder="请输入以sess-xxxx开头的Authorization" x-model="u"></textarea></p>
4949
<div class="d-grid gap-2 d-sm-block">
5050
<button :class="{ loading }" class="btn btn-primary me-sm-3 " :disabled="loading"
5151
@click="submit($refs)">查询</button>

0 commit comments

Comments
 (0)