Commit e98a4753 authored by 付清曌's avatar 付清曌

Merge branch 'new0219' into 'master'

New0219

See merge request !2
parents 5b084957 348e681d
...@@ -19,6 +19,7 @@ module.exports = { ...@@ -19,6 +19,7 @@ module.exports = {
'prettier/prettier': 'error', 'prettier/prettier': 'error',
// 防止iview的标签报错 // 防止iview的标签报错
'vue/no-parsing-error': [2, { 'x-invalid-end-tag': false }], 'vue/no-parsing-error': [2, { 'x-invalid-end-tag': false }],
'prettier/prettier': 0,
}, },
} }
module.exports = {
"printWidth": 200,
"trailingComma": "es5",
"singleQuote": true,
}
\ No newline at end of file
import axios from '../services/http.service' import axios from "../services/http.service";
import { import { sapi } from "../config";
sapi // import qs from "qs";
} from '../config'
import qs from 'qs'
let comapi = '/heimdallr-config'
// 获取服务列表 // 获取服务列表
export function getservicelist () { export function getservicelist() {
return axios.get(`${sapi}/service/list`) return axios.get(`${sapi}/service/list`);
} }
// 获取文字说明 // 获取文字说明
export function getkey (key) { export function getkey(key) {
return axios.get(`${sapi}/get-key-explain/${key}`) return axios.get(`${sapi}/get-key-explain/${key}`);
} }
// 获取配置列表 // 获取配置列表
export function getconfigurelist (data) { export function getconfigurelist(data) {
return axios.get(`${sapi}/config/service/${data.key}/${data.service_name}`) return axios.get(`${sapi}/config/service/${data.key}/${data.service_name}`);
} }
// 发布 // 发布
export function postconfigurelist (data, params) { export function postconfigurelist(data, params) {
return axios.post(`${sapi}/config/service/${data.key}/${data.service_name}`, params, {headers: { return axios.post(
'Content-Type': 'application/json' `${sapi}/config/service/${data.key}/${data.service_name}`,
}}) params,
{
headers: {
"Content-Type": "application/json"
}
}
);
} }
// 获取版本 // 获取版本
export function getVersionnumber (data) { export function getVersionnumber(data) {
return axios.get(`${sapi}/config-version/service/${data.key}/${data.service_name}/list`) return axios.get(
`${sapi}/config-version/service/${data.key}/${data.service_name}/list`
);
} }
// 回滚版本 // 回滚版本
export function rollbacknum (data) { export function rollbacknum(data) {
return axios.get(`${sapi}/config-version/service/${data.key}/${data.service_name}/set/${data.version}`) return axios.get(
`${sapi}/config-version/service/${data.key}/${data.service_name}/set/${data.version}`
);
} }
// 获取节点列表 // 获取节点列表
export function getnodelist (data) { export function getnodelist(data) {
return axios.get(`${sapi}/node/list/${data.service_name}`) return axios.get(`${sapi}/node/list/${data.service_name}`);
} }
// 获取节点配置 // 获取节点配置
export function getnodeconfig (data) { export function getnodeconfig(data) {
return axios.get(`${sapi}/config/node/${data.service_name}/${data.node_id}`) return axios.get(`${sapi}/config/node/${data.service_name}/${data.node_id}`);
} }
// 设置节点配置 // 设置节点配置
export function nodeconfig (data, weight) { export function nodeconfig(data, weight) {
return axios.post(`${sapi}/config/node/${data.service_name}/${data.node_id}`, weight, {headers: { return axios.post(
'Content-Type': 'application/json' `${sapi}/config/node/${data.service_name}/${data.node_id}`,
}}) weight,
{
headers: {
"Content-Type": "application/json"
}
}
);
}
// 获取菜单列表
export function getMenuList() {
return axios.get(`${sapi}/key/list`);
}
// 获取标签列表
export function getTypeList() {
return axios.get(`${sapi}/filter/list`);
} }
const sapi = 'https://kapi-fe.liangkebang.net' const sapi = "https://kapi-fe.liangkebang.net";
// const sapi = 'http://192.168.29.88:5555' // const sapi = 'http://192.168.29.88:5555'
export { export { sapi };
sapi
}
let comapi = '/heimdallr-config' // let comapi = "/heimdallr-config";
const sapi = `//kapi.xyqb.com/heimdallr-config` const sapi = `//kapi.xyqb.com/heimdallr-config`;
// const sapi = `//kapi.xyqb.com` // const sapi = `//kapi.xyqb.com`;
export { export { sapi };
sapi
}
...@@ -14,12 +14,7 @@ ...@@ -14,12 +14,7 @@
</div> </div>
<div class="content_header_list"> <div class="content_header_list">
<div class="header_list_left"> <div class="header_list_left">
<p class="list_content" @click="authenticationlist('url_auth_list')" :class="{'colorlistone':listonecolorauth}">鉴权URL列表</p> <p class="list_content" v-for="(item, index) in menu" :key="index" :class="{'colorlistone':index==colorIndex}" @click="authenticationlist(item.Key,index)"> {{item.Value}}</p>
<p class="list_content" @click="foreignlist('url_white_list')" :class="{'colorlistone':listonecolorfor}">对外URL列表</p>
<p class="list_content" @click="internallylist('url_black_list')" :class="{'colorlistone':listonecolorint}">对内URL列表</p>
<p class="list_content" @click="domainnameprefixlist('domain_prefix')" :class="{'colorlistone':listonecolordoma}">域名前缀列表</p>
<p class="list_content" @click="serviceAdministrator('service_owner')" :class="{'colorlistone':listonecolorserv}">服务管理员列表</p>
<p class="list_content" @click="testmo('test_mode')" :class="{'colorlistone':listonecolortest}">测试模式</p>
</div> </div>
<div class="header_list_right"> <div class="header_list_right">
<div class="list_right_header"> <div class="list_right_header">
...@@ -27,9 +22,9 @@ ...@@ -27,9 +22,9 @@
<span class="textExplain" v-html="textExplain"></span> <span class="textExplain" v-html="textExplain"></span>
</div> </div>
<div class="list_right_content"> <div class="list_right_content">
<p class="right_content_btn"> <div class="right_content_btn">
<Button type="primary" size = 'small' @click="configlist" :class="{'colorlistcolor':colorupdata}">发布</Button> <Button type="primary" size = 'small' @click="configlist" :class="{'colorlistcolor':colorupdata}">发布</Button>
</p> </div>
<p> <p>
<Button type="primary" size = 'small' @click="rollback">回滚</Button> <Button type="primary" size = 'small' @click="rollback">回滚</Button>
</p> </p>
...@@ -37,19 +32,19 @@ ...@@ -37,19 +32,19 @@
</div> </div>
<div class="list_right_configure"> <div class="list_right_configure">
<div class="configure_content" v-show="isShowList"> <div class="configure_content" v-show="isShowList">
<p class="configure_content_configure"> <div class="configure_content_configure">
<span><Input v-model="singlebaraddition" placeholder="请输入配置项" style="width: 65%;margin-top:1%;float:left;margin-left:2%" @keyup.enter.native='oneadd'/></span> <span><Input v-model="singlebaraddition" placeholder="请输入配置项" style="width: 65%;margin-top:1%;float:left;margin-left:2%" @keyup.enter.native='oneadd'/></span>
<Button type="primary" size = 'small' style="margin:1.2% 0 0 1%;float:left" @click="oneadd">单条添加</Button> <Button type="primary" size = 'small' style="margin:1.2% 0 0 1%;float:left" @click="oneadd">单条添加</Button>
<span style="float:right;margin:1.2% 2% 0% 1%"> <span style="float:right;margin:1.2% 2% 0% 1%">
<Button type="primary" size = 'small' @click="clear">清空</Button> <Button type="primary" size = 'small' @click="clear">清空</Button>
<Button type="primary" size = 'small' @click="alladd">批量添加</Button> <Button type="primary" size = 'small' @click="alladd">批量添加</Button>
</span> </span>
</p> </div>
<p class="configure_content_page"> <p class="configure_content_page">
<Table :data='logData' :columns='logCol' border ></Table> <Table :data='logData' :columns='logCol' border ></Table>
</p> </p>
</div> </div>
<div class="configure_content_test" v-show="isShowList == false"> <div class="configure_content_test" v-show="showTestModal">
<p class="test_content"> <p class="test_content">
<span style="margin-left:20px">状态: <span style="margin-left:20px">状态:
<span class="test_conten_status" v-if="testmostatus === true">开启</span> <span class="test_conten_status" v-if="testmostatus === true">开启</span>
...@@ -60,6 +55,51 @@ ...@@ -60,6 +55,51 @@
</span> </span>
</p> </p>
</div> </div>
<div class="ipSet" v-show="showIpSet">
<div style="float:right">
<Button type="primary" size = 'small' @click="clear">清空</Button>
<Button type="primary" size = 'small' @click="addIpset">添加</Button>
</div>
<div style="float:left;margin:10px 0" class="configure_content_page">
<Table :data='ipsetData' :columns='ipsetCol' border ></Table>
</div>
</div>
<div class="urlIpSet" v-show="showUrlIpSet">
<div style="float:right">
<Button type="primary" size = 'small' @click="clear">清空</Button>
<Button type="primary" size = 'small' @click="addUrlIpset">添加</Button>
</div>
<div style="float:left;margin:10px 0" class="configure_content_page">
<Table :data='urlIpSetData' :columns='urlIpSetCol' border ></Table>
</div>
</div>
<div class="urlIpSet" v-show="showLimit">
<div style="float:right">
<Button type="primary" size = 'small' @click="clear">清空</Button>
<Button type="primary" size = 'small' @click="addLimit">添加</Button>
</div>
<div style="float:left;margin:10px 0" class="configure_content_page">
<Table :data='limitData' :columns='limitCol' border ></Table>
</div>
</div>
<div class="urlIpSet" v-show="showSpecified">
<div style="float:right">
<Button type="primary" size = 'small' @click="clear">清空</Button>
<Button type="primary" size = 'small' @click="addSpecified">添加</Button>
</div>
<div style="float:left;margin:10px 0" class="configure_content_page">
<Table :data='specifiedData' :columns='specifiedCol' border ></Table>
</div>
</div>
<div class="urlIpSet" v-show="showElse">
<div style="float:right">
<Button type="primary" size = 'small' @click="modify">修改</Button>
<Button type="primary" size = 'small' @click="reduction">还原</Button>
</div>
<div style="float:left;margin:10px 0;border-top:1px solid #999;width:100%;height:100%">
{{origenContent}}
</div>
</div>
</div> </div>
</div> </div>
</div> </div>
...@@ -73,6 +113,77 @@ ...@@ -73,6 +113,77 @@
</div> </div>
</div> </div>
</div> </div>
<Modal v-model="addIpsetModal" :mask-closable = 'false' :footer-hide='true'>
<Form ref="formInline" :model="formInline" :rules="ruleInline" style="margin-top:20px" :label-width="80">
<FormItem prop="alladdcontent" label="名称:">
<Input v-model="ipsetName" type="text" placeholder="请输入名称" :disabled="updataIpsetSta" style="width: 70%" />
</FormItem>
<FormItem prop="alladdcontent" label="列表:">
<Input v-model="ipsetContent" type="text" placeholder="请输入" style="width: 70%" />
</FormItem>
</Form>
<div class="alladdbtn">
<Button type="primary" size='large' style="margin:0 20px" @click="addIpsetModal = false">取消</Button>
<Button type="primary" size='large' @click="confireIpset">保存</Button>
</div>
</Modal>
<Modal v-model="addUrlIpsetModal" :mask-closable = 'false' :footer-hide='true'>
<Form ref="formInline" :model="formInline" :rules="ruleInline" style="margin-top:20px" :label-width="80">
<FormItem prop="alladdcontent" label="路径:">
<Input v-model="urlIpsetPath" type="text" placeholder="请输入" style="width: 70%" />
</FormItem>
<FormItem prop="alladdcontent" label="集合:">
<Select v-model="urlIpsetName" style="width:70%">
<Option v-for="item in ipsetList" :value="item" :key="item">{{ item }}</Option>
</Select>
</FormItem>
</Form>
<div class="alladdbtn">
<Button type="primary" size='large' style="margin:0 20px" @click="addUrlIpsetModal = false">取消</Button>
<Button type="primary" size='large' @click="confireUrlSet">保存</Button>
</div>
</Modal>
<Modal v-model="addLimitModal" :mask-closable = 'false' :footer-hide='true'>
<Form ref="formInline" :model="formInline" :rules="ruleInline" style="margin-top:20px" :label-width="80">
<FormItem prop="alladdcontent" label="路径:">
<Input v-model="limitPath" type="text" placeholder="请输入路径" style="width: 70%" />
</FormItem>
<FormItem prop="alladdcontent" label="单位时间:">
<Input v-model="limitTime" type="number" placeholder="请输入单位时间" style="width: 70%" />
</FormItem>
<FormItem prop="alladdcontent" label="速率:">
<Input v-model="limitRate" type="number" placeholder="请输入速率" style="width: 70%" />
</FormItem>
</Form>
<div class="alladdbtn">
<Button type="primary" size='large' style="margin:0 20px" @click="addLimitModal = false">取消</Button>
<Button type="primary" size='large' @click="confireLimit">保存</Button>
</div>
</Modal>
<Modal v-model="addSpecifiedModal" :mask-closable = 'false' :footer-hide='true'>
<Form ref="formInline" :model="formInline" :rules="ruleInline" style="margin-top:20px" :label-width="80">
<FormItem prop="alladdcontent" label="类型:">
<Select v-model="err_type" style="width:70%" @on-change="changeType">
<Option v-for="(item, index) in typeList" :value="item.value" :key="index">{{ item.value }}</Option>
</Select>
</FormItem>
<FormItem prop="alladdcontent" label="标签:">
<Select v-model="err_tag" style="width:70%">
<Option v-for="(item, index) in tageList" :value="item" :key="index">{{ item }}</Option>
</Select>
</FormItem>
<FormItem prop="alladdcontent" label="header:">
<Input v-model="header" type="text" placeholder="请输入首部" style="width: 70%" />
</FormItem>
<FormItem prop="alladdcontent" label="body:">
<Input v-model="body" type="text" placeholder="请输入主体" style="width: 70%" />
</FormItem>
</Form>
<div class="alladdbtn">
<Button type="primary" size='large' style="margin:0 20px" @click="addSpecifiedModal = false">取消</Button>
<Button type="primary" size='large' @click="confireSpecified">保存</Button>
</div>
</Modal>
<Modal v-model="alladdModal" :mask-closable = 'false' :footer-hide='true'> <Modal v-model="alladdModal" :mask-closable = 'false' :footer-hide='true'>
<h2 class="alladdtitle">批量添加</h2> <h2 class="alladdtitle">批量添加</h2>
<Form ref="formInline" :model="formInline" :rules="ruleInline" style="margin-top:20px" :label-width="80"> <Form ref="formInline" :model="formInline" :rules="ruleInline" style="margin-top:20px" :label-width="80">
...@@ -106,6 +217,29 @@ ...@@ -106,6 +217,29 @@
<Button type="primary" size='small' @click="confiredelate">确认</Button> <Button type="primary" size='small' @click="confiredelate">确认</Button>
</div> </div>
</Modal> </Modal>
<Modal v-model="modifyModal" :mask-closable = 'false' :footer-hide='true' width='300'>
<div style="padding-top:40px">
<Input v-model="updataOrigenContent" type="textarea" clearable style="width: 90%"/>
</div>
<div class="rollbackdivbtn">
<Button type="primary" size='small' style="margin:0 20px" @click="modifyModal = false">取消</Button>
<Button type="primary" size='small' @click="conforeModify">确认</Button>
</div>
</Modal>
<Modal v-model="clearModal" :mask-closable = 'false' :footer-hide='true' width='300'>
<h3 class="delatediv">是否确认清空该列表?</h3>
<div class="rollbackdivbtn">
<Button type="primary" size='small' style="margin:0 20px" @click="clearModal = false">取消</Button>
<Button type="primary" size='small' @click="confireClear">确认</Button>
</div>
</Modal>
<Modal v-model="delateIpModal" :mask-closable = 'false' :footer-hide='true' width='300'>
<h3 class="delatediv">是否确认删除该选项?</h3>
<div class="rollbackdivbtn">
<Button type="primary" size='small' style="margin:0 20px" @click="delateIpModal = false">取消</Button>
<Button type="primary" size='small' @click="confierDelateOne">确认</Button>
</div>
</Modal>
<Modal v-model="changeserverModal" :mask-closable = 'false' :footer-hide='true' width='300'> <Modal v-model="changeserverModal" :mask-closable = 'false' :footer-hide='true' width='300'>
<h3 class="delatediv">有尚未发布的配置,是否确认切换服务?切换会导致未发布的配置丢失。</h3> <h3 class="delatediv">有尚未发布的配置,是否确认切换服务?切换会导致未发布的配置丢失。</h3>
<div class="rollbackdivbtn"> <div class="rollbackdivbtn">
...@@ -169,6 +303,36 @@ ...@@ -169,6 +303,36 @@
<Button type="primary" size='small' @click="confirfabu">发布</Button> <Button type="primary" size='small' @click="confirfabu">发布</Button>
</div> </div>
</Modal> </Modal>
<Modal v-model="elseConfireModal" :mask-closable = 'false' :footer-hide='true' width='500'>
<h3 class="updatediv">是否确认发布?</h3>
<div class="updatetestclass">
<p>
<span>原配置:{{netModily}}</span>
</p>
<p>
<span>新配置:{{origenContent}}</span>
</p>
</div>
<div class="rollbackdivbtn">
<Button type="primary" size='small' style="margin:0 20px" @click="elseConfireModal = false">取消</Button>
<Button type="primary" size='small' @click="confirfabu">发布</Button>
</div>
</Modal>
<Modal v-model="contrastIpset" :mask-closable = 'false' :footer-hide='true' width='500'>
<h3 class="updatediv">是否确认发布?</h3>
<div class="updatetestclass">
<p>
<span>原配置:{{needModilyArr}}</span>
</p>
<p>
<span>新配置:{{newIpsetData}}</span>
</p>
</div>
<div class="rollbackdivbtn">
<Button type="primary" size='small' style="margin:0 20px" @click="contrastIpset = false">取消</Button>
<Button type="primary" size='small' @click="confirfabu">发布</Button>
</div>
</Modal>
<Modal v-model="ContrasttestModal" :mask-closable = 'false' :footer-hide='true' width='500'> <Modal v-model="ContrasttestModal" :mask-closable = 'false' :footer-hide='true' width='500'>
<h3 class="updatediv">是否确认发布?</h3> <h3 class="updatediv">是否确认发布?</h3>
<div class="updatetestclass"> <div class="updatetestclass">
...@@ -202,11 +366,279 @@ ...@@ -202,11 +366,279 @@
</div> </div>
</template> </template>
<script> <script>
import {getservicelist, getkey, getconfigurelist, postconfigurelist, getVersionnumber, rollbacknum, getnodelist, nodeconfig} from '../../api/mainconfigguration.server' import {getservicelist, getkey, getTypeList, getconfigurelist, postconfigurelist, getVersionnumber, rollbacknum, getnodelist, nodeconfig, getMenuList} from '../../api/mainconfigguration.server'
export default { export default {
data () { data () {
return { return {
menu: [],
colorIndex: '',
changeIndex: '',
addIpsetModal: false,
elseConfireModal: false,
addUrlIpsetModal: false,
addSpecifiedModal: false,
addLimitModal: false,
showSpecified: false,
showElse: false,
contrastIpset: false,
updataIpsetSta: false,
updataUrlSta: false,
updataLimitSta: false,
updataSpecifiedSta: false,
delateIpModal: false,
ipsetName: '',
header: '',
err_type: '',
err_tag: '',
body: '',
origenContent: '显示原始值',
urlIpsetPath: '',
urlIpsetName: '',
ipsetContent: '',
typeList: [
{
key: 'pre',
value: 'pre',
},{
key: 'proxy',
value: 'proxy',
},{
key: 'post',
value: 'post',
}
],
limitPath: '',
limitRate: 0,
limitTime: 1,
tageList: [],
ipsetList: [],
ipsetData: [],
ipsetCol:[
{
title: '名称',
key: 'name',
align: 'center'
},
{
title: 'ip列表',
key: 'ip_list',
align: 'center'
},
{
title: '操作',
key: 'action',
// width: 200,
align: 'center',
render: (h, params) => {
let arr = [h('Button', {
props: {
type: 'primary',
size: 'small'
},
style: {
marginRight: '10px'
},
on: {
click: () => {
this.updateIpset(params.row)
}
}
}, '修改'),
h('Button', {
props: {
type: 'primary',
size: 'small',
},
style: {
marginRight: '10px'
},
on: {
click: () => {
this.delateOne(params.row)
}
}
}, '删除')]
return h('div', arr)
}
}
],
clearModal: false,
updataOrigenContent: '',
urlIpSetData: [],
urlIpSetCol: [
{
title: '路径',
key: 'path',
align: 'center'
},
{
title: '集合',
key: 'ip_set_name',
align: 'center'
},
{
title: '操作',
key: 'action',
width: 200,
align: 'center',
render: (h, params) => {
let arr = [h('Button', {
props: {
type: 'primary',
size: 'small'
},
style: {
marginRight: '10px'
},
on: {
click: () => {
this.updateUrlIpset(params.row)
}
}
}, '修改'),
h('Button', {
props: {
type: 'primary',
size: 'small'
},
style: {
marginRight: '10px'
},
on: {
click: () => {
this.delateOne(params.row)
}
}
}, '删除')]
return h('div', arr)
}
}
],
limitData: [],
limitCol: [
{
title: '路径',
key: 'path',
align: 'center'
},
{
title: '单位时间(秒)',
key: 'duration',
align: 'center'
},
{
title: '速率',
key: 'rate',
align: 'center'
},
{
title: '操作',
key: 'action',
width: 200,
align: 'center',
render: (h, params) => {
let arr = [h('Button', {
props: {
type: 'primary',
size: 'small'
},
style: {
marginRight: '10px'
},
on: {
click: () => {
this.updateLimit(params.row)
}
}
}, '修改'),
h('Button', {
props: {
type: 'primary',
size: 'small'
},
style: {
marginRight: '10px'
},
on: {
click: () => {
this.delateOne(params.row)
}
}
}, '删除')]
return h('div', arr)
}
}
],
specifiedData: [],
specifiedCol: [
{
title: '类型',
key: 'err_type',
align: 'center'
},
{
title: '标签',
key: 'err_tag',
align: 'center'
},
{
title: '首部',
key: 'header',
align: 'center'
},
{
title: '主体',
key: 'body',
align: 'center'
},
{
title: '操作',
key: 'action',
width: 200,
align: 'center',
render: (h, params) => {
let arr = [h('Button', {
props: {
type: 'primary',
size: 'small'
},
style: {
marginRight: '10px'
},
on: {
click: () => {
this.updateSpecified(params.row)
}
}
}, '修改'),
h('Button', {
props: {
type: 'primary',
size: 'small'
},
style: {
marginRight: '10px'
},
on: {
click: () => {
this.delateOne(params.row)
}
}
}, '删除')]
return h('div', arr)
}
}
],
server: '', server: '',
needModilyArr: [],
delateindex: null,
modifyModal: false,
origenIpsetList: [],
newIpsetData: [],
showIpSet: false,
showUrlIpSet: false,
showLimit: false,
showTestModal: false,
isShowList: true, isShowList: true,
alladdModal: false, alladdModal: false,
listonecolorauth: true, listonecolorauth: true,
...@@ -233,6 +665,7 @@ export default { ...@@ -233,6 +665,7 @@ export default {
changeserverModal: false, changeserverModal: false,
ContrasttestModal: false, ContrasttestModal: false,
ContrastnodeModal: false, ContrastnodeModal: false,
netModily: '',
aftertestmostatuorigen: false, aftertestmostatuorigen: false,
opentest: false, opentest: false,
closetest: false, closetest: false,
...@@ -270,7 +703,7 @@ export default { ...@@ -270,7 +703,7 @@ export default {
{ {
title: '配置', title: '配置',
key: 'sort', key: 'sort',
align: 'center' align: 'left'
}, },
{ {
title: '操作', title: '操作',
...@@ -323,7 +756,7 @@ export default { ...@@ -323,7 +756,7 @@ export default {
key: 'Status', key: 'Status',
align: 'center', align: 'center',
render: (h, params) => { render: (h, params) => {
return h('div', params.row.Status == 'passing' ? 'up' : 'down') return h('div', params.row.Status === 'passing' ? 'up' : 'down')
} }
}, },
{ {
...@@ -375,45 +808,11 @@ export default { ...@@ -375,45 +808,11 @@ export default {
} }
} }
], ],
rollbacklist: [] rollbacklist: [],
keyArr: [],
} }
}, },
methods: { methods: {
testmo (key) {
this.changekey = key
if (this.colorupdata === true) {
this.changedivModal = true
return
}
this.contrastlist = []
this.listonecolorauth = false
this.listonecolorfor = false
this.listonecolorint = false
this.listonecolorserv = false
this.listonecolordoma = false
this.listonecolortest = true
this.isShowList = false
this.colorupdatacolor = false
this.colorupdata = false
this.key = key
this.testdiv = true
this.getkeytext(key)
let data = {
key: key,
service_name: this.server
}
getconfigurelist(data).then(data => {
this.testmostatus = data.body
this.aftertestmostatuorigen = data.body
if (data.body === true) {
this.opentest = true
this.closetest = false
} else {
this.closetest = true
this.opentest = false
}
})
},
opentestradio (data) { opentestradio (data) {
this.closetest = !this.closetest this.closetest = !this.closetest
this.aftertestmostatus = true this.aftertestmostatus = true
...@@ -429,121 +828,135 @@ export default { ...@@ -429,121 +828,135 @@ export default {
this.colorupdatacolor = true this.colorupdatacolor = true
this.origenselectserver = this.server this.origenselectserver = this.server
}, },
serviceAdministrator (key) { authenticationlist (key,Tindex) {
this.changeIndex = Tindex;
this.changekey = key this.changekey = key
if (this.colorupdata === true) { if (this.colorupdata === true) {
this.changedivModal = true this.changedivModal = true
return return
} }
this.contrastlist = [] this.contrastlist = [];
this.listonecolorauth = false this.origenIpsetList = [];
this.listonecolorfor = false this.colorIndex = Tindex;
this.listonecolorint = false if (key === 'url_auth_list' || key === 'url_white_list' || key === 'url_black_list' || key === 'domain_prefix' || key === 'service_owner') {
this.listonecolorserv = true
this.listonecolordoma = false
this.listonecolortest = false
this.colorupdatacolor = false
this.colorupdata = false
this.isShowList = true
this.testdiv = false this.testdiv = false
this.key = key this.key = key
this.logData = [] this.logData = []
this.singlebaraddition = ''
this.getkeytext(key) this.getkeytext(key)
this.getconfigurlist(key, this.server) this.getconfigurlist(key, this.server)
},
domainnameprefixlist (key) {
this.changekey = key
if (this.colorupdata === true) {
this.changedivModal = true
return
}
this.contrastlist = []
this.listonecolorauth = false
this.listonecolorfor = false
this.listonecolorint = false
this.listonecolorserv = false
this.listonecolordoma = true
this.listonecolortest = false
this.colorupdatacolor = false
this.colorupdata = false
this.isShowList = true this.isShowList = true
this.testdiv = false this.showSpecified = false;
this.key = key this.showLimit = false;
this.logData = [] this.showIpSet =false;
this.getkeytext(key) this.showUrlIpSet = false;
this.getconfigurlist(key, this.server)
},
internallylist (key) {
this.changekey = key
if (this.colorupdata === true) {
this.changedivModal = true
return
} }
this.contrastlist = [] if (key === 'test_mode') {
this.listonecolorauth = false
this.listonecolorfor = false
this.listonecolorint = true
this.listonecolorserv = false
this.listonecolordoma = false
this.listonecolortest = false
this.colorupdatacolor = false
this.colorupdata = false
this.isShowList = true
this.testdiv = false
this.key = key this.key = key
this.logData = [] let data = {
this.getkeytext(key) key: key,
this.getconfigurlist(key, this.server) service_name: this.server
}, }
foreignlist (key) { getconfigurelist(data).then(data => {
this.changekey = key this.testmostatus = data.body
if (this.colorupdata === true) { this.aftertestmostatuorigen = data.body
this.changedivModal = true if (data.body === true) {
return this.opentest = true
this.closetest = false
} else {
this.closetest = true
this.opentest = false
}
})
this.showTestModal = true
this.isShowList = false
this.showSpecified = false;
this.showIpSet =false;
this.showUrlIpSet = false;
this.testdiv = true
this.showLimit = false;
this.getkeytext(key);
} }
this.contrastlist = [] if (key === 'ip_set_v2') {
this.listonecolorauth = false
this.listonecolorfor = true
this.listonecolorint = false
this.listonecolorserv = false
this.listonecolordoma = false
this.listonecolortest = false
this.colorupdatacolor = false
this.colorupdata = false
this.isShowList = true
this.testdiv = false
this.key = key this.key = key
this.logData = [] this.isShowList = false;
this.getkeytext(key) this.showIpSet = true;
this.getconfigurlist(key, this.server) this.showTestModal = false;
}, this.showUrlIpSet = false;
authenticationlist (key) { this.showLimit = false;
this.changekey = key this.showSpecified = false;
if (this.colorupdata === true) { this.getkeytext(key);
this.changedivModal = true this.getList(key, this.server);
return
} }
this.contrastlist = [] if (key === 'url_ip_set_v2') {
this.listonecolorauth = true this.isShowList = false;
this.listonecolorfor = false this.showIpSet = false;
this.listonecolorint = false this.showUrlIpSet = true;
this.listonecolorserv = false this.showTestModal = false;
this.listonecolordoma = false this.showLimit = false;
this.listonecolortest = false this.showLimit = false;
this.colorupdatacolor = false this.showSpecified = false;
this.colorupdata = false
this.isShowList = true
this.testdiv = false
this.key = key this.key = key
this.logData = [] this.getkeytext(key);
this.getkeytext(key) this.getList(key, this.server);
this.getconfigurlist(key, this.server) }
if (key === 'limit') {
this.isShowList = false;
this.showIpSet = false;
this.showUrlIpSet = false;
this.showTestModal = false;
this.showLimit = true;
this.showSpecified = false;
this.showElse = false;
this.getkeytext(key);
this.key = key
this.getList(key, this.server);
}
if (key === 'specified_values') {
this.isShowList = false;
this.showIpSet = false;
this.showUrlIpSet = false;
this.showTestModal = false;
this.showLimit = false;
this.showElse = false;
this.showSpecified = true;
this.key = key
this.getkeytext(key);
this.getList(key, this.server);
}
let arr = ['specified_values', 'limit', 'url_ip_set_v2',
'ip_set_v2', 'test_mode','url_auth_list','url_white_list','url_black_list', 'domain_prefix','service_owner'];
let keys = arr.some(function(item){
return item === key;
})
if (!keys) {
this.showElse = true
this.isShowList = false;
this.showIpSet = false;
this.showUrlIpSet = false;
this.showTestModal = false;
this.showLimit = false;
this.showSpecified = false;
this.key = key
this.getkeytext(key);
this.getList(key, this.server);
}
}, },
oneadd () { oneadd () {
if (this.singlebaraddition == '') { if (this.singlebaraddition === '') {
this.$Message.error('请先输入要添加的内容') this.$Message.error('请先输入要添加的内容')
return return
} }
let keys = this.logData.some(item => {
return item.sort === this.singlebaraddition
})
if (keys) {
this.$Notice.error({
title: '提示',
desc: '不能添加重复的内容',
});
return
}
this.logData.push({sort: this.singlebaraddition}) this.logData.push({sort: this.singlebaraddition})
this.logparamsarr.push(this.singlebaraddition) this.logparamsarr.push(this.singlebaraddition)
this.singlebaraddition = '' this.singlebaraddition = ''
...@@ -552,18 +965,36 @@ export default { ...@@ -552,18 +965,36 @@ export default {
this.origenselectserver = this.server this.origenselectserver = this.server
}, },
alladd () { alladd () {
this.formInline.alladdcontent = ''
this.alladdModal = true this.alladdModal = true
}, },
alladdconfire () { alladdconfire () {
if (this.formInline.alladdcontent == '') { if (this.formInline.alladdcontent === '') {
this.$Message.error('请先输入要添加的内容') this.$Message.error('请先输入要添加的内容')
return return
} }
let str = this.formInline.alladdcontent.replace(/\[|]/g, '') let str = this.formInline.alladdcontent.replace(/\[|]/g, '')
str = str.replace(/\n/g, '') str = str.replace(/\n/g, '')
str = str.replace(/\"/g, '') str = str.replace(/\"/g, '') // eslint-disable-line no-useless-escape
str = str.replace(/\'/g, '') str = str.replace(/\'/g, '') // eslint-disable-line no-useless-escape
let arr = str.split(',') let arr = str.split(',')
arr.map(item => {
let keys = this.logData.some(data => {
return item === data.sort
})
this.keyArr.push(keys)
})
let keys = this.keyArr.some(item => {
return item === true
})
if (keys) {
this.$Notice.error({
title: '提示',
desc: '不能添加重复的内容',
});
this.keyArr = []
return
}
this.logparamsarr = arr this.logparamsarr = arr
arr.map(item => { arr.map(item => {
this.logData.push({sort: item}) this.logData.push({sort: item})
...@@ -578,13 +1009,32 @@ export default { ...@@ -578,13 +1009,32 @@ export default {
this.formInline.alladdcontent = '' this.formInline.alladdcontent = ''
}, },
clear () { clear () {
this.clearModal = true
},
confireClear () {
if (this.key === 'url_auth_list' || this.key === 'url_white_list' || this.key === 'url_black_list' || this.key === 'domain_prefix' || this.key === 'service_owner') {
this.logData = [] this.logData = []
// this.contrastlist = []
this.singlebaraddition = '' this.singlebaraddition = ''
this.logparamsarr = [] this.logparamsarr = []
} else {
if (this.key === 'ip_set_v2') {
this.ipsetData = []
}
if (this.key === 'url_ip_set_v2') {
this.urlIpSetData = []
}
if (this.key === 'limit') {
this.limitData = []
}
if (this.key === 'specified_values') {
this.specifiedData = []
}
}
this.newIpsetData = []
this.colorupdatacolor = true this.colorupdatacolor = true
this.colorupdata = true this.colorupdata = true
this.origenselectserver = this.server this.origenselectserver = this.server
this.clearModal = false
}, },
rollback () { rollback () {
let data = { let data = {
...@@ -600,8 +1050,8 @@ export default { ...@@ -600,8 +1050,8 @@ export default {
item.listonecolorback = false item.listonecolorback = false
} }
}) })
this.content = data.body.length == 0 ? '' : data.body[0].value this.content = data.body.length === 0 ? '' : data.body[0].value
this.version = data.body.length == 0 ? '' : data.body[0].key this.version = data.body.length === 0 ? '' : data.body[0].key
if (this.rollbacklist.length === 0) { if (this.rollbacklist.length === 0) {
this.$Message.error('暂无要回滚的内容') this.$Message.error('暂无要回滚的内容')
return false return false
...@@ -616,7 +1066,7 @@ export default { ...@@ -616,7 +1066,7 @@ export default {
this.clickIndex1 = index this.clickIndex1 = index
}, },
confirerollback () { confirerollback () {
if (this.version == '') { if (this.version === '') {
this.$Message.error('没有要回滚的内容') this.$Message.error('没有要回滚的内容')
return return
} }
...@@ -630,6 +1080,7 @@ export default { ...@@ -630,6 +1080,7 @@ export default {
this.rollbackModal = false this.rollbackModal = false
this.$Message.success('回滚成功') this.$Message.success('回滚成功')
this.getconfigurlist(this.key, this.server) this.getconfigurlist(this.key, this.server)
this.getList(this.key, this.server)
this.getnodeList() this.getnodeList()
} }
}) })
...@@ -640,10 +1091,10 @@ export default { ...@@ -640,10 +1091,10 @@ export default {
}, },
confiredelate () { confiredelate () {
this.logData = this.logData.filter(item => { this.logData = this.logData.filter(item => {
return item.sort != this.delateconfigurecontent return item.sort !== this.delateconfigurecontent
}) })
this.contrastlist.filter(item => { this.contrastlist.filter(item => {
return item != this.delateconfigurecontent return item !== this.delateconfigurecontent
}) })
this.delateModal = false this.delateModal = false
this.colorupdata = true this.colorupdata = true
...@@ -697,6 +1148,7 @@ export default { ...@@ -697,6 +1148,7 @@ export default {
}) })
}, },
getkeytext (key) { getkeytext (key) {
this.textExplain = '';
getkey(key).then((data) => { getkey(key).then((data) => {
this.textExplain = data.body.replace(/\n/g, '<br/>') this.textExplain = data.body.replace(/\n/g, '<br/>')
}) })
...@@ -717,14 +1169,79 @@ export default { ...@@ -717,14 +1169,79 @@ export default {
}) })
}) })
}, },
getList (key, service) {
this.limitData = [];
this.ipsetData = [];
this.urlIpSetData = [];
this.specifiedData = [];
this.origenContent = '';
this.contrastlist = []
let data = {
key: key,
service_name: service
}
getconfigurelist(data).then(data => {
let arr =['limit', 'ip_set_v2','url_ip_set_v2', 'specified_values']
let keys = arr.some(function(item){
return item === key;
})
if (key === 'limit') {
this.needModilyArr = [];
this.limitData = [];
this.limitData = (data && data.body) || []
this.limitData = [...this.limitData]
this.needModilyArr = JSON.stringify((data && data.body)) || [];
}
if (key === 'ip_set_v2') {
this.needModilyArr = [];
this.ipsetData = [];
this.ipsetData = (data && data.body) || [];
this.ipsetData = [...this.ipsetData]
this.needModilyArr = JSON.stringify((data && data.body)) || [];
}
if (key === 'url_ip_set_v2') {
this.needModilyArr = [];
this.urlIpSetData = [];
this.urlIpSetData = (data && data.body) || []
this.urlIpSetData = [...this.urlIpSetData]
this.needModilyArr = JSON.stringify((data && data.body)) || [];
}
if (key === 'specified_values') {
this.needModilyArr = [];
this.specifiedData = [];
this.specifiedData = (data && data.body) || []
this.specifiedData = [...this.specifiedData]
this.needModilyArr = JSON.stringify((data && data.body)) || [];
}
if (!keys) {
this.origenContent = JSON.stringify(data && data.body) || '';
this.netModily = JSON.stringify(data && data.body) || '';
}
})
},
configlist () { configlist () {
this.logDataorigen = [] this.logDataorigen = []
this.logData.map(item => { this.logData.map(item => {
this.logDataorigen.push(item.sort) this.logDataorigen.push(item.sort)
}) })
if (this.testdiv === true) { let _this = this
let arr = ['specified_values', 'limit', 'url_ip_set_v2',
'ip_set_v2', 'test_mode','url_auth_list','url_white_list','url_black_list', 'domain_prefix','service_owner'];
let keys = arr.some(function(item){
return item === _this.key;
})
if (!keys) {
this.elseConfireModal = true;
return
}
if (this.key === 'ip_set_v2' || this.key === 'url_ip_set_v2' || this.key === 'specified_values' || this.key === 'limit') {
this.contrastIpset = true
return
}
if (this.testdiv) {
this.ContrasttestModal = true this.ContrasttestModal = true
} else { }
if (!this.testdiv) {
this.ContrastModal = true this.ContrastModal = true
} }
}, },
...@@ -735,9 +1252,57 @@ export default { ...@@ -735,9 +1252,57 @@ export default {
} }
if (this.key === 'test_mode') { if (this.key === 'test_mode') {
this.paramscontent = this.aftertestmostatus === true ? 'true' : 'false' this.paramscontent = this.aftertestmostatus === true ? 'true' : 'false'
} else { }
if (this.key === 'url_auth_list' || this.key === 'url_white_list' || this.key === 'url_black_list' || this.key === 'domain_prefix' || this.key === 'service_owner') {
this.paramscontent = this.logDataorigen this.paramscontent = this.logDataorigen
} }
if (this.key === 'ip_set_v2') {
this.ipsetData.map(item => {
if (typeof(item.ip_list) === 'object') {
item.ip_list = item.ip_list
} else {
item.ip_list = JSON.parse(item.ip_list)
}
})
this.paramscontent = this.ipsetData
}
if (this.key === 'url_ip_set_v2') {
this.paramscontent = this.urlIpSetData
}
if (this.key === 'specified_values') {
if (!this.specifiedData.length) {
this.paramscontent = this.specifiedData
} else {
this.specifiedData.forEach(item => {
if (typeof(item.header) === 'object') {
item.header = item.header
} else {
item.header = JSON.parse(item.header)
}
})
this.paramscontent = this.specifiedData
}
}
if (this.key === 'limit') {
if (!this.limitData.length) {
this.paramscontent = this.limitData
} else {
this.limitData && this.limitData.forEach(item => {
item.rate = Number(item.rate)
item.duration = Number(item.duration)
})
this.paramscontent = this.limitData
}
}
let arr = ['specified_values', 'limit', 'url_ip_set_v2',
'ip_set_v2', 'test_mode','url_auth_list','url_white_list','url_black_list', 'domain_prefix','service_owner'];
let _this = this;
let keys = arr.some(function(item){
return item === _this.key;
})
if (!keys) {
this.paramscontent = this.origenContent
}
postconfigurelist(data, this.paramscontent).then(data => { postconfigurelist(data, this.paramscontent).then(data => {
if (data.code === 200) { if (data.code === 200) {
this.$Message.success('发布成功') this.$Message.success('发布成功')
...@@ -745,8 +1310,15 @@ export default { ...@@ -745,8 +1310,15 @@ export default {
this.colorupdatacolor = false this.colorupdatacolor = false
this.ContrastModal = false this.ContrastModal = false
this.ContrasttestModal = false this.ContrasttestModal = false
this.contrastIpset = false
this.getconfigurlist(this.key, this.server) this.getconfigurlist(this.key, this.server)
this.getList(this.key, this.server)
this.contrastlist = this.logDataorigen this.contrastlist = this.logDataorigen
this.updataIpsetSta = false
this.updataUrlSta = false
this.updataLimitSta = false
this.elseConfireModal = false
this.updataSpecifiedSta = false
} else { } else {
this.$Message.error(data.body) this.$Message.error(data.body)
this.ContrastModal = false this.ContrastModal = false
...@@ -802,6 +1374,7 @@ export default { ...@@ -802,6 +1374,7 @@ export default {
this.getnodeList() this.getnodeList()
this.getkeytext(this.key) this.getkeytext(this.key)
this.getconfigurlist(this.key, this.server) this.getconfigurlist(this.key, this.server)
this.getList(this.key, this.server)
}, },
coloechangeserver () { coloechangeserver () {
this.server = this.origenselectserver this.server = this.origenselectserver
...@@ -840,9 +1413,9 @@ export default { ...@@ -840,9 +1413,9 @@ export default {
return arr.push(item.Meta.weight) return arr.push(item.Meta.weight)
}) })
let sta = arr.some(function (item, index, array) { let sta = arr.some(function (item, index, array) {
return item != 0 return item !== 0
}) })
if (sta == false) { if (sta === false) {
this.$Message.error('权重不能全部修改为0') this.$Message.error('权重不能全部修改为0')
this.ContrastnodeModal = false this.ContrastnodeModal = false
this.getnodeList() this.getnodeList()
...@@ -875,91 +1448,15 @@ export default { ...@@ -875,91 +1448,15 @@ export default {
}) })
}, },
confiechangediv () { confiechangediv () {
if (this.changekey === 'url_white_list') { this.colorIndex = this.changeIndex
this.listonecolorauth = false if (this.changekey === 'url_white_list' || this.changekey === 'url_auth_list' || this.changekey === 'url_black_list'
this.listonecolorfor = true || this.changekey === 'domain_prefix' || this.changekey === 'service_owner' || this.changekey === 'test_mode') {
this.listonecolorint = false
this.listonecolorserv = false
this.listonecolordoma = false
this.listonecolortest = false
this.isShowList = true
this.logData = []
this.contrastlist = []
this.testdiv = false
this.colorupdatacolor = false
this.getkeytext(this.changekey)
this.getconfigurlist(this.changekey, this.server)
}
if (this.changekey === 'url_auth_list') {
this.listonecolorauth = true
this.listonecolorfor = false
this.listonecolorint = false
this.listonecolorserv = false
this.listonecolordoma = false
this.listonecolortest = false
this.colorupdatacolor = false
this.isShowList = true
this.testdiv = false
this.logData = []
this.contrastlist = []
this.getkeytext(this.changekeyy)
this.getconfigurlist(this.changekey, this.server)
}
if (this.changekey === 'url_black_list') {
this.listonecolorauth = false
this.listonecolorfor = false
this.listonecolorint = true
this.listonecolorserv = false
this.listonecolordoma = false
this.listonecolortest = false
this.colorupdatacolor = false
this.isShowList = true
this.testdiv = false
this.logData = []
this.contrastlist = []
this.getkeytext(this.changekey)
this.getconfigurlist(this.changekey, this.server)
}
if (this.changekey === 'domain_prefix') {
this.listonecolorauth = false
this.listonecolorfor = false
this.listonecolorint = false
this.listonecolorserv = false
this.listonecolordoma = true
this.listonecolortest = false
this.colorupdatacolor = false
this.isShowList = true
this.testdiv = false
this.logData = []
this.contrastlist = []
this.getkeytext(this.changekey)
this.getconfigurlist(this.changekey, this.server)
}
if (this.changekey === 'service_owner') {
this.listonecolorauth = false
this.listonecolorfor = false
this.listonecolorint = false
this.listonecolorserv = true
this.listonecolordoma = false
this.listonecolortest = false
this.colorupdatacolor = false
this.isShowList = true
this.testdiv = false
this.logData = []
this.contrastlist = []
this.getkeytext(this.changekey)
this.getconfigurlist(this.changekey, this.server)
}
if (this.changekey === 'test_mode') { if (this.changekey === 'test_mode') {
this.listonecolorauth = false
this.listonecolorfor = false this.listonecolorfor = false
this.listonecolorint = false
this.listonecolorserv = false
this.listonecolordoma = false
this.listonecolortest = true this.listonecolortest = true
this.colorupdatacolor = false
this.isShowList = false this.isShowList = false
this.testdiv = true this.testdiv = true
this.showTestModal = true
this.logData = [] this.logData = []
this.contrastlist = [] this.contrastlist = []
this.getkeytext(this.changekey) this.getkeytext(this.changekey)
...@@ -978,10 +1475,63 @@ export default { ...@@ -978,10 +1475,63 @@ export default {
this.opentest = false this.opentest = false
} }
}) })
} else {
this.listonecolorfor = true
this.isShowList = true
this.logData = []
this.contrastlist = []
this.testdiv = false
this.colorupdatacolor = false
this.getkeytext(this.changekey)
this.getconfigurlist(this.changekey, this.server)
}
this.colorupdata = false
this.colorupdatacolor = false
this.changedivModal = false
} else {
if (this.changekey === 'ip_set_v2' || this.changekey === 'url_ip_set_v2' || this.changekey === 'limit' || this.changekey === 'specified_values') {
if (this.changekey === 'ip_set_v2') {
this.showIpSet = true
this.showUrlIpSet = false
this.showLimit = false
this.showSpecified = false
this.showElse = false
}
if (this.changekey === 'url_ip_set_v2') {
this.showUrlIpSet = true
this.showIpSet = false
this.showLimit = false
this.showSpecified = false
this.showElse = false
}
if (this.changekey === 'limit') {
this.showLimit = true
this.showIpSet = false
this.showUrlIpSet = false
this.showSpecified = false
this.showElse = false
}
if (this.changekey === 'specified_values') {
this.showIpSet = false
this.showUrlIpSet = false
this.showLimit = false
this.showElse = false
this.showTestModal = false
}
this.getList(this.changekey, this.server)
this.getkeytext(this.changekey)
} else {
this.origenContent = ''
this.showElse = true
this.getList(this.changekey,this.server)
this.getkeytext(this.changekey)
} }
this.isShowList = false
this.showTestModal = false
this.colorupdata = false this.colorupdata = false
this.colorupdatacolor = false this.colorupdatacolor = false
this.changedivModal = false this.changedivModal = false
}
}, },
confireupdatenode () { confireupdatenode () {
if (this.updateweight < 0) { if (this.updateweight < 0) {
...@@ -998,15 +1548,329 @@ export default { ...@@ -998,15 +1548,329 @@ export default {
this.colorupdatacolor = true this.colorupdatacolor = true
this.colorupdatacolor = true this.colorupdatacolor = true
this.origenselectserver = this.server this.origenselectserver = this.server
},
MenuList() {
getMenuList().then(res => {
this.menu = res && res.body || []
})
},
addIpset() {
this.ipsetName = '';
this.ipsetContent = '';
this.addIpsetModal = true;
this.updataIpsetSta = false;
},
updateIpset(data) {
this.updataIpsetSta = true;
this.updateconfigindex = data._index;
this.ipsetName = data.name;
this.ipsetContent = JSON.stringify(data.ip_list);
this.addIpsetModal = true;
},
updateUrlIpset(data) {
this.updataUrlSta = true;
let list = {
key: 'ip_set_v2',
service_name: this.server
};
getconfigurelist(list).then(data => {
let arr = (data && data.body) || [];
arr = arr.filter((x, index,self)=>self.indexOf(x)===index)
arr.map(item => {
this.ipsetList.push(item.name)
})
this.ipsetList = this.ipsetList.filter((x, index,self) => self.indexOf(x) === index)
});
this.updateconfigindex = data._index;
this.urlIpsetName = data.ip_set_name;
this.urlIpsetPath = data.path;
this.addUrlIpsetModal = true;
},
updateLimit(data) {
this.updataLimitSta = true;
this.updateconfigindex = data._index;
this.limitTime = data.duration;
this.limitRate = data.rate;
this.limitPath = data.path;
this.addLimitModal = true
},
updateSpecified(data) {
this.updataSpecifiedSta = true;
this.updateconfigindex = data._index;
this.body = data.body;
this.header = JSON.stringify(data.header);
this.err_type = data.err_type;
this.err_tag = data.err_tag;
this.addSpecifiedModal = true
},
addUrlIpset() {
this.urlIpsetName = '';
this.urlIpsetPath = '';
this.addUrlIpsetModal = true;
let data = {
key: 'ip_set_v2',
service_name: this.server
}
getconfigurelist(data).then(data => {
let arr = (data && data.body) || [];
arr = arr.filter((x, index,self)=>self.indexOf(x)===index)
arr.map(item => {
this.ipsetList.push(item.name)
})
this.ipsetList = this.ipsetList.filter((x, index,self) => self.indexOf(x) === index)
})
},
addLimit() {
this.limitPath = '';
this.limitTime = '';
this.limitRate = '';
this.addLimitModal = true;
},
addSpecified () {
this.header = '';
this.body = '';
this.err_tag = '';
this.err_type = '';
this.addSpecifiedModal = true;
},
confireIpset() {
if (!this.ipsetName || !this.ipsetContent) {
this.$Notice.error({
title: '提示',
desc: '请输入完整信息',
});
return
}
let re = /["\[\]]/g // eslint-disable-line no-useless-escape
if (!re.test(this.ipsetContent)) {
this.$Notice.error({
title: '提示',
desc: ' 输入格式不正确',
});
return
}
let str = this.ipsetContent.replace(re, '');
let arr = str.split(',')
// 判断是否是IP字段
let test = arr && arr.every(item => {
let reg = /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/
return !reg.test(item)
})
if (test) {
this.$Notice.error({
title: '提示',
desc: ' 输入格式不正确',
});
return
}
if (this.updataIpsetSta) {
this.ipsetData[this.updateconfigindex].ip_list = this.ipsetContent
} else {
let keys = this.ipsetData.some(item => {
return item.name === this.ipsetName
})
if (keys) {
this.$Notice.error({
title: '提示',
desc: '不能添加重复的内容',
});
return
}
this.ipsetData.push(
{
name: this.ipsetName,
ip_list: this.ipsetContent,
}
);
}
this.addIpsetModal = false;
this.colorupdata = true;
this.colorupdatacolor = true
this.newIpsetData = [];
this.newIpsetData = this.ipsetData;
this.origenselectserver = this.server
},
confireUrlSet() {
if (!this.urlIpsetPath || !this.urlIpsetName) {
this.$Notice.error({
title: '提示',
desc: '请输入完整信息',
});
return
}
let keys = this.urlIpSetData.some(item => {
return item.ip_set_name === this.urlIpsetName
})
if (keys) {
this.$Notice.error({
title: '提示',
desc: '不能添加重复的内容',
});
return
}
if (this.updataUrlSta) {
this.urlIpSetData[this.updateconfigindex].path = this.urlIpsetPath
this.urlIpSetData[this.updateconfigindex].ip_set_name = this.urlIpsetName
} else {
this.urlIpSetData.push(
{
ip_set_name: this.urlIpsetName,
path:this.urlIpsetPath,
}
);
}
this.addUrlIpsetModal = false;
this.colorupdata = true;
this.colorupdatacolor = true
this.newIpsetData = [];
this.newIpsetData = this.urlIpSetData;
this.origenselectserver = this.server
},
confireLimit() {
if (!this.limitPath || !this.limitRate || !this.limitTime) {
this.$Notice.error({
title: '提示',
desc: '请输入完整信息',
});
return
}
if (this.limitTime <= 0) {
this.$Notice.error({
title: '提示',
desc: '时间不能为0',
});
return
}
let keys = this.urlIpSetData.some(item => {
return item.path === this.limitPath
})
if (keys) {
this.$Notice.error({
title: '提示',
desc: '不能添加重复的内容',
});
return
}
if (this.updataLimitSta) {
this.limitData[this.updateconfigindex].path = this.limitPath
this.limitData[this.updateconfigindex].duration = this.limitTime
this.limitData[this.updateconfigindex].rate = this.limitRate
} else {
this.limitData.push(
{
path: this.limitPath,
rate: this.limitRate,
duration: this.limitTime,
}
);
}
this.addLimitModal = false;
this.colorupdata = true;
this.newIpsetData = [];
this.newIpsetData = this.limitData;
this.colorupdatacolor = true
this.origenselectserver = this.server
},
confireSpecified() {
if (!this.header || !this.body || !this.err_type || !this.err_tag) {
this.$Notice.error({
title: '提示',
desc: '请输入完整信息',
});
return
}
let keys = this.specifiedData.some(item => {
return item.err_type === this.err_type && item.err_tag === this.err_tag
})
if (keys) {
this.$Notice.error({
title: '提示',
desc: '不能添加重复的内容',
});
return
}
if (this.updataSpecifiedSta) {
this.specifiedData[this.updateconfigindex].body = this.body
this.specifiedData[this.updateconfigindex].header = this.header
this.specifiedData[this.updateconfigindex].err_type = this.err_type
this.specifiedData[this.updateconfigindex].err_tag = this.err_tag
} else {
this.specifiedData.push(
{
body: this.body,
header: this.header,
err_type: this.err_type,
err_tag: this.err_tag,
}
);
}
this.addSpecifiedModal = false;
this.colorupdata = true;
this.newIpsetData = [];
this.newIpsetData = this.specifiedData;
this.colorupdatacolor = true
this.origenselectserver = this.server
},
delateOne(data) {
this.delateindex = data._index;
this.delateIpModal = true
},
confierDelateOne() {
if (this.key === 'ip_set_v2') {
this.ipsetData.splice(this.delateindex, 1);
}
if (this.key === 'url_ip_set_v2') {
this.urlIpSetData.splice(this.delateindex, 1)
}
if (this.key === 'limit') {
this.limitData.splice(this.delateindex, 1)
}
if (this.key === 'specified_values') {
this.specifiedData.splice(this.delateindex, 1)
}
this.delateIpModal = false
this.colorupdata = true;
this.colorupdatacolor = true
this.origenselectserver = this.server
},
getType() {
getTypeList().then(data => {
this.tageList = (data && data.body) || []
})
},
changeType (data) {
if (data === 'proxy') {
this.tageList = ['timeout','other']
} else {
this.getType()
} }
}, },
modify() {
this.updataOrigenContent = this.origenContent;
this.modifyModal = true;
},
conforeModify() {
this.origenContent = this.updataOrigenContent;
this.colorupdatacolor = true
this.colorupdata = true
this.origenselectserver = this.server
this.modifyModal = false;
},
reduction() {
this.origenContent = this.netModily;
this.colorupdatacolor = false
this.colorupdata = false
},
},
created () { created () {
}, },
async mounted () { async mounted () {
await this.getserlist() await this.getserlist()
this.MenuList()
this.getkeytext('url_auth_list') this.getkeytext('url_auth_list')
this.getconfigurlist('url_auth_list', this.server) this.getconfigurlist('url_auth_list', this.server)
this.getnodeList() this.getnodeList()
this.getType()
}, },
destroyed () { destroyed () {
} }
...@@ -1068,11 +1932,11 @@ export default { ...@@ -1068,11 +1932,11 @@ export default {
} }
.list_content{ .list_content{
background: #f2f2f2; background: #f2f2f2;
height: 30px; line-height: 20px;
line-height: 30px; margin:10px 0;
margin-top:10px;
width: 80%; width: 80%;
margin-left: 10%; margin-left: 10%;
padding: 10px;
border-radius: 5px; border-radius: 5px;
cursor: pointer cursor: pointer
} }
...@@ -1103,7 +1967,8 @@ export default { ...@@ -1103,7 +1967,8 @@ export default {
height: 72%; height: 72%;
width: 99%; width: 99%;
margin-left: 1%; margin-left: 1%;
margin-top: 1% margin-top: 1%;
overflow-y: auto;
} }
.right_content_btn{ .right_content_btn{
margin: 10% 0% 20% 0% margin: 10% 0% 20% 0%
......
import axios from 'axios' import axios from "axios";
import { Notice } from 'iview' import { Notice } from "iview";
import localStorage from './localStorage.service' import localStorage from "./localStorage.service";
// window.Promise = require('es6-promise').Promise // window.Promise = require('es6-promise').Promise
const config = { const config = {
timeout: 600000 timeout: 600000
// withCredentials: true // 允许携带cookie // withCredentials: true // 允许携带cookie
} };
const instance = axios.create(Object.assign({}, config)) const instance = axios.create(Object.assign({}, config));
instance._extend = {} instance._extend = {};
function requestInterceptor (config) { function requestInterceptor(config) {
config.headers['x-requested-with'] = 'XMLHttpRequest' config.headers["x-requested-with"] = "XMLHttpRequest";
// if (!config.headers['Content-Type']) { // if (!config.headers['Content-Type']) {
// config.headers['Content-Type'] = 'application/x-www-form-urlencoded' // config.headers['Content-Type'] = 'application/x-www-form-urlencoded'
// } // }
if (!config.headers['heimdallr-token']) { if (!config.headers["heimdallr-token"]) {
config.headers['heimdallr-token'] = localStorage.get('heimdallr-token') || '' config.headers["heimdallr-token"] =
localStorage.get("heimdallr-token") || "";
} }
return config return config;
} }
function responseInterceptor (response) { function responseInterceptor(response) {
if (response.status < 200 || response.status > 300) { if (response.status < 200 || response.status > 300) {
Notice.error({ Notice.error({
title: '请求发生错误', title: "请求发生错误",
desc: response && response.data && (response.data.errorMsg || '请联系系统管理员') desc:
}) response &&
return Promise.reject(response && response.data) response.data &&
(response.data.errorMsg || "请联系系统管理员")
});
return Promise.reject(response && response.data);
} }
// code是0000表示成功 // code是0000表示成功
if (response.data.code === 200 || response.data.code === 400) { if (response.data.code === 200 || response.data.code === 400) {
return Promise.resolve(response.data || null) return Promise.resolve(response.data || null);
} }
if (response.data.code === 401) { if (response.data.code === 401) {
window.location.href = window.location.origin + '/login' window.location.href = window.location.origin + "/login";
} }
// Notice.error({ // Notice.error({
// title: '', // title: '',
// desc: response.data.errorMsg || response.data.message || '请联系客服' // desc: response.data.errorMsg || response.data.message || '请联系客服'
// }) // })
return Promise.reject(response && response.data) return Promise.reject(response && response.data);
} }
/** /**
...@@ -52,23 +56,23 @@ function responseInterceptor (response) { ...@@ -52,23 +56,23 @@ function responseInterceptor (response) {
* axios.interceptors.request.eject(0) * axios.interceptors.request.eject(0)
* axios.interceptors.response.eject(0) * axios.interceptors.response.eject(0)
*/ */
instance.interceptors.request.use(requestInterceptor, (error) => { instance.interceptors.request.use(requestInterceptor, error => {
// return Promise.reject(error) return Promise.reject(error);
}) });
instance.interceptors.response.use(responseInterceptor, error => { instance.interceptors.response.use(responseInterceptor, error => {
// const code = response.data // const code = response.data
if (error.response && error.response.status === 401) { if (error.response && error.response.status === 401) {
window.location.href = window.location.origin + '/login' window.location.href = window.location.origin + "/login";
} }
if (error.message.indexOf('timeout') !== -1) { if (error.message.indexOf("timeout") !== -1) {
Notice.error({ Notice.error({
title: '', title: "",
desc: '请求超时' desc: "请求超时"
}) });
} }
// return Promise.reject(error) // return Promise.reject(error)
}) });
export default instance export default instance;
import localStorage from '../services/localStorage.service' import localStorage from "../services/localStorage.service";
export default{ export default {
init (router) { init(router) {
router.beforeEach((to, form, next) => { router.beforeEach((to, form, next) => {
const token = localStorage.get('heimdallr-token') const token = localStorage.get("heimdallr-token");
if (to.meta && !to.meta.allowBack && window.history && window.history.pushState) { // 登录页面不能后退 if (
history.pushState(null, null, document.URL) to.meta &&
!to.meta.allowBack &&
window.history &&
window.history.pushState
) {
// 登录页面不能后退
history.pushState(null, null, document.URL);
} }
if (to.name === 'login') { if (to.name === "login") {
next() next();
return return;
} }
if (!token) { if (!token) {
window.location.href = `${window.location.origin}/login` window.location.href = `${window.location.origin}/login`;
return return;
} }
next() next();
}) });
} }
} };
export default{ export default {
get (key) { get(key) {
let result = localStorage.getItem(key) let result = localStorage.getItem(key);
try { try {
result = JSON.parse(result) result = JSON.parse(result);
} catch (e) {} } catch (e) {}
return result return result;
}, },
set (key, value) { set(key, value) {
let toString = Object.prototype.toString let toString = Object.prototype.toString;
if (toString.call(value) === '[object Array]' || toString.call(value) === '[object Object]') { if (
value = JSON.stringify(value) toString.call(value) === "[object Array]" ||
toString.call(value) === "[object Object]"
) {
value = JSON.stringify(value);
} }
return localStorage.setItem(key, value) return localStorage.setItem(key, value);
}, },
remove (key) { remove(key) {
return localStorage.removeItem(key) return localStorage.removeItem(key);
}, },
clear () { clear() {
return localStorage.clear() return localStorage.clear();
} }
} };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment