Skip to content

Commit

Permalink
[update] modify failed developer tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
Diving-Fish committed Aug 23, 2024
1 parent 8294bd5 commit 8781431
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 15 deletions.
60 changes: 46 additions & 14 deletions web/src/components/DeveloperToken.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@
</v-tooltip>
</div>
</template>
<template v-slot:item.actions="{ item }">
<v-icon
@click="openFormDialog(item)"
class="mr-2"
color="primary"
>mdi-pencil</v-icon
>
</template>
</v-data-table>
</v-card-text>
<v-card-actions>
Expand All @@ -67,7 +75,7 @@
:fullscreen="$vuetify.breakpoint.mobile"
>
<v-card>
<v-card-title class="headline">申请新 Token</v-card-title>
<v-card-title class="headline">{{ isNewToken ? '申请新 Token' : '编辑已有 Token' }}</v-card-title>
<v-card-text>
<v-form ref="form">
<v-select
Expand Down Expand Up @@ -104,7 +112,7 @@
</div>
<v-text-field
v-model="newToken.oldToken"
label="旧版本 Token(如果没有旧版本 Token 请留空)"
:label="isNewToken ? '旧版本 Token(如果没有旧版本 Token 请留空)' : 'Token'"
required
></v-text-field>
</v-form>
Expand Down Expand Up @@ -133,6 +141,7 @@ export default {
{ text: "等级", value: "level" },
{ text: "状态", value: "available" },
{ text: "备注", value: "comment" },
{ text: "", value: "actions", sortable: false },
],
level_items: [
{ text: "<300次/天", value: 1 },
Expand Down Expand Up @@ -160,8 +169,16 @@ export default {
});
},
methods: {
openFormDialog() {
openFormDialog(oldToken) {
this.formDialog = true;
if (oldToken !== undefined) {
this.isNewToken = false;
this.newToken.oldToken = oldToken.token;
this.newToken.level = oldToken.level;
}
else {
this.isNewToken = true;
}
},
async submitForm() {
if (this.$refs.form.validate()) {
Expand All @@ -176,17 +193,32 @@ export default {
level: this.newToken.level,
};
try {
await axios.post(
"https://www.diving-fish.com/api/maimaidxprober/developer_token",
postData
);
this.items.push(postData);
this.formDialog = false;
this.resetForm();
this.$message.success("已发送申请请求,请等待管理员审核");
} catch (error) {
this.$message.error(error.response.data.message);
if (this.isNewToken) {
try {
await axios.post(
"https://www.diving-fish.com/api/maimaidxprober/developer_token",
postData
);
this.items.push(postData);
this.formDialog = false;
this.resetForm();
this.$message.success("已发送申请请求,请等待管理员审核");
} catch (error) {
this.$message.error(error.response.data.message);
}
}
else {
try {
await axios.put(
"https://www.diving-fish.com/api/maimaidxprober/developer_token",
postData
);
this.formDialog = false;
this.resetForm();
this.$message.success("已发送申请请求,请等待管理员审核");
} catch (error) {
this.$message.error(error.response.data.message);
}
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion web/src/pages/MainPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
</v-card>
</v-dialog>
<recovery :visible="true" />
<developer-token :visible="username !== '未登录'" />
<developer-token />
<v-dialog width="1000px" :fullscreen="$vuetify.breakpoint.mobile" v-model="dialogVisible">
<template #activator="{ on, attrs }">
<v-btn class="mt-3 mr-4" v-bind="attrs" v-on="on">导入数据</v-btn>
Expand Down

0 comments on commit 8781431

Please sign in to comment.