Skip to content

Commit

Permalink
feat: submit flag
Browse files Browse the repository at this point in the history
  • Loading branch information
wuhan005 committed Aug 7, 2020
1 parent 031bd98 commit b419650
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions src/components/SubmitFlag.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
<template>
<v-card class="mx-auto" v-if="info !== null">
<v-card-title>{{$t('flag.submit')}}</v-card-title>
<v-snackbar v-model="snackBarVisible" color="error" :timeout="3000" :top="true">{{ message }}</v-snackbar>

<v-card-title>
<span style="margin-right: 20px;">{{$t('flag.submit')}}</span>
<v-text-field
v-model="inputFlag"
label="手动提交"
clearable
></v-text-field>
<v-btn style="margin-left: 20px;" @click="submitFlag">提交</v-btn>
</v-card-title>
<v-card-text>
<h2>POST <code style="background-color: #1c1c1c">/flag</code></h2><br>
<p>Content-Type: application/json</p>
Expand All @@ -15,7 +25,8 @@
<br>
<p>
<code class="pa-3" style="width: 100%; background-color: #1c1c1c; color: rgba(255, 255, 255, 0.7);">curl
-X POST {{baseURL}}/api/flag -H 'Authorization: {{info.Token}}' -d '{ "flag": "your_flag_here" }'</code>
-X POST {{baseURL}}/api/flag -H 'Authorization: {{info.Token}}' -d '{ "flag": "your_flag_here"
}'</code>
</p>
</v-card-text>
</v-card>
Expand All @@ -27,7 +38,11 @@
data: () => ({
info: null,
inputFlag: '',
baseURL: window.location.origin,
message: '',
snackBarVisible: false,
}),
mounted() {
Expand All @@ -39,6 +54,18 @@
this.utils.GET("/team/info").then(res => {
this.info = res
})
},
submitFlag() {
this.utils.POST('/flag', {
'flag': this.inputFlag
}).then(res => {
this.inputFlag = ''
this.message = res
this.snackBarVisible = true
}).catch(err => {
this.message = err.response.data.msg
this.snackBarVisible = true
})
}
}
}
Expand Down

0 comments on commit b419650

Please sign in to comment.