gameapi & apigate

This commit is contained in:
yangduo 2024-08-29 19:12:31 +08:00
parent ee182bde8d
commit bbb07f9d29
5 changed files with 547 additions and 1 deletions

49
src/api/workertool.js Normal file
View File

@ -0,0 +1,49 @@
import request from '@/utils/request'
export function addGameapi(data) {
return request({
url: '/gameapihost/add',
method: 'post',
data
})
}
export function getGameapiList(data) {
return request({
url: '/gameapihost/list',
method: 'post',
data
})
}
export function updateGameapi(data) {
return request({
url: '/gameapihost/edit',
method: 'post',
data
})
}
export function addApigate(data) {
return request({
url: '/apigate/add',
method: 'post',
data
})
}
export function getApigateList(data) {
return request({
url: '/apigate/list',
method: 'post',
data
})
}
export function updateApigate(data) {
return request({
url: '/apigate/edit',
method: 'post',
data
})
}

View File

@ -361,6 +361,29 @@ export const asyncRoutes = [
meta: { title: '激活码', pername: 'activecode' }
}
]
}, {
path: '/workertool',
component: Layout,
redirect: '/index',
meta: {
title: '运维工具',
icon: 'skill',
pername: 'wokertool'
},
children: [
{
path: 'index',
component: () => import('@/views/workertool/gameapi'),
name: 'gameapi',
meta: { title: 'php服务器配置', pername: 'gameapi' }
},
{
path: 'apigate',
component: () => import('@/views/workertool/apigate'),
name: 'apigate',
meta: { title: 'apigate服务器配置', pername: 'apigate' }
}
]
}
// {
// path: '/permission',

View File

@ -85,7 +85,7 @@
<el-dialog :title="dialogTitle" :visible.sync="dialogFormVisible" :close-on-click-modal="false" @close="handleDialogClose()">
<el-form ref="form" :rules="rules" :model="form" label-position="left" label-width="130px" style="width: 400px; margin-left:50px;">
<el-form-item label="账号/钱包/email" prop="user_identity">
<el-input v-model="form.user_identity" />
<el-input v-model="form.user_identity" :readonly="dialogStatus!=='create'" />
</el-form-item>
<el-form-item label="是否生效" prop="enable">
<el-switch

View File

