From e25ff4286e4b8a6276365163e953e8bc6326a359 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=87=E5=A4=A9?= Date: Wed, 15 Aug 2018 12:27:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=AF=AD=E8=A8=80=E5=8C=85?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E9=80=BB=E8=BE=91;=E4=BC=98=E5=8C=96switch?= =?UTF-8?q?=E7=BB=84=E4=BB=B6checked=E5=B1=9E=E6=80=A7=E5=92=8C=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F;meditor=E5=A2=9E=E5=8A=A0revise=E5=9B=9E=E8=B0=83,?= =?UTF-8?q?=E5=85=81=E8=AE=B8=E7=94=A8=E6=88=B7=E5=AF=B9md=E7=BC=96?= =?UTF-8?q?=E8=AF=91=E5=90=8E=E7=9A=84=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/css/form.scss | 8 ++++---- src/form/index.js | 8 +++++++- src/layer/index.js | 3 ++- src/meditor/addon/attach-native.js | 3 ++- src/meditor/addon/attach.js | 3 ++- src/meditor/index.js | 7 ++++++- 6 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/css/form.scss b/src/css/form.scss index 565b08d..c850b63 100644 --- a/src/css/form.scss +++ b/src/css/form.scss @@ -155,12 +155,12 @@ &.dark.checked &__label {background:nth($cd, 1) + a0;} &.disabled.checked &__dot {background:#fff;} - &.disabled &__label, &.disabled.checked &__label {background:nth($cp, 1); + &.disabled &__label, &.disabled.checked &__label { - &::before {display:block;position:absolute;top:6px;width:8px;height:4px;border-radius:2px;background:#fff;content:"";} + &::before {display:block;position:absolute;top:5px;width:8px;height:4px;border-radius:2px;background:#fff;content:"";} } - &.disabled &__label::before {right:7px;} - &.disabled.checked &__label::before {left:7px;} + &.disabled &__label::before {right:5px;} + &.disabled.checked &__label::before {left:5px;} } diff --git a/src/form/index.js b/src/form/index.js index 641cf7a..c6afe62 100644 --- a/src/form/index.js +++ b/src/form/index.js @@ -128,6 +128,12 @@ Anot.component('switch', { if (props.hasOwnProperty('disabled')) { state.disabled = true } + if (props.hasOwnProperty('checked')) { + if (state.value === null) { + state.value = true + } + } + state.value = !!state.value this.classList.add('do-switch') this.classList.add('do-fn-noselect') @@ -145,7 +151,7 @@ Anot.component('switch', { ` }, state: { - value: false, + value: null, disabled: false }, methods: { diff --git a/src/layer/index.js b/src/layer/index.js index 13ce4d4..b7f929b 100644 --- a/src/layer/index.js +++ b/src/layer/index.js @@ -36,7 +36,8 @@ const LANGUAGES = { } } LANGUAGES['zh-CN'] = LANGUAGES.zh -const lang = LANGUAGES[Anot.language || navigator.language] || LANGUAGES.en +const lang = + LANGUAGES[window.__ENV_LANG__ || navigator.language] || LANGUAGES.en let layerDom = {} let layerObj = {} let unique = null // 储存当前打开的1/2/3类型的弹窗 diff --git a/src/meditor/addon/attach-native.js b/src/meditor/addon/attach-native.js index 7a44c22..775d8ad 100644 --- a/src/meditor/addon/attach-native.js +++ b/src/meditor/addon/attach-native.js @@ -81,7 +81,8 @@ const LANGUAGES = { } LANGUAGES['zh-CN'] = LANGUAGES.zh LANGUAGES['zh-TW'] = LANGUAGES.zh -const lang = LANGUAGES[Anot.language || navigator.language] || LANGUAGES.en +const lang = + LANGUAGES[window.__ENV_LANG__ || navigator.language] || LANGUAGES.en const fixCont = function(vm, tool) { let limit = false diff --git a/src/meditor/addon/attach.js b/src/meditor/addon/attach.js index 0bf1746..d76ba34 100644 --- a/src/meditor/addon/attach.js +++ b/src/meditor/addon/attach.js @@ -79,7 +79,8 @@ const LANGUAGES = { } LANGUAGES['zh-CN'] = LANGUAGES.zh LANGUAGES['zh-TW'] = LANGUAGES.zh -const lang = LANGUAGES[Anot.language || navigator.language] || LANGUAGES.en +const lang = + LANGUAGES[window.__ENV_LANG__ || navigator.language] || LANGUAGES.en class Uploader { constructor(url) { diff --git a/src/meditor/index.js b/src/meditor/index.js index 097239f..60294b5 100644 --- a/src/meditor/index.js +++ b/src/meditor/index.js @@ -140,7 +140,8 @@ const LANGUAGES = { } LANGUAGES['zh-CN'] = LANGUAGES.zh LANGUAGES['zh-TW'] = LANGUAGES.zh -const lang = LANGUAGES[Anot.language || navigator.language] || LANGUAGES.en +const lang = + LANGUAGES[window.__ENV_LANG__ || navigator.language] || LANGUAGES.en marked.setOptions({ highlight: function(code, lang) { @@ -507,6 +508,7 @@ Anot.component('meditor', { }, props: { safeMode: true, + revise: Anot.PropsTypes.isFunction(), created: Anot.PropsTypes.isFunction(), onUpdate: Anot.PropsTypes.isFunction(), onFullscreen: Anot.PropsTypes.isFunction() @@ -606,6 +608,9 @@ Anot.component('meditor', { } //只解析,不渲染 this.__tmp__ = marked(txt) + if (typeof this.props.revise === 'function') { + this.__tmp__ = this.props.revise(this.__tmp__) + } } } })