Skip to content

Commit

Permalink
V0.7.3 (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
wuhan005 authored Feb 1, 2021
1 parent f7287fb commit 9896044
Show file tree
Hide file tree
Showing 7 changed files with 925 additions and 875 deletions.
90 changes: 45 additions & 45 deletions dist/dist_gen.go

Large diffs are not rendered by default.

13 changes: 11 additions & 2 deletions src/assets/languages/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@
"gamebox": "Gamebox",
"round": "Round",
"flag": "Flag",
"select_team": "Select Team...",
"select_challenge": "Select Challenge...",
"filter": "Filter",
"clean_filter": "Clean Filter",
"confirm": "Confirm",
"generate_flag_confirm": "This operation will delete all the existing flags and regenerate them. Are you sure to continue?",
"export_flag": "Export Flag"
Expand Down Expand Up @@ -102,6 +106,7 @@
"gamebox": {
"add": "Add",
"publish": "New Gamebox",
"publish_out": "New External Gamebox",
"challenge": "Challenge",
"team": "Team",
"ip": "IP",
Expand All @@ -127,7 +132,9 @@
"test_ssh_success": "SSH Connect Successfully!",
"test_ssh_fail": "Fail to Connect the SSH.",
"input_shell_command": "Please input the shell command to test",
"refresh_flag": "Refresh all the flags"
"refresh_flag": "Refresh all the flags",
"reset": "Reset all gameboxes",
"reset_confirm": "This operation will reset all the gameboxes. Are you sure to continue?"
},
"login": {
"account": "Account",
Expand Down Expand Up @@ -197,10 +204,12 @@
"type_game_end": "Game End"
},
"config": {
"save": "Save",
"title": "Title",
"flag_prefix": "Flag Prefix",
"flag_suffix": "Flag Suffix",
"animate_asteroid": "More Animate Asteroid",
"show_others_gamebox": "Show Other Teams' GameBoxes"
"show_others_gamebox": "Show Other Teams' GameBoxes",
"default_language": "🌐 Default Language"
}
}
13 changes: 11 additions & 2 deletions src/assets/languages/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@
"gamebox": "所属靶机",
"round": "所属轮数",
"flag": "Flag",
"select_team": "选择队伍",
"select_challenge": "选择题目",
"filter": "筛选",
"clean_filter": "清除筛选条件",
"confirm": "请确认",
"generate_flag_confirm": "此操作将删除现有的 Flag 并重新生成, 是否继续?",
"export_flag": "导出题目 Flag"
Expand Down Expand Up @@ -102,6 +106,7 @@
"gamebox": {
"add": "新增",
"publish": "添加新靶机",
"publish_out": "添加外部靶机",
"challenge": "题目名",
"team": "所属队伍",
"ip": "题目 IP",
Expand All @@ -127,7 +132,9 @@
"test_ssh_fail": "SSH 连接失败",
"test_ssh_success": "SSH 连接全部成功!",
"input_shell_command": "请输入需要测试的 Shell 命令",
"refresh_flag": "更新所有 Flag"
"refresh_flag": "更新所有 Flag",
"reset": "重置所有靶机分数",
"reset_confirm": "您确认重置所有靶机分数吗?"
},
"login": {
"account": "账号",
Expand Down Expand Up @@ -197,10 +204,12 @@
"type_game_end": "比赛结束时"
},
"config": {
"save": "保存配置",
"title": "比赛名",
"flag_prefix": "Flag 前缀",
"flag_suffix": "Flag 后缀",
"animate_asteroid": "更绚丽的 Asteroid 大屏",
"show_others_gamebox": "队伍靶机相互可见"
"show_others_gamebox": "队伍靶机相互可见",
"default_language": "🌐 默认语言 / Default Language"
}
}
135 changes: 70 additions & 65 deletions src/components/Header.vue
Original file line number Diff line number Diff line change
@@ -1,78 +1,83 @@
<template>
<div>
<!-- <TaskView :visible="taskVisible" @visibleChange="(val) => {taskVisible = val}"></TaskView>-->
<el-menu :default-active="this.$route.path" mode="horizontal" :router="true" background-color="#323232"
text-color="#fff" active-text-color="#2194EC">
<el-menu-item>{{ base.Title }}</el-menu-item>
<el-menu-item index="/">{{$t('header.panel')}}</el-menu-item>
<el-menu-item index="/team">{{$t('header.team')}}</el-menu-item>
<el-menu-item index="/challenge">{{$t('header.challenge')}}</el-menu-item>
<el-menu-item index="/gamebox">{{$t('header.gamebox')}}</el-menu-item>
<!-- <el-menu-item index="/docker">{{$t('header.docker')}}</el-menu-item>-->
<el-menu-item index="/flag">{{$t('header.flag')}}</el-menu-item>
<el-menu-item index="/bulletin">{{$t('header.bulletin')}}</el-menu-item>
<el-menu-item index="/asteroid">{{$t('header.asteroid')}}</el-menu-item>
<el-menu-item index="/webhook">{{$t('header.webhook')}}</el-menu-item>
<el-menu-item index="/config">{{$t('header.config')}}</el-menu-item>
<el-menu-item index="/manager">{{$t('header.manager')}}</el-menu-item>
<el-menu-item v-if="$route.name !== 'Login'" index="" @click="onLogout">{{$t('header.logout')}}
</el-menu-item>
<el-menu-item index="">
<el-dropdown @command="(lang) => this.$i18n.locale = lang" class="height: 100%;">
<div>
<!-- <TaskView :visible="taskVisible" @visibleChange="(val) => {taskVisible = val}"></TaskView>-->
<el-menu :default-active="this.$route.path" mode="horizontal" :router="true" background-color="#323232"
text-color="#fff" active-text-color="#2194EC">
<el-menu-item>{{ base.Title }}</el-menu-item>
<el-menu-item index="/">{{ $t('header.panel') }}</el-menu-item>
<el-menu-item index="/team">{{ $t('header.team') }}</el-menu-item>
<el-menu-item index="/challenge">{{ $t('header.challenge') }}</el-menu-item>
<el-menu-item index="/gamebox">{{ $t('header.gamebox') }}</el-menu-item>
<!-- <el-menu-item index="/docker">{{$t('header.docker')}}</el-menu-item>-->
<el-menu-item index="/flag">{{ $t('header.flag') }}</el-menu-item>
<el-menu-item index="/bulletin">{{ $t('header.bulletin') }}</el-menu-item>
<el-menu-item index="/asteroid">{{ $t('header.asteroid') }}</el-menu-item>
<el-menu-item index="/webhook">{{ $t('header.webhook') }}</el-menu-item>
<el-menu-item index="/config">{{ $t('header.config') }}</el-menu-item>
<el-menu-item index="/manager">{{ $t('header.manager') }}</el-menu-item>
<el-menu-item v-if="$route.name !== 'Login'" index="" @click="onLogout">{{ $t('header.logout') }}
</el-menu-item>
<el-menu-item index="">
<el-dropdown @command="(lang) => this.$i18n.locale = lang" class="height: 100%;">
<span>
{{$i18n.locale}}
{{ $i18n.locale }}
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item v-for="(lang, index) in $i18n.availableLocales" v-bind:key="index"
:command="lang">{{lang}}
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</el-menu-item>
<!-- <el-menu-item style="float: right;">-->
<!-- <el-badge :value="200" :max="99" class="badge">-->
<!-- <el-button plain size="small" style="margin-top: -20px;" @click="taskVisible = true">任务队列-->
<!-- </el-button>-->
<!-- </el-badge>-->
<!-- </el-menu-item>-->
</el-menu>
</div>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item v-for="(lang, index) in $i18n.availableLocales" v-bind:key="index"
:command="lang">{{ lang }}
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</el-menu-item>
<!-- <el-menu-item style="float: right;">-->
<!-- <el-badge :value="200" :max="99" class="badge">-->
<!-- <el-button plain size="small" style="margin-top: -20px;" @click="taskVisible = true">任务队列-->
<!-- </el-button>-->
<!-- </el-badge>-->
<!-- </el-menu-item>-->
</el-menu>
</div>
</template>

