mirror of
https://github.com/jumpserver/lina.git
synced 2025-09-01 06:58:01 +00:00
feat: 封装json editor组件
This commit is contained in:
@@ -58,6 +58,7 @@
|
|||||||
"vue-cookie": "^1.1.4",
|
"vue-cookie": "^1.1.4",
|
||||||
"vue-echarts": "^5.0.0-beta.0",
|
"vue-echarts": "^5.0.0-beta.0",
|
||||||
"vue-i18n": "^8.15.5",
|
"vue-i18n": "^8.15.5",
|
||||||
|
"vue-json-editor": "^1.4.3",
|
||||||
"vue-moment": "^4.1.0",
|
"vue-moment": "^4.1.0",
|
||||||
"vue-password-strength-meter": "^1.7.2",
|
"vue-password-strength-meter": "^1.7.2",
|
||||||
"vue-router": "3.0.6",
|
"vue-router": "3.0.6",
|
||||||
|
73
src/components/FormFields/JsonEditor.vue
Normal file
73
src/components/FormFields/JsonEditor.vue
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
<template>
|
||||||
|
<div class="json-editor">
|
||||||
|
<JsonEditor
|
||||||
|
v-model="resultInfo"
|
||||||
|
:show-btns="false"
|
||||||
|
:mode="'code'"
|
||||||
|
@json-change="onJsonChange"
|
||||||
|
@json-save="onJsonSave"
|
||||||
|
@has-error="onError"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import JsonEditor from 'vue-json-editor'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: { JsonEditor },
|
||||||
|
props: {
|
||||||
|
value: {
|
||||||
|
type: String,
|
||||||
|
default: () => ''
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
hasJsonFlag: true, // json是否验证通过
|
||||||
|
resultInfo: {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.resultInfo = JSON.parse(this.value)
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
// 数据改变
|
||||||
|
onJsonChange(value) {
|
||||||
|
this.onJsonSave(value)
|
||||||
|
},
|
||||||
|
// 保存
|
||||||
|
onJsonSave(value) {
|
||||||
|
this.resultInfo = value
|
||||||
|
this.hasJsonFlag = true
|
||||||
|
setTimeout(() => {
|
||||||
|
this.$emit('change', JSON.stringify(this.resultInfo))
|
||||||
|
}, 500)
|
||||||
|
},
|
||||||
|
onError: _.debounce(function(value) {
|
||||||
|
this.$message.error(this.$t('common.FormatError'))
|
||||||
|
}, 1100)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.json-editor {
|
||||||
|
&>>> .jsoneditor {
|
||||||
|
border: 1px solid #e5e6e7;
|
||||||
|
}
|
||||||
|
&>>> .jsoneditor-compact {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
&>>> .jsoneditor-modes {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
&>>> .jsoneditor-poweredBy {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
&>>> .jsoneditor-menu {
|
||||||
|
background: #1ab394;
|
||||||
|
border-bottom: 1px solid #1ab394;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
@@ -8,6 +8,7 @@ import UploadKey from './UploadKey'
|
|||||||
import UserPassword from './UserPassword'
|
import UserPassword from './UserPassword'
|
||||||
import WeekCronSelect from './WeekCronSelect'
|
import WeekCronSelect from './WeekCronSelect'
|
||||||
import UpdateToken from './UpdateToken'
|
import UpdateToken from './UpdateToken'
|
||||||
|
import JsonEditor from './JsonEditor'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
DatetimeRangePicker,
|
DatetimeRangePicker,
|
||||||
@@ -19,7 +20,8 @@ export default {
|
|||||||
UploadField,
|
UploadField,
|
||||||
UserPassword,
|
UserPassword,
|
||||||
WeekCronSelect,
|
WeekCronSelect,
|
||||||
UpdateToken
|
UpdateToken,
|
||||||
|
JsonEditor
|
||||||
}
|
}
|
||||||
|
|
||||||
export {
|
export {
|
||||||
@@ -32,5 +34,6 @@ export {
|
|||||||
UploadField,
|
UploadField,
|
||||||
UserPassword,
|
UserPassword,
|
||||||
WeekCronSelect,
|
WeekCronSelect,
|
||||||
UpdateToken
|
UpdateToken,
|
||||||
|
JsonEditor
|
||||||
}
|
}
|
||||||
|
@@ -445,6 +445,7 @@
|
|||||||
"lastCannotBeDeleteMsg": "最后一项,不能被删除",
|
"lastCannotBeDeleteMsg": "最后一项,不能被删除",
|
||||||
"InvalidJson": "不是合法 JSON",
|
"InvalidJson": "不是合法 JSON",
|
||||||
"time_period": "时段",
|
"time_period": "时段",
|
||||||
|
"FormatError": "格式错误",
|
||||||
"WeekCronSelect": {
|
"WeekCronSelect": {
|
||||||
"Monday": "星期一",
|
"Monday": "星期一",
|
||||||
"Tuesday": "星期二",
|
"Tuesday": "星期二",
|
||||||
|
@@ -468,6 +468,7 @@
|
|||||||
"failedConditions": "cron expression error"
|
"failedConditions": "cron expression error"
|
||||||
},
|
},
|
||||||
"Cycle": "Cycle",
|
"Cycle": "Cycle",
|
||||||
|
"FormatError": "Format error",
|
||||||
"WeekCronSelect": {
|
"WeekCronSelect": {
|
||||||
"Monday": "Monday",
|
"Monday": "Monday",
|
||||||
"Tuesday": "Tuesday",
|
"Tuesday": "Tuesday",
|
||||||
|
@@ -11,6 +11,8 @@
|
|||||||
<script>
|
<script>
|
||||||
import BaseAuth from './Base'
|
import BaseAuth from './Base'
|
||||||
import { JsonRequired } from '@/components/DataForm/rules'
|
import { JsonRequired } from '@/components/DataForm/rules'
|
||||||
|
import { JsonEditor } from '@/components/FormFields'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Cas',
|
name: 'Cas',
|
||||||
components: {
|
components: {
|
||||||
@@ -36,10 +38,7 @@ export default {
|
|||||||
],
|
],
|
||||||
fieldsMeta: {
|
fieldsMeta: {
|
||||||
CAS_RENAME_ATTRIBUTES: {
|
CAS_RENAME_ATTRIBUTES: {
|
||||||
component: 'el-input',
|
component: JsonEditor,
|
||||||
el: {
|
|
||||||
type: 'textarea'
|
|
||||||
},
|
|
||||||
label: this.$t('setting.authUserAttrMap'),
|
label: this.$t('setting.authUserAttrMap'),
|
||||||
rules: [JsonRequired]
|
rules: [JsonRequired]
|
||||||
}
|
}
|
||||||
|
@@ -12,6 +12,8 @@
|
|||||||
import BaseAuth from './Base'
|
import BaseAuth from './Base'
|
||||||
import { JsonRequired } from '@/components/DataForm/rules'
|
import { JsonRequired } from '@/components/DataForm/rules'
|
||||||
import { UploadKey } from '@/components'
|
import { UploadKey } from '@/components'
|
||||||
|
import { JsonEditor } from '@/components/FormFields'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'SAML2',
|
name: 'SAML2',
|
||||||
components: {
|
components: {
|
||||||
@@ -54,11 +56,7 @@ export default {
|
|||||||
label: this.$t('setting.authSAML2Xml')
|
label: this.$t('setting.authSAML2Xml')
|
||||||
},
|
},
|
||||||
SAML2_SP_ADVANCED_SETTINGS: {
|
SAML2_SP_ADVANCED_SETTINGS: {
|
||||||
component: 'el-input',
|
component: JsonEditor,
|
||||||
el: {
|
|
||||||
type: 'textarea',
|
|
||||||
rows: 3
|
|
||||||
},
|
|
||||||
label: this.$t('setting.authSAML2AdvancedSettings'),
|
label: this.$t('setting.authSAML2AdvancedSettings'),
|
||||||
rules: [JsonRequired]
|
rules: [JsonRequired]
|
||||||
},
|
},
|
||||||
@@ -69,10 +67,7 @@ export default {
|
|||||||
component: UploadKey
|
component: UploadKey
|
||||||
},
|
},
|
||||||
SAML2_RENAME_ATTRIBUTES: {
|
SAML2_RENAME_ATTRIBUTES: {
|
||||||
component: 'el-input',
|
component: JsonEditor,
|
||||||
el: {
|
|
||||||
type: 'textarea'
|
|
||||||
},
|
|
||||||
label: this.$t('setting.authUserAttrMap'),
|
label: this.$t('setting.authUserAttrMap'),
|
||||||
rules: [JsonRequired],
|
rules: [JsonRequired],
|
||||||
helpText: this.$t('setting.authUserAttrMapHelpText')
|
helpText: this.$t('setting.authUserAttrMapHelpText')
|
||||||
|
@@ -13,7 +13,7 @@ import TestLoginDialog from './TestLoginDialog'
|
|||||||
import { IBox } from '@/components'
|
import { IBox } from '@/components'
|
||||||
import rules from '@/components/DataForm/rules'
|
import rules from '@/components/DataForm/rules'
|
||||||
import { JsonRequired } from '@/components/DataForm/rules'
|
import { JsonRequired } from '@/components/DataForm/rules'
|
||||||
import { UpdateToken } from '@/components/FormFields'
|
import { UpdateToken, JsonEditor } from '@/components/FormFields'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Ldap',
|
name: 'Ldap',
|
||||||
@@ -62,10 +62,7 @@ export default {
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
AUTH_LDAP_USER_ATTR_MAP: {
|
AUTH_LDAP_USER_ATTR_MAP: {
|
||||||
component: 'el-input',
|
component: JsonEditor,
|
||||||
el: {
|
|
||||||
type: 'textarea'
|
|
||||||
},
|
|
||||||
label: this.$t('setting.authLdapUserAttrMap'),
|
label: this.$t('setting.authLdapUserAttrMap'),
|
||||||
rules: [JsonRequired]
|
rules: [JsonRequired]
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user