@ -0,0 +1,237 @@
<template>
<div class="app-container">
<div class="filter-container">
<el-button class="filter-item" style="margin-left: 10px;" type="primary" @click="handleCreate">
新增
</el-button>
</div>
<el-table
:data="apigates"
border
fit
highlight-current-row
style="width: 100%;"
:empty-text="emptytext"
height="480"
>
<el-table-column
label="host(ip)"
prop="apigate_host"
/>
<el-table-column
label="port"
prop="apigate_port"
/>
<el-table-column
label="是否生效"
prop="enable"
>
<template slot-scope="scope">
<svg-icon v-if="scope.row.enable === 0" icon-class="no" style="font-size: 20px;" />
<svg-icon v-else icon-class="ok" style="font-size: 20px;" />
</template>
</el-table-column>
<el-table-column
fixed="right"
label="操作"
>
<template slot-scope="scope">
<el-button type="text" size="small" @click="handleUpdate(scope.row)">编辑</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination
background
:current-page="curpage"
:page-size="page_size"
:page-count="totalpage"
layout="prev, pager, next"
@current-change="handleCurrentChange"
/>
<el-dialog :title="dialogTitle" :visible.sync="dialogFormVisible" :close-on-click-modal="false" @close="handleDialogClose()">
<el-form ref="form" :rules="rules" :model="form" label-position="left" label-width="130px" style="width: 400px; margin-left:50px;">
<el-form-item label="host(ip)" prop="apigate_host">
<el-input v-model="form.apigate_host" :readonly="dialogStatus!=='create'" />
</el-form-item>
<el-form-item label="port" prop="apigate_port">
<el-input v-model.number="form.apigate_port" :readonly="dialogStatus!=='create'" />
</el-form-item>
<el-form-item label="是否生效" prop="enable">
<el-switch
v-model="form.enable"
:active-value="1"
:inactive-value="0"
active-color="#13ce66"
inactive-color="#ff4949"
/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="dialogFormVisible = handleDialogClose()">
Cancel
</el-button>
<el-button type="primary" @click="dialogStatus==='create'?createData():updateData()">
Confirm
</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
// import Pagination from '@/components/Pagination/index.vue'
import { addApigate, getApigateList, updateApigate } from '@/api/workertool'
import { parseTime } from '@/utils'
export default {
components: {
},
data() {
return {
form: {
apigate_host: '',
apigate_port: '',
enable: 1
},
dialogFormVisible: false,
dialogStatus: '',
apigates: [],
dialogTitle: '新增',
emptytext: ' ',
totalpage: 0,
curpage: 1,
page_size: 8,
rules: {
apigate_host: [{ required: true, message: 'required', trigger: 'blur' }],
apigate_port: [{ required: true, message: 'required', trigger: 'blur' }],
type: [{ required: true, message: 'required', trigger: 'blur' }]
},
uploadUrl: '',
uploadData: {
file: ''
},
filelist: []
}
},
created() {
this.getList()
},
methods: {
parseTime,
handleDialogClose() {
// this.getList()
},
handleUpdate(row) {
this.form.enable = row.enable
this.form.apigate_host = row.apigate_host
this.form.apigate_port = row.apigate_port
this.dialogStatus = 'update'
this.dialogTitle = '编辑'
this.dialogFormVisible = true
this.$nextTick(() => {
this.$refs['form'].clearValidate()
})
},
/* handleDel(row) {
this.$confirm('此操作将无法恢复, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
delWhiteList({ apigate_host: row.apigate_host }).then(response => {
if (response.code === 0) {
if (this.apigates.length === 1 && this.curpage === this.totalpage && this.curpage > 1) {
this.curpage--
}
this.getList()
this.$notify({
title: 'Success',
message: 'Deleted Successfully',
type: 'success',
duration: 2000
})
}
})
}).catch(() => {
})
}, */
getList() {
const data = {
'page_dto': {
'page': this.curpage,
'pageSize': this.page_size
}
}
getApigateList(data).then(response => {
this.apigates = response.data
this.totalpage = response.total_page
this.curpage = response.cur_page
if (this.apigates === undefined || this.apigates.length <= 0) {
this.emptytext = 'No data'
}
})
},
handleCurrentChange(val) {
this.curpage = val
this.getList()
},
handleCreate() {
this.resetTemp()
this.dialogStatus = 'create'
this.dialogTitle = '新增'
this.dialogFormVisible = true
this.$nextTick(() => {
this.$refs['form'].clearValidate()
})
},
resetTemp() {
this.form = {
apigate_host: '',
apigate_port: '',
enable: 0
}
},
createData() {
this.$refs['form'].validate((valid) => {
if (valid) {
addApigate(this.form).then(response => {
if (response.code === 0) {
this.dialogFormVisible = false
this.getList()
this.$notify({
title: 'Success',
message: 'Created Successfully',
type: 'success',
duration: 2000
})
}
})
}
})
},
updateData() {
this.$refs['form'].validate((valid) => {
if (valid) {
updateApigate(this.form).then(response => {
if (response.code === 0) {
this.dialogFormVisible = false
this.getList()
this.$notify({
title: 'Success',
message: 'Updated Successfully',
type: 'success',
duration: 2000
})
}
})
}
})
}
}
}
</script>

View File