<script>
// import TaskView from "./TaskView";
// import TaskView from "./TaskView";
export default {
name: "Header",
// components: {TaskView},
data: () => ({
base: {
Title: ''
},
taskVisible: false,
}),
export default {
name: "Header",
// components: {TaskView},
data: () => ({
base: {
Title: ''
},
taskVisible: false,
}),
created() {
this.utils.GET('/base').then(res => {
this.base = res
}).catch(err => this.$message.error(err))
},
created() {
this.utils.GET('/base').then(res => {
this.base = res
this.setLanguage()
}).catch(err => this.$message.error(err))
},
methods: {
onLogout() {
this.utils.GET('/manager/logout').then(res => {
this.$message.success(res)
localStorage.removeItem('managerToken')
this.$router.push('/login')
}).catch(err => this.$message.error(err))
},
},
}
methods: {
setLanguage() {
this.$i18n.locale = this.base.Language
},
onLogout() {
this.utils.GET('/manager/logout').then(res => {
this.$message.success(res)
localStorage.removeItem('managerToken')
this.$router.push('/login')
}).catch(err => this.$message.error(err))
},
},
}
</script>

<style scoped>
.badge {
margin-top: 10px;
margin-right: 30px;
}
.badge {
margin-top: 10px;
margin-right: 30px;
}
</style>
108 changes: 59 additions & 49 deletions src/views/Config.vue
Original file line number Diff line number Diff line change
@@ -1,58 +1,68 @@
<template>
<div>
<el-row :gutter="20">
<el-col :span="8" :offset="7">
<el-form label-width="200px">
<el-form-item v-for="(c, index) in config" v-bind:key="index" :label="$t(`config.${c.Key}`)">
<el-input v-if="c.Kind === 0" v-model="config[index].Value"></el-input>
<el-switch v-if="c.Kind === 1" v-model="config[index].Value"></el-switch>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="saveConfig">保存配置</el-button>
</el-form-item>
</el-form>
</el-col>
</el-row>
</div>
<div>
<el-row :gutter="20">
<el-col :span="8" :offset="7">
<el-form label-width="250px">
<el-form-item v-for="(c, index) in config" v-bind:key="index" :label="$t(`config.${c.Key}`)">
<el-input v-if="c.Kind === 0" v-model="config[index].Value"></el-input>
<el-switch v-if="c.Kind === 1" v-model="config[index].Value"></el-switch>
<el-select v-if="c.Kind === 2" v-model="config[index].Value" placeholder="">
<el-option
v-for="(item, index) in c.Options.split('|')"
:key="index"
:label="item"
:value="item">
</el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="saveConfig">{{ $t('config.save') }}</el-button>
</el-form-item>
</el-form>
</el-col>
</el-row>
</div>
</template>

