Commit 66bec88a by zhengjie

去除实时控制台页面,去除redis的新增与编辑功能

parent 0a5db88f
......@@ -34,8 +34,6 @@
"jszip": "3.1.5",
"@riophae/vue-treeselect": "0.0.38",
"file-saver": "1.3.8",
"sockjs-client": "1.3.0",
"stompjs": "2.3.3",
"wangeditor": ">=3.0.0",
"codemirror": "^5.38.0",
"mavon-editor": "^2.7.0",
......
<template>
<div class="container">
<el-tooltip :content="content" class="lock item" effect="dark" placement="left">
<el-button type="info" size="mini" circle @click="doLock"><svg-icon :icon-class="ico"/></el-button>
</el-tooltip>
<div id="console" :style="'height:'+ height" class="console">
<div v-for="item in data" :key="item.time">
<span>{{ item.name }}</span>
<span style="color:#CD0066 ">{{ parseTime(item.timestamp)+' ' }}</span>
<span style="color: #00CD00">{{ item.threadName+' ' }}</span>
<span :style="'color:'+ getColor(item.level) ">
{{ item.level+' ' }}
</span>
<span style="color: #DE00CC">{{ item.className+' ' }}</span>
<span v-html="item.body"/>
</div>
</div>
</div>
</template>
<script>
import { mapGetters } from 'vuex'
import SockJS from 'sockjs-client'
import Stomp from 'stompjs'
import { parseTime } from '@/utils/index'
export default {
name: 'Msg',
data() {
return {
ico: 'unlock', unlock: true, content: '锁定滚动条',
height: '0px',
data: [{ name: 'elAdmin-', timestamp: new Date(), threadName: 'system-prompt-message', level: 'INFO', className: 'me.zhengjie.AppRun' + ' :', body: 'Welcome, no log output' }],
// level
INFO: '#0000ff', WARN: '#FFFF00', ERROR: '#FF0000', DEBUG: '#DEA000'
}
},
computed: {
...mapGetters([
'socketApi'
]),
tagsView() {
return this.$store.state.settings.tagsView
}
},
// 监听控制滚动条
watch: {
data: {
handler(val, oldVal) {
this.$nextTick(() => {
if (this.unlock) {
var div = document.getElementById('console')
div.scrollTop = div.scrollHeight
}
})
}
},
tagsView(newVal, oldVal) {
this.height = this.tagsView ? document.documentElement.clientHeight - 95 + 'px;' : document.documentElement.clientHeight - 65 + 'px;'
}
},
created() {
this.height = this.tagsView ? document.documentElement.clientHeight - 95 + 'px;' : document.documentElement.clientHeight - 65 + 'px;'
},
mounted: function() {
this.initWebSocket()
const that = this
window.onresize = function temp() {
that.height = that.tagsView ? document.documentElement.clientHeight - 95 + 'px;' : document.documentElement.clientHeight - 65 + 'px;'
}
},
beforeDestroy: function() {
// 页面离开时断开连接,清除定时器
this.disconnect()
window.clearInterval(this.timer)
},
methods: {
parseTime,
initWebSocket() {
this.connection(this)
},
connection(_this) {
const socket = new SockJS(this.socketApi)// 连接服务端提供的通信接口,连接以后才可以订阅广播消息和个人消息
// 获取STOMP子协议的客户端对象
this.stompClient = Stomp.over(socket)
// 定义客户端的认证信息,按需求配置
var headers = {
token: 'k1'
}
// 向服务器发起websocket连接
this.stompClient.connect(headers, (frame) => {
this.stompClient.subscribe('/topic/logMsg', (msg) => { // 订阅服务端提供的某个topic
var content = JSON.parse(msg.body)
content.name = 'elAdmin-'
console.log(_this.data)
this.data.push(content)
})
}, (err) => {
// 连接发生错误时的处理函数
console.log(err)
})
},
// 断开连接
disconnect() {
if (this.stompClient != null) {
this.stompClient.disconnect()
window.clearInterval(this.timer)
}
},
getColor(level) {
if (level === 'INFO') {
return this.INFO
} else if (level === 'WARN') {
return this.WARN
} else if (level === 'DEBUG') {
return this.DEBUG
} else {
return this.ERROR
}
},
doLock() {
if (this.unlock) {
this.content = '解除锁定'
this.ico = 'lock'
} else {
this.content = '锁定滚动条'
this.ico = 'unlock'
}
this.unlock = !this.unlock
}
}
}
</script>
<style scoped>
button,input,textarea {
outline: 0
}
.container {
margin: 2px
}
.container .console {
font-family: "Interstate", "Hind", -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;
overflow-y: scroll;
background: #494949;
color: #f7f7f7;
padding: 10px;
font-size: 14px;
border-radius: 3px 1px 3px 3px;
}
.lock {
position: fixed;
right: 45px;
bottom: 6.8%;
z-index: 100000
}
</style>
......@@ -18,7 +18,6 @@
</el-table-column>
<el-table-column v-if="checkPermission(['ADMIN','REDIS_ALL','REDIS_EDIT','REDIS_DELETE'])" label="操作" width="130px" align="center">
<template slot-scope="scope">
<edit v-permission="['ADMIN','REDIS_ALL','REDIS_EDIT']" :data="scope.row" :sup_this="sup_this"/>
<el-popover
v-permission="['ADMIN','REDIS_ALL','REDIS_DELETE']"
:ref="scope.$index"
......@@ -49,9 +48,8 @@ import checkPermission from '@/utils/permission' // 权限判断函数
import initData from '@/mixins/initData'
import { del } from '@/api/redis'
import eHeader from './module/header'
import edit from './module/edit'
export default {
components: { eHeader, edit },
components: { eHeader },
mixins: [initData],
data() {
return {
......
<template>
<div>
<el-button size="mini" type="primary" icon="el-icon-edit" @click="to"/>
<eForm ref="form" :sup_this="sup_this" :is-add="false"/>
</div>
</template>
<script>
import eForm from './form'
export default {
components: { eForm },
props: {
data: {
type: Object,
required: true
},
sup_this: {
type: Object,
required: true
}
},
methods: {
to() {
const _this = this.$refs.form
_this.form = { key: this.data.key, value: this.data.value }
_this.dialog = true
}
}
}
</script>
<style scoped>
div{display: inline-block;margin-right: 3px;}
</style>
<template>
<el-dialog :visible.sync="dialog" :title="isAdd ? '新增缓存' : '编辑缓存'" append-to-body width="500px">
<el-form ref="form" :model="form" :rules="rules" size="small" label-width="66px">
<el-form-item label="key" prop="key">
<el-input v-model="form.key" style="width: 370px;"/>
</el-form-item>
<el-form-item label="value" prop="value">
<el-input v-model="form.value" style="width: 370px;" rows="6" type="textarea"/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="text" @click="cancel">取消</el-button>
<el-button :loading="loading" type="primary" @click="doSubmit">确认</el-button>
</div>
</el-dialog>
</template>
<script>
import { add, edit } from '@/api/redis'
export default {
props: {
isAdd: {
type: Boolean,
required: true
},
sup_this: {
type: Object,
default: null
}
},
data() {
return {
loading: false, dialog: false, title: '新增缓存',
form: { key: '', value: '' },
rules: {
key: [
{ required: true, message: '请输入Key', trigger: 'blur' }
],
value: [
{ required: true, message: '请输入Value', trigger: 'blur' }
]
}
}
},
methods: {
cancel() {
this.resetForm()
},
doSubmit() {
this.$refs['form'].validate((valid) => {
if (valid) {
this.loading = true
if (this.isAdd) {
this.doAdd()
} else this.doEdit()
} else {
return false
}
})
},
doAdd() {
add(this.form).then(res => {
this.resetForm()
this.$notify({
title: '添加成功',
type: 'success',
duration: 2500
})
this.loading = false
this.$parent.$parent.init()
}).catch(err => {
this.loading = false
console.log(err.response.data.message)
})
},
doEdit() {
edit(this.form).then(res => {
this.resetForm()
this.$notify({
title: '修改成功',
type: 'success',
duration: 2500
})
this.loading = false
this.sup_this.init()
}).catch(err => {
this.loading = false
console.log(err.response.data.message)
})
},
resetForm() {
this.dialog = false
this.$refs['form'].resetFields()
this.form = { key: '', value: '' }
}
}
}
</script>
<style scoped>
</style>
......@@ -3,16 +3,6 @@
<!-- 搜索 -->
<el-input v-model="query.value" clearable placeholder="输入关键词搜索" style="width: 200px;" class="filter-item" @keyup.enter.native="toQuery"/>
<el-button class="filter-item" size="mini" type="success" icon="el-icon-search" @click="toQuery">搜索</el-button>
<!-- 新增 -->
<div v-permission="['ADMIN','REDIS_ALL','REDIS_CREATE']" style="display: inline-block;margin: 0px 2px;">
<el-button
class="filter-item"
size="mini"
type="primary"
icon="el-icon-plus"
@click="$refs.form.dialog = true">新增</el-button>
<eForm ref="form" :is-add="true"/>
</div>
<div style="display: inline-block;">
<!-- 清空缓存 -->
<el-button v-permission="['ADMIN','REDIS_ALL','REDIS_DELETE']" :loading="deleteAllLoading" type="warning" size="mini" class="filter-item" icon="el-icon-delete" @click="deleteAll">清空缓存</el-button>
......@@ -21,11 +11,9 @@
</template>
<script>
import eForm from './form'
import { delAll } from '@/api/redis'
// 查询条件
export default {
components: { eForm },
props: {
query: {
type: Object,
......
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