Skip to content

Commit

Permalink
[feature] 添加了几项设置
Browse files Browse the repository at this point in the history
  • Loading branch information
Diving-Fish committed Sep 20, 2023
1 parent 4fb33a4 commit 3303b72
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 3 deletions.
2 changes: 2 additions & 0 deletions database/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ async def func(*args, **kwargs):
g.user = Player.get(Player.username == g.username)
return await f(*args, **kwargs)

return func


def is_developer(token):
if token == "":
Expand Down
2 changes: 0 additions & 2 deletions web/public/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<!DOCTYPE html>
<html lang="zh-cn">
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-3816408908336415"
crossorigin="anonymous"></script>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
Expand Down
90 changes: 89 additions & 1 deletion web/src/components/Profile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,40 @@
(u) => u.length <= 8 || '昵称不能超过 8 个字符',
]"
></v-text-field>

<div style="display: flex; justify-content: space-between;">
<div style="flex-grow: 1; padding-right: 16px;">
<v-text-field label="成绩导入 Token" v-model="import_token" disabled
></v-text-field
>
</div>
<div>
<v-tooltip bottom>
<template v-slot:activator="{ on }">
<v-icon v-on="on" class="mr-2" style="line-height: 66px;"> mdi-help-circle-outline </v-icon>
</template>
成绩导入 Token 可以查询和导入您的成绩。
</v-tooltip>
<v-tooltip bottom>
<template v-slot:activator="{ on }">
<v-icon v-on="on" @click="generateTokenVisible = true" class="click-icon"> mdi-refresh </v-icon>
</template>
生成新的成绩导入 Token
</v-tooltip>
<v-tooltip bottom>
<template v-slot:activator="{ on }">
<v-icon v-on="on" @click="copyToClipboard(import_token)" class="click-icon"> mdi-content-copy </v-icon>
</template>
复制 Token
</v-tooltip>
<v-tooltip bottom>
<template v-slot:activator="{ on }">
<v-icon v-on="on" @click="copyToClipboard('https://www.diving-fish.com/prober-import/?t=' + import_token)" class="click-icon"> mdi-link-variant </v-icon>
</template>
复制 Http 代理导入链接
</v-tooltip>
</div>
</div>
<v-text-field label="绑定 QQ 号" v-model="bind_qq"
><template v-slot:prepend>
<v-tooltip bottom>
Expand All @@ -39,6 +73,16 @@
</v-tooltip>
</template></v-text-field
>
<v-text-field label="绑定频道 ID" v-model="qq_channel_uid"
><template v-slot:prepend>
<v-tooltip bottom>
<template v-slot:activator="{ on }">
<v-icon v-on="on"> mdi-help-circle-outline </v-icon>
</template>
您可以在频道中输入 cuid 查询自己的频道 ID。
</v-tooltip>
</template></v-text-field
>
<v-row align="center">
<v-col cols="3">
<v-subheader> 段位 </v-subheader>
Expand Down Expand Up @@ -120,6 +164,22 @@
</v-card-actions>
</v-card>
</v-dialog>
<v-dialog
v-model="generateTokenVisible"
width="600"
:fullscreen="$vuetify.breakpoint.mobile"
>
<v-card>
<v-card-title>生成 Token</v-card-title>
<v-card-text>
确定生成新的 Token?旧的 Token 将失效。
</v-card-text>
<v-card-actions class="pb-4">
<v-btn color="primary" @click="generateToken">确定</v-btn>
<v-btn @click="generateTokenVisible = false">取消</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
<v-dialog
v-model="delVisible"
width="600"
Expand Down Expand Up @@ -161,10 +221,11 @@ export default {
data: () => {
return {
valid: false,
login: false,
login: true,
username: "",
visible: false,
delVisible: false,
generateTokenVisible: false,
select: { label: "初学者", ra: 0 },
ratings: [
{ label: "初学者", ra: 0 },
Expand Down Expand Up @@ -192,6 +253,8 @@ export default {
{ label: "里皆传", ra: 22 },
],
bind_qq: "",
qq_channel_uid: "",
import_token: "123456",
nickname: "",
privacy: false,
plate: "",
Expand Down Expand Up @@ -268,13 +331,16 @@ export default {
additional_rating: this.select.ra,
nickname: this.nickname,
plate: this.plate_upload,
qq_channel_uid: this.qq_channel_uid,
})
.then((resp) => {
this.visible = false;
this.$message.success("修改成功");
this.username = resp.data.username;
this.privacy = resp.data.privacy;
this.bind_qq = resp.data.bind_qq;
this.qq_channel_uid = resp.data.qq_channel_uid;
this.import_token = resp.data.import_token;
this.plate = resp.data.plate;
this.nickname = resp.data.nickname;
for (let elem of this.ratings) {
Expand All @@ -291,6 +357,14 @@ export default {
this.$message.error(`错误:${err.response.data.message}`)
});
},
generateToken() {
axios.put("/api/maimaidxprober/player/import_token").then(resp => {
this.import_token = resp.data.token;
this.$message.success("已生成新的导入 Token");
}).catch(() => {
this.$message.error(`生成导入 Token 失败!`)
}).finally(() => this.generateTokenVisible = false);
},
delete_records() {
axios.all([
axios.delete("https://www.diving-fish.com/api/maimaidxprober/player/delete_records"),
Expand Down Expand Up @@ -324,6 +398,8 @@ export default {
this.username = resp.data.username;
this.privacy = resp.data.privacy;
this.bind_qq = resp.data.bind_qq;
this.qq_channel_uid = resp.data.qq_channel_uid;
this.import_token = resp.data.import_token;
this.ra = resp.data.additional_rating;
this.plate = resp.data.plate;
this.nickname = resp.data.nickname;
Expand All @@ -340,6 +416,13 @@ export default {
})
.catch(() => {});
},
copyToClipboard(text) {
navigator.clipboard.writeText(text).then(() => {
this.$message.success("已复制到剪贴板");
}).catch(() => {
this.$message.error("复制失败");
})
}
},
created: function () {
for (const elem of [
Expand Down Expand Up @@ -376,4 +459,9 @@ export default {
display: flex;
align-items: center;
}
.click-icon {
cursor: pointer;
margin-left: 4px;
}
</style>

0 comments on commit 3303b72

Please sign in to comment.