<script>
export default {
name: "Config",
data() {
return {
config: [],
}
},
mounted() {
this.getAllConfig()
},
methods: {
getAllConfig() {
this.utils.GET('/manager/configs').then(res => {
this.config = res
for (let i = 0; i < this.config.length; i++) {
// Convert the string to boolean
if (this.config[i].Kind === 1) {
this.config[i].Value = this.config[i].Value === 'true'
}
}
}).catch(err => this.$message.error(err))
},
saveConfig() {
for (let i = 0; i < this.config.length; i++) {
// Convert the boolean to string
if (this.config[i].Kind === 1) {
this.config[i].Value = this.config[i].Value.toString()
}
}
this.utils.PUT('/manager/config', this.config).then(res => {
this.$message.success(res)
this.getAllConfig()
}).catch(err => this.$message.error(err))
}
export default {
name: "Config",
data() {
return {
config: [],
}
},
mounted() {
this.getAllConfig()
},
methods: {
getAllConfig() {
this.utils.GET('/manager/configs').then(res => {
this.config = res
for (let i = 0; i < this.config.length; i++) {
// Convert the string to boolean
if (this.config[i].Kind === 1) {
this.config[i].Value = this.config[i].Value === 'true'
}
}
}).catch(err => this.$message.error(err))
},
saveConfig() {
for (let i = 0; i < this.config.length; i++) {
// Convert the boolean to string
if (this.config[i].Kind === 1) {
this.config[i].Value = this.config[i].Value.toString()
}
}
this.utils.PUT('/manager/config', this.config).then(res => {
this.$message.success(res)
this.getAllConfig()
// Hard code here, the index 5 is the `default_language`.
this.$i18n.locale = this.config[5].Value
}).catch(err => this.$message.error(err))
}
}
}
</script>

<style scoped>
Expand Down
Loading

0 comments on commit 9896044

Please sign in to comment.