@ -0,0 +1,237 @@
<template>
<div class="app-container">
<div class="filter-container">
<el-button class="filter-item" style="margin-left: 10px;" type="primary" @click="handleCreate">
新增
</el-button>
</div>
<el-table
:data="gameapihosts"
border
fit
highlight-current-row
style="width: 100%;"
:empty-text="emptytext"
height="480"
>
<el-table-column
label="host(ip)"
prop="gameapi_host"
/>
<el-table-column
label="port"
prop="gameapi_port"
/>
<el-table-column
label="是否生效"
prop="enable"
>
<template slot-scope="scope">
<svg-icon v-if="scope.row.enable === 0" icon-class="no" style="font-size: 20px;" />
<svg-icon v-else icon-class="ok" style="font-size: 20px;" />
</template>
</el-table-column>
<el-table-column
fixed="right"
label="操作"
>
<template slot-scope="scope">
<el-button type="text" size="small" @click="handleUpdate(scope.row)">编辑</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination
background
:current-page="curpage"
:page-size="page_size"
:page-count="totalpage"
layout="prev, pager, next"
@current-change="handleCurrentChange"
/>
<el-dialog :title="dialogTitle" :visible.sync="dialogFormVisible" :close-on-click-modal="false" @close="handleDialogClose()">
<el-form ref="form" :rules="rules" :model="form" label-position="left" label-width="130px" style="width: 400px; margin-left:50px;">
<el-form-item label="host(ip)" prop="gameapi_host">
<el-input v-model="form.gameapi_host" :readonly="dialogStatus!=='create'" />
</el-form-item>
<el-form-item label="port" prop="gameapi_port">
<el-input v-model.number="form.gameapi_port" :readonly="dialogStatus!=='create'" />
</el-form-item>
<el-form-item label="是否生效" prop="enable">
<el-switch
v-model="form.enable"
:active-value="1"
:inactive-value="0"
active-color="#13ce66"
inactive-color="#ff4949"
/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="dialogFormVisible = handleDialogClose()">
Cancel
</el-button>
<el-button type="primary" @click="dialogStatus==='create'?createData():updateData()">
Confirm
</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
// import Pagination from '@/components/Pagination/index.vue'
import { addGameapi, getGameapiList, updateGameapi } from '@/api/workertool'
import { parseTime } from '@/utils'
export default {
components: {
},
data() {
return {
form: {
gameapi_host: '',
gameapi_port: '',
enable: 1
},
dialogFormVisible: false,
dialogStatus: '',
gameapihosts: [],
dialogTitle: '新增',
emptytext: ' ',
totalpage: 0,
curpage: 1,
page_size: 8,
rules: {
gameapi_host: [{ required: true, message: 'required', trigger: 'blur' }],
gameapi_port: [{ required: true, message: 'required', trigger: 'blur' }],
type: [{ required: true, message: 'required', trigger: 'blur' }]
},
uploadUrl: '',
uploadData: {
file: ''
},
filelist: []
}
},
created() {
this.getList()
},
methods: {
parseTime,
handleDialogClose() {
// this.getList()
},
handleUpdate(row) {
this.form.enable = row.enable
this.form.gameapi_host = row.gameapi_host
this.form.gameapi_port = row.gameapi_port
this.dialogStatus = 'update'
this.dialogTitle = '编辑'
this.dialogFormVisible = true
this.$nextTick(() => {
this.$refs['form'].clearValidate()
})
},
/* handleDel(row) {
this.$confirm('此操作将无法恢复, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
delWhiteList({ gameapi_host: row.gameapi_host }).then(response => {
if (response.code === 0) {
if (this.gameapihosts.length === 1 && this.curpage === this.totalpage && this.curpage > 1) {
this.curpage--
}
this.getList()
this.$notify({
title: 'Success',
message: 'Deleted Successfully',
type: 'success',
duration: 2000
})
}
})
}).catch(() => {
})
}, */
getList() {
const data = {
'page_dto': {
'page': this.curpage,
'pageSize': this.page_size
}
}
getGameapiList(data).then(response => {
this.gameapihosts = response.data
this.totalpage = response.total_page
this.curpage = response.cur_page
if (this.gameapihosts === undefined || this.gameapihosts.length <= 0) {
this.emptytext = 'No data'
}
})
},
handleCurrentChange(val) {
this.curpage = val
this.getList()
},
handleCreate() {
this.resetTemp()
this.dialogStatus = 'create'
this.dialogTitle = '新增'
this.dialogFormVisible = true
this.$nextTick(() => {
this.$refs['form'].clearValidate()
})
},
resetTemp() {
this.form = {
gameapi_host: '',
gameapi_port: '',
enable: 0
}
},
createData() {
this.$refs['form'].validate((valid) => {
if (valid) {
addGameapi(this.form).then(response => {
if (response.code === 0) {
this.dialogFormVisible = false
this.getList()
this.$notify({
title: 'Success',
message: 'Created Successfully',
type: 'success',
duration: 2000
})
}
})
}
})
},
updateData() {
this.$refs['form'].validate((valid) => {
if (valid) {
updateGameapi(this.form).then(response => {
if (response.code === 0) {
this.dialogFormVisible = false
this.getList()
this.$notify({
title: 'Success',
message: 'Updated Successfully',
type: 'success',
duration: 2000
})
}
})
}
})
}
}
}
</script>