Skip to content

Commit 168150f

Browse files
committed
refine code
1 parent db83dd5 commit 168150f

File tree

8 files changed

+54
-157
lines changed

8 files changed

+54
-157
lines changed

src/components/Charts/keyboard.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,7 @@
105105
return idx * 20;
106106
}
107107
}]
108-
}
109-
)
108+
})
110109
}
111110
}
112111
}

src/components/MDinput/index.vue

Lines changed: 24 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -1,127 +1,23 @@
11
<template>
22
<div class="material-input__component" :class="computedClasses">
3-
<input
4-
v-if="type === 'email'"
5-
type="email"
6-
class="material-input"
7-
:name="name"
8-
:id="id"
9-
:placeholder="placeholder"
10-
v-model="valueCopy"
11-
12-
:readonly="readonly"
13-
:disabled="disabled"
14-
:autocomplete="autocomplete"
15-
16-
:required="required"
17-
18-
@focus="handleFocus(true)"
19-
@blur="handleFocus(false)"
20-
@input="handleModelInput"
21-
>
22-
<input
23-
v-if="type === 'url'"
24-
type="url"
25-
class="material-input"
26-
:name="name"
27-
:id="id"
28-
:placeholder="placeholder"
29-
v-model="valueCopy"
30-
31-
:readonly="readonly"
32-
:disabled="disabled"
33-
:autocomplete="autocomplete"
34-
35-
:required="required"
36-
37-
@focus="handleFocus(true)"
38-
@blur="handleFocus(false)"
39-
@input="handleModelInput"
40-
>
41-
<input
42-
v-if="type === 'number'"
43-
type="number"
44-
class="material-input"
45-
:name="name"
46-
:id="id"
47-
:placeholder="placeholder"
48-
v-model="valueCopy"
49-
50-
:readonly="readonly"
51-
:disabled="disabled"
52-
:autocomplete="autocomplete"
53-
54-
:max="max"
55-
:min="min"
56-
:minlength="minlength"
57-
:maxlength="maxlength"
58-
:required="required"
59-
60-
@focus="handleFocus(true)"
61-
@blur="handleFocus(false)"
62-
@input="handleModelInput"
63-
>
64-
<input
65-
v-if="type === 'password'"
66-
type="password"
67-
class="material-input"
68-
:name="name"
69-
:id="id"
70-
:placeholder="placeholder"
71-
v-model="valueCopy"
72-
73-
:readonly="readonly"
74-
:disabled="disabled"
75-
:autocomplete="autocomplete"
76-
77-
:max="max"
78-
:min="min"
79-
:required="required"
80-
81-
@focus="handleFocus(true)"
82-
@blur="handleFocus(false)"
83-
@input="handleModelInput"
84-
>
85-
<input
86-
v-if="type === 'tel'"
87-
type="tel"
88-
class="material-input"
89-
:name="name"
90-
:id="id"
91-
:placeholder="placeholder"
92-
v-model="valueCopy"
93-
94-
:readonly="readonly"
95-
:disabled="disabled"
96-
:autocomplete="autocomplete"
97-
98-
:required="required"
99-
100-
@focus="handleFocus(true)"
101-
@blur="handleFocus(false)"
102-
@input="handleModelInput"
103-
>
104-
<input
105-
v-if="type === 'text'"
106-
type="text"
107-
class="material-input"
108-
:name="name"
109-
:id="id"
110-
:placeholder="placeholder"
111-
v-model="valueCopy"
112-
113-
:readonly="readonly"
114-
:disabled="disabled"
115-
:autocomplete="autocomplete"
116-
117-
:minlength="minlength"
118-
:maxlength="maxlength"
119-
:required="required"
120-
121-
@focus="handleFocus(true)"
122-
@blur="handleFocus(false)"
123-
@input="handleModelInput"
124-
>
3+
<input v-if="type === 'email'" type="email" class="material-input" :name="name" :id="id" :placeholder="placeholder" v-model="valueCopy"
4+
:readonly="readonly" :disabled="disabled" :autocomplete="autocomplete" :required="required" @focus="handleFocus(true)"
5+
@blur="handleFocus(false)" @input="handleModelInput">
6+
<input v-if="type === 'url'" type="url" class="material-input" :name="name" :id="id" :placeholder="placeholder" v-model="valueCopy"
7+
:readonly="readonly" :disabled="disabled" :autocomplete="autocomplete" :required="required" @focus="handleFocus(true)"
8+
@blur="handleFocus(false)" @input="handleModelInput">
9+
<input v-if="type === 'number'" type="number" class="material-input" :name="name" :id="id" :placeholder="placeholder" v-model="valueCopy"
10+
:readonly="readonly" :disabled="disabled" :autocomplete="autocomplete" :max="max" :min="min" :minlength="minlength"
11+
:maxlength="maxlength" :required="required" @focus="handleFocus(true)" @blur="handleFocus(false)" @input="handleModelInput">
12+
<input v-if="type === 'password'" type="password" class="material-input" :name="name" :id="id" :placeholder="placeholder"
13+
v-model="valueCopy" :readonly="readonly" :disabled="disabled" :autocomplete="autocomplete" :max="max" :min="min"
14+
:required="required" @focus="handleFocus(true)" @blur="handleFocus(false)" @input="handleModelInput">
15+
<input v-if="type === 'tel'" type="tel" class="material-input" :name="name" :id="id" :placeholder="placeholder" v-model="valueCopy"
16+
:readonly="readonly" :disabled="disabled" :autocomplete="autocomplete" :required="required" @focus="handleFocus(true)"
17+
@blur="handleFocus(false)" @input="handleModelInput">
18+
<input v-if="type === 'text'" type="text" class="material-input" :name="name" :id="id" :placeholder="placeholder" v-model="valueCopy"
19+
:readonly="readonly" :disabled="disabled" :autocomplete="autocomplete" :minlength="minlength" :maxlength="maxlength"
20+
:required="required" @focus="handleFocus(true)" @blur="handleFocus(false)" @input="handleModelInput">
12521

12622
<span class="material-input-bar"></span>
12723

@@ -137,6 +33,7 @@
13733
</template>
13834

13935
<script>
36+
// source:https://github.com/wemake-services/vue-material-input/blob/master/src/components/MaterialInput.vue
14037
export default {
14138
name: 'material-input',
14239
computed: {
@@ -148,12 +45,8 @@
14845
return {
14946
'material--active': this.focus,
15047
'material--disabled': this.disabled,
151-
'material--has-errors': Boolean(
152-
!this.valid ||
153-
(this.errorMessages && this.errorMessages.length)),
154-
'material--raised': Boolean(
155-
this.focus ||
156-
this.valueCopy || // has value
48+
'material--has-errors': Boolean(!this.valid || (this.errorMessages && this.errorMessages.length)),
49+
'material--raised': Boolean(this.focus || this.valueCopy || // has value
15750
(this.placeholder && !this.valueCopy)) // has placeholder
15851
}
15952
}
@@ -166,8 +59,8 @@
16659
}
16760
},
16861
beforeMount() {
169-
// Here we are following the Vue2 convention on custom v-model:
170-
// https://github.com/vuejs/vue/issues/2873#issuecomment-223759341
62+
// Here we are following the Vue2 convention on custom v-model:
63+
// https://github.com/vuejs/vue/issues/2873#issuecomment-223759341
17164
this.copyValue(this.value)
17265
},
17366
methods: {
@@ -179,8 +72,7 @@
17972
this.focus = focused
18073
},
18174
handleValidation() {
182-
this.valid = this.$el ? this.$el.querySelector(
183-
'.material-input').validity.valid : this.valid
75+
this.valid = this.$el ? this.$el.querySelector('.material-input').validity.valid : this.valid
18476
},
18577
copyValue(value) {
18678
this.valueCopy = value
@@ -388,8 +280,6 @@
388280
}
389281
// Errors:
390282
&.material--has-errors {
391-
// These styles are required
392-
// for custom validation:
393283
&.material--active .material-label {
394284
color: $color-red;
395285
}

src/components/MdEditor/index.vue

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div class='simplemde-container'>
2+
<div class='simplemde-container' :style="{height:height+'px',zIndex:zIndex}">
33
<textarea :id='id'>
44
</textarea>
55
</div>
@@ -24,11 +24,16 @@ export default {
2424
type: String,
2525
default: ''
2626
},
27+
height: {
28+
type: Number,
29+
default: 150
30+
},
31+
zIndex: {
32+
type: Number,
33+
default: 10
34+
},
2735
toolbar: {
2836
type: Array
29-
// default() {
30-
// return ['bold', '|', 'link']
31-
// }
3237
}
3338
},
3439
data() {
@@ -58,7 +63,6 @@ export default {
5863
if (this.value) {
5964
this.simplemde.value(this.value);
6065
}
61-
6266
this.simplemde.codemirror.on('change', () => {
6367
if (this.hasChange) {
6468
this.hasChange = true
@@ -74,7 +78,7 @@ export default {
7478

7579
<style>
7680
.simplemde-container .CodeMirror {
77-
height: 150px;
81+
/*height: 150px;*/
7882
min-height: 150px;
7983
}
8084
.simplemde-container .CodeMirror-scroll{
@@ -102,7 +106,6 @@ export default {
102106
font-weight: bold;
103107
color: #E61E1E;
104108
}
105-
106109
</style>
107110

108111

src/components/PanThumb/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div class="pan-item" :style="{zIndex:zIndex,height:height,width:width}">
33
<div class="pan-info">
44
<div class="pan-info-roles-container">
5-
<slot>pan</slot>
5+
<slot></slot>
66
</div>
77
</div>
88
<img class="pan-thumb" :src="image">

src/components/Tinymce/index.vue

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,29 @@
11
<template>
22
<div class='tinymce-container editor-container'>
33
<textarea class='tinymce-textarea' :id="id"></textarea>
4+
<!--业务需求可删除-->
45
<div class="editor-custom-btn-container">
56
<editorSlide v-if="customButton.indexOf('editorSlide')>=0" color="#3A71A8" class="editor-upload-btn" @successCBK="slideSuccessCBK"></editorSlide>
67
<editorAudio v-if="customButton.indexOf('editorAudio')>=0" color="#30B08F" class="editor-upload-btn" @successCBK="aduioSuccessCBK"></editorAudio>
78
<editorVideo v-if="customButton.indexOf('editorVideo')>=0" color="#E65D6E" class="editor-upload-btn" @successCBK="videoSuccessCBK"></editorVideo>
89
<editorImage v-if="customButton.indexOf('editorImage')>=0" color="#20a0ff" class="editor-upload-btn" @successCBK="imageSuccessCBK"></editorImage>
10+
<!--业务需求可删除-->
911
</div>
1012
</div>
1113
</template>
1214

1315
<script>
16+
// tinymce 在最外层目录static下 ,由index.html直接引入,挂载在window下。不通过impot,不打包
17+
// 业务需求可删除
1418
import editorAudio from './components/editorAudio';
1519
import editorVideo from './components/editorVideo';
1620
import editorSlide from './components/editorSlide';
1721
import editorImage from './components/editorImage';
18-
import { getToken, upload } from 'api/qiniu';
22+
import { getToken, upload } from 'api/qiniu'; // 七牛
23+
// 业务需求可删除
1924
export default {
2025
name: 'tinymce',
21-
components: { editorImage, editorAudio, editorSlide, editorVideo },
26+
components: { editorImage, editorAudio, editorSlide, editorVideo }, // 业务需求可删除
2227
props: {
2328
id: {
2429
type: String,
@@ -100,6 +105,7 @@
100105
this.$emit('input', editor.getContent({ format: 'raw' }));
101106
});
102107
},
108+
// 整合七牛上传
103109
// images_dataimg_filter(img) {
104110
// setTimeout(() => {
105111
// const $image = $(img);
@@ -149,7 +155,7 @@
149155
}
150156
});
151157
editor.addButton('p', {
152-
title: '正文', // tooltip text seen on mouseover
158+
title: '正文',
153159
text: '正文',
154160
onclick() {
155161
editor.execCommand('mceToggleFormat', false, 'p');
@@ -167,6 +173,7 @@
167173
});
168174
},
169175
methods: {
176+
/* 业务代码可删除 start*/
170177
imageSuccessCBK(arr) {
171178
console.log(arr)
172179
const _this = this;
@@ -212,6 +219,7 @@
212219
node.className = 'wscnph editor-placeholder';
213220
tinymce.get(this.id).insertContent(node.outerHTML)
214221
}
222+
/* 业务代码可删除 end*/
215223
},
216224
destroyed() {
217225
tinymce.get(this.id).destroy();

src/directive/sticky.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,12 @@
1111

1212
elStyle.position = '-webkit-sticky';
1313
elStyle.position = 'sticky';
14-
15-
// if the browser support css sticky(Currently Safari, Firefox and Chrome Canary)
16-
// if (~elStyle.position.indexOf('sticky')) {
17-
// elStyle.top = `${stickyTop}px`;
18-
// elStyle.zIndex = zIndex;
19-
// return
20-
// }
21-
14+
// if the browser support css sticky(Currently Safari, Firefox and Chrome Canary)
15+
// if (~elStyle.position.indexOf('sticky')) {
16+
// elStyle.top = `${stickyTop}px`;
17+
// elStyle.zIndex = zIndex;
18+
// return
19+
// }
2220
const elHeight = el.getBoundingClientRect().height;
2321
const elWidth = el.getBoundingClientRect().width;
2422
elStyle.cssText = `top: ${stickyTop}px; z-index: ${zIndex}`;

src/router/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import Router from 'vue-router';
55
import Layout from '../views/layout/Layout';
66

77
// dashboard
8-
// import dashboard from '../views/dashboard/index';
98
const dashboard = resolve => require(['../views/dashboard/index'], resolve);
109

1110
/* error page*/

src/views/components/markdown.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div class="components-container">
33
<code>公司做的后台主要是一个cms系统,公司也是已自媒体为核心的,所以富文本是后台很核心的功能。在选择富文本的过程中也走了不少的弯路,市面上常见的富文本都基本用过了,最终选择了tinymce</code>
44
<div class="editor-container">
5-
<MdEditor id='contentEditor' ref="contentEditor" v-model='content' :height="150"></MdEditor>
5+
<MdEditor id='contentEditor' ref="contentEditor" v-model='content' :height="300" :zIndex='20'></MdEditor>
66
</div>
77
</div>
88
</template>

0 commit comments

Comments
 (0)