Commit 551e911e authored by Pan's avatar Pan Committed by 花裤衩

全局lint优化

parent b8ecda19
This diff is collapsed.
...@@ -37,15 +37,15 @@ module.exports = { ...@@ -37,15 +37,15 @@ module.exports = {
}, },
module: { module: {
rules: [ rules: [
// { {
// test: /\.(js|vue)$/, test: /\.(js|vue)$/,
// loader: 'eslint-loader', loader: 'eslint-loader',
// enforce: "pre", enforce: "pre",
// include: [resolve('src'), resolve('test')], include: [resolve('src'), resolve('test')],
// options: { options: {
// formatter: require('eslint-friendly-formatter') formatter: require('eslint-friendly-formatter')
// } }
// }, },
{ {
test: /\.vue$/, test: /\.vue$/,
loader: 'vue-loader', loader: 'vue-loader',
......
...@@ -11,6 +11,6 @@ ...@@ -11,6 +11,6 @@
</script> </script>
<style lang="scss"> <style lang="scss">
@import '~normalize.css/normalize.css';// normalize.css 样式格式化 @import '~normalize.css/normalize.css';// normalize.css 样式格式化
@import './styles/index.scss'; // 全局自定义的css样式 @import './styles/index.scss'; // 全局自定义的css样式
</style> </style>
import fetch from 'utils/fetch'; import fetch from 'utils/fetch'
export function getList() { export function getList () {
return fetch({ return fetch({
url: '/article/list', url: '/article/list',
method: 'get' method: 'get'
}); })
} }
export function getArticle() { export function getArticle () {
return fetch({ return fetch({
url: '/article/detail', url: '/article/detail',
method: 'get' method: 'get'
}); })
} }
import fetch from 'utils/fetch'; import fetch from 'utils/fetch'
export function fetchList(query) { export function fetchList (query) {
return fetch({ return fetch({
url: '/article_table/list', url: '/article_table/list',
method: 'get', method: 'get',
params: query params: query
}); })
} }
export function fetchPv(pv) { export function fetchPv (pv) {
return fetch({ return fetch({
url: '/article_table/pv', url: '/article_table/pv',
method: 'get', method: 'get',
params: { pv } params: { pv }
}); })
} }
import fetch from 'utils/fetch' import fetch from 'utils/fetch'
export function loginByUsername(username, password) { export function loginByUsername (username, password) {
const data = { const data = {
username, username,
password password
...@@ -12,14 +12,14 @@ export function loginByUsername(username, password) { ...@@ -12,14 +12,14 @@ export function loginByUsername(username, password) {
}) })
} }
export function logout() { export function logout () {
return fetch({ return fetch({
url: '/login/logout', url: '/login/logout',
method: 'post' method: 'post'
}) })
} }
export function getInfo(token) { export function getInfo (token) {
return fetch({ return fetch({
url: '/user/info', url: '/user/info',
method: 'get', method: 'get',
......
import fetch from 'utils/fetch'; import fetch from 'utils/fetch'
export function getToken() { export function getToken () {
return fetch({ return fetch({
url: '/qiniu/upload/token', // 假地址 自行替换 url: '/qiniu/upload/token', // 假地址 自行替换
method: 'get' method: 'get'
}); })
} }
import fetch from 'utils/fetch'; import fetch from 'utils/fetch'
export function userSearch(name) { export function userSearch (name) {
return fetch({ return fetch({
url: '/search/user', url: '/search/user',
method: 'get', method: 'get',
params: { name } params: { name }
}); })
} }
...@@ -12,73 +12,73 @@ ...@@ -12,73 +12,73 @@
</template> </template>
<script> <script>
export default { export default {
name: 'BackToTop', name: 'BackToTop',
props: { props: {
visibilityHeight: { visibilityHeight: {
type: Number, type: Number,
default: 400 default: 400
}, },
backPosition: { backPosition: {
type: Number, type: Number,
default: 0 default: 0
},
customStyle: {
type: Object,
default: {
right: '50px',
bottom: '50px',
width: '40px',
height: '40px',
'border-radius': '4px',
'line-height': '45px',
background: '#e7eaf1'
}
},
transitionName: {
type: String,
default: 'fade'
}
}, },
data() { customStyle: {
return { type: Object,
visible: false, default: {
interval: null right: '50px',
bottom: '50px',
width: '40px',
height: '40px',
'border-radius': '4px',
'line-height': '45px',
background: '#e7eaf1'
} }
}, },
mounted() { transitionName: {
window.addEventListener('scroll', this.handleScroll); type: String,
default: 'fade'
}
},
data() {
return {
visible: false,
interval: null
}
},
mounted() {
window.addEventListener('scroll', this.handleScroll)
},
beforeDestroy() {
window.removeEventListener('scroll', this.handleScroll)
if (this.interval) {
clearInterval(this.interval)
}
},
methods: {
handleScroll() {
this.visible = window.pageYOffset > this.visibilityHeight
}, },
beforeDestroy() { backToTop() {
window.removeEventListener('scroll', this.handleScroll); const start = window.pageYOffset
if (this.interval) { let i = 0
clearInterval(this.interval); this.interval = setInterval(() => {
} const next = Math.floor(this.easeInOutQuad(10 * i, start, -start, 500))
if (next <= this.backPosition) {
window.scrollTo(0, this.backPosition)
clearInterval(this.interval)
} else {
window.scrollTo(0, next)
}
i++
}, 16.7)
}, },
methods: { easeInOutQuad(t, b, c, d) {
handleScroll() { if ((t /= d / 2) < 1) return c / 2 * t * t + b
this.visible = window.pageYOffset > this.visibilityHeight; return -c / 2 * (--t * (t - 2) - 1) + b
},
backToTop() {
const start = window.pageYOffset;
let i = 0;
this.interval = setInterval(() => {
const next = Math.floor(this.easeInOutQuad(10 * i, start, -start, 500));
if (next <= this.backPosition) {
window.scrollTo(0, this.backPosition);
clearInterval(this.interval)
} else {
window.scrollTo(0, next);
}
i++;
}, 16.7)
},
easeInOutQuad(t, b, c, d) {
if ((t /= d / 2) < 1) return c / 2 * t * t + b;
return -c / 2 * (--t * (t - 2) - 1) + b;
}
} }
} }
}
</script> </script>
<style scoped> <style scoped>
......
...@@ -3,111 +3,111 @@ ...@@ -3,111 +3,111 @@
</template> </template>
<script> <script>
import echarts from 'echarts'; import echarts from 'echarts'
export default { export default {
props: { props: {
className: { className: {
type: String, type: String,
default: 'chart' default: 'chart'
}, },
id: { id: {
type: String, type: String,
default: 'chart' default: 'chart'
}, },
width: { width: {
type: String, type: String,
default: '200px' default: '200px'
}, },
height: { height: {
type: String, type: String,
default: '200px' default: '200px'
} }
}, },
data() { data() {
return { return {
chart: null chart: null
}; }
}, },
mounted() { mounted() {
this.initChart(); this.initChart()
}, },
beforeDestroy() { beforeDestroy() {
if (!this.chart) { if (!this.chart) {
return return
} }
this.chart.dispose(); this.chart.dispose()
this.chart = null; this.chart = null
}, },
methods: { methods: {
initChart() { initChart() {
this.chart = echarts.init(document.getElementById(this.id)); this.chart = echarts.init(document.getElementById(this.id))
const xAxisData = []; const xAxisData = []
const data = []; const data = []
for (let i = 0; i < 30; i++) { for (let i = 0; i < 30; i++) {
xAxisData.push(i + '号'); xAxisData.push(i + '号')
data.push(Math.round(Math.random() * 2 + 3)) data.push(Math.round(Math.random() * 2 + 3))
} }
this.chart.setOption( this.chart.setOption(
{ {
backgroundColor: '#08263a', backgroundColor: '#08263a',
tooltip: { tooltip: {
trigger: 'axis' trigger: 'axis'
}, },
xAxis: { xAxis: {
show: false, show: false,
data: xAxisData data: xAxisData
}, },
visualMap: { visualMap: {
show: false, show: false,
min: 0, min: 0,
max: 50, max: 50,
dimension: 0, dimension: 0,
inRange: { inRange: {
color: ['#4a657a', '#308e92', '#b1cfa5', '#f5d69f', '#f5898b', '#ef5055'] color: ['#4a657a', '#308e92', '#b1cfa5', '#f5d69f', '#f5898b', '#ef5055']
} }
}, },
yAxis: { yAxis: {
axisLine: { axisLine: {
show: false show: false
}, },
axisLabel: { axisLabel: {
textStyle: { textStyle: {
color: '#4a657a' color: '#4a657a'
} }
}, },
splitLine: { splitLine: {
show: true, show: true,
lineStyle: { lineStyle: {
color: '#08263f' color: '#08263f'
} }
}, },
axisTick: {} axisTick: {}
}, },
series: [{ series: [{
type: 'bar', type: 'bar',
data, data,
name: '撸文数', name: '撸文数',
itemStyle: { itemStyle: {
normal: { normal: {
barBorderRadius: 5, barBorderRadius: 5,
shadowBlur: 10, shadowBlur: 10,
shadowColor: '#111' shadowColor: '#111'
} }
}, },
animationEasing: 'elasticOut', animationEasing: 'elasticOut',
animationEasingUpdate: 'elasticOut', animationEasingUpdate: 'elasticOut',
animationDelay(idx) { animationDelay(idx) {
return idx * 20; return idx * 20
}, },
animationDelayUpdate(idx) { animationDelayUpdate(idx) {
return idx * 20; return idx * 20
} }
}] }]
}) })
} }
} }
} }
</script> </script>
...@@ -3,148 +3,148 @@ ...@@ -3,148 +3,148 @@
</template> </template>
<script> <script>
import echarts from 'echarts'; import echarts from 'echarts'
export default { export default {
props: { props: {
className: { className: {
type: String, type: String,
default: 'chart' default: 'chart'
},
id: {
type: String,
default: 'chart'
},
width: {
type: String,
default: '200px'
},
height: {
type: String,
default: '200px'
}
},
data() {
return {
chart: null
};
}, },
mounted() { id: {
this.initChart(); type: String,
default: 'chart'
}, },
beforeDestroy() { width: {
if (!this.chart) { type: String,
return default: '200px'
}
this.chart.dispose();
this.chart = null;
}, },
methods: { height: {
initChart() { type: String,
this.chart = echarts.init(document.getElementById(this.id)); default: '200px'
}
},
data() {
return {
chart: null
}
},
mounted() {
this.initChart()
},
beforeDestroy() {
if (!this.chart) {
return
}
this.chart.dispose()
this.chart = null
},
methods: {
initChart() {
this.chart = echarts.init(document.getElementById(this.id))
const xAxisData = []; const xAxisData = []
const data = []; const data = []
const data2 = []; const data2 = []
for (let i = 0; i < 50; i++) { for (let i = 0; i < 50; i++) {
xAxisData.push(i); xAxisData.push(i)
data.push((Math.sin(i / 5) * (i / 5 - 10) + i / 6) * 5); data.push((Math.sin(i / 5) * (i / 5 - 10) + i / 6) * 5)
data2.push((Math.sin(i / 5) * (i / 5 + 10) + i / 6) * 3); data2.push((Math.sin(i / 5) * (i / 5 + 10) + i / 6) * 3)
} }
this.chart.setOption( this.chart.setOption(
{ {
backgroundColor: '#08263a', backgroundColor: '#08263a',
xAxis: [{ xAxis: [{
show: false, show: false,
data: xAxisData data: xAxisData
}, { }, {
show: false, show: false,
data: xAxisData data: xAxisData
}], }],
visualMap: { visualMap: {
show: false, show: false,
min: 0, min: 0,
max: 50, max: 50,
dimension: 0, dimension: 0,
inRange: { inRange: {
color: ['#4a657a', '#308e92', '#b1cfa5', '#f5d69f', '#f5898b', '#ef5055'] color: ['#4a657a', '#308e92', '#b1cfa5', '#f5d69f', '#f5898b', '#ef5055']
} }
},
yAxis: {
axisLine: {
show: false
}, },
yAxis: { axisLabel: {
axisLine: { textStyle: {
show: false color: '#4a657a'
},
axisLabel: {
textStyle: {
color: '#4a657a'
}
},
splitLine: {
show: true,
lineStyle: {
color: '#08263f'
}
},
axisTick: {
show: false
} }
}, },
series: [{ splitLine: {
name: 'back', show: true,
type: 'bar',
data: data2,
z: 1,
itemStyle: {
normal: {
opacity: 0.4,
barBorderRadius: 5,
shadowBlur: 3,
shadowColor: '#111'
}
}
}, {
name: 'Simulate Shadow',
type: 'line',
data,
z: 2,
showSymbol: false,
animationDelay: 0,
animationEasing: 'linear',
animationDuration: 1200,
lineStyle: { lineStyle: {
normal: { color: '#08263f'
color: 'transparent'
}
},
areaStyle: {
normal: {
color: '#08263a',
shadowBlur: 50,
shadowColor: '#000'
}
} }
}, { },
name: 'front', axisTick: {
type: 'bar', show: false
data, }
xAxisIndex: 1, },
z: 3, series: [{
itemStyle: { name: 'back',
normal: { type: 'bar',
barBorderRadius: 5 data: data2,
} z: 1,
itemStyle: {
normal: {
opacity: 0.4,
barBorderRadius: 5,
shadowBlur: 3,
shadowColor: '#111'
}
}
}, {
name: 'Simulate Shadow',
type: 'line',
data,
z: 2,
showSymbol: false,
animationDelay: 0,
animationEasing: 'linear',
animationDuration: 1200,
lineStyle: {
normal: {
color: 'transparent'
} }
}],
animationEasing: 'elasticOut',
animationEasingUpdate: 'elasticOut',
animationDelay(idx) {
return idx * 20;
}, },
animationDelayUpdate(idx) { areaStyle: {
return idx * 20; normal: {
color: '#08263a',
shadowBlur: 50,
shadowColor: '#000'
}
} }
}) }, {
} name: 'front',
type: 'bar',
data,
xAxisIndex: 1,
z: 3,
itemStyle: {
normal: {
barBorderRadius: 5
}
}
}],
animationEasing: 'elasticOut',
animationEasingUpdate: 'elasticOut',
animationDelay(idx) {
return idx * 20
},
animationDelayUpdate(idx) {
return idx * 20
}
})
} }
} }
}
</script> </script>
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -30,19 +30,19 @@ ...@@ -30,19 +30,19 @@
</template> </template>
<script> <script>
export default { export default {
name: 'errLog', name: 'errLog',
props: { props: {
logsList: { logsList: {
type: Array type: Array
} }
}, },
data() { data() {
return { return {
dialogTableVisible: false dialogTableVisible: false
}
} }
} }
}
</script> </script>
<style scoped> <style scoped>
......
...@@ -13,19 +13,19 @@ ...@@ -13,19 +13,19 @@
</template> </template>
<script> <script>
export default { export default {
name: 'hamburger', name: 'hamburger',
props: { props: {
isActive: { isActive: {
type: Boolean, type: Boolean,
default: false default: false
}, },
toggleClick: { toggleClick: {
type: Function, type: Function,
default: null default: null
}
} }
} }
}
</script> </script>
<style scoped> <style scoped>
......
...@@ -5,18 +5,18 @@ ...@@ -5,18 +5,18 @@
</template> </template>
<script> <script>
export default { export default {
name: 'icon-svg', name: 'icon-svg',
props: { props: {
iconClass: { iconClass: {
type: String, type: String,
required: true required: true
} }
}, },
computed: { computed: {
iconName() { iconName() {
return `#icon-${this.iconClass}` return `#icon-${this.iconClass}`
}
} }
} }
}
</script> </script>
...@@ -37,5 +37,5 @@ const langBag = { ...@@ -37,5 +37,5 @@ const langBag = {
lowestPx: 'The lowest pixel in the image: ' lowestPx: 'The lowest pixel in the image: '
} }
} }
}; }
export default langBag; export default langBag
<template> <template>
<div class="material-input__component" :class="computedClasses"> <div class="material-input__component" :class="computedClasses">
<input v-if="type === 'email'" type="email" class="material-input" :name="name" :id="id" :placeholder="placeholder" v-model="valueCopy" <input v-if="type === 'email'" type="email" class="material-input" :name="name" :id="id" :placeholder="placeholder" v-model="valueCopy"
:readonly="readonly" :disabled="disabled" :autocomplete="autocomplete" :required="required" @focus="handleFocus(true)" :readonly="readonly" :disabled="disabled" :autocomplete="autocomplete" :required="required" @focus="handleFocus(true)"
@blur="handleFocus(false)" @input="handleModelInput"> @blur="handleFocus(false)" @input="handleModelInput">
<input v-if="type === 'url'" type="url" class="material-input" :name="name" :id="id" :placeholder="placeholder" v-model="valueCopy" <input v-if="type === 'url'" type="url" class="material-input" :name="name" :id="id" :placeholder="placeholder" v-model="valueCopy"
:readonly="readonly" :disabled="disabled" :autocomplete="autocomplete" :required="required" @focus="handleFocus(true)" :readonly="readonly" :disabled="disabled" :autocomplete="autocomplete" :required="required" @focus="handleFocus(true)"
@blur="handleFocus(false)" @input="handleModelInput"> @blur="handleFocus(false)" @input="handleModelInput">
<input v-if="type === 'number'" type="number" class="material-input" :name="name" :id="id" :placeholder="placeholder" v-model="valueCopy" <input v-if="type === 'number'" type="number" class="material-input" :name="name" :id="id" :placeholder="placeholder" v-model="valueCopy"
:readonly="readonly" :disabled="disabled" :autocomplete="autocomplete" :max="max" :min="min" :minlength="minlength" :maxlength="maxlength" :readonly="readonly" :disabled="disabled" :autocomplete="autocomplete" :max="max" :min="min" :minlength="minlength" :maxlength="maxlength"
:required="required" @focus="handleFocus(true)" @blur="handleFocus(false)" @input="handleModelInput"> :required="required" @focus="handleFocus(true)" @blur="handleFocus(false)" @input="handleModelInput">
<input v-if="type === 'password'" type="password" class="material-input" :name="name" :id="id" :placeholder="placeholder" <input v-if="type === 'password'" type="password" class="material-input" :name="name" :id="id" :placeholder="placeholder"
v-model="valueCopy" :readonly="readonly" :disabled="disabled" :autocomplete="autocomplete" :max="max" :min="min" :required="required" v-model="valueCopy" :readonly="readonly" :disabled="disabled" :autocomplete="autocomplete" :max="max" :min="min" :required="required"
@focus="handleFocus(true)" @blur="handleFocus(false)" @input="handleModelInput"> @focus="handleFocus(true)" @blur="handleFocus(false)" @input="handleModelInput">
<input v-if="type === 'tel'" type="tel" class="material-input" :name="name" :id="id" :placeholder="placeholder" v-model="valueCopy" <input v-if="type === 'tel'" type="tel" class="material-input" :name="name" :id="id" :placeholder="placeholder" v-model="valueCopy"
:readonly="readonly" :disabled="disabled" :autocomplete="autocomplete" :required="required" @focus="handleFocus(true)" :readonly="readonly" :disabled="disabled" :autocomplete="autocomplete" :required="required" @focus="handleFocus(true)"
@blur="handleFocus(false)" @input="handleModelInput"> @blur="handleFocus(false)" @input="handleModelInput">
<input v-if="type === 'text'" type="text" class="material-input" :name="name" :id="id" :placeholder="placeholder" v-model="valueCopy" <input v-if="type === 'text'" type="text" class="material-input" :name="name" :id="id" :placeholder="placeholder" v-model="valueCopy"
:readonly="readonly" :disabled="disabled" :autocomplete="autocomplete" :minlength="minlength" :maxlength="maxlength" :required="required" :readonly="readonly" :disabled="disabled" :autocomplete="autocomplete" :minlength="minlength" :maxlength="maxlength"
@focus="handleFocus(true)" @blur="handleFocus(false)" @input="handleModelInput"> :required="required" @focus="handleFocus(true)" @blur="handleFocus(false)" @input="handleModelInput">
<span class="material-input-bar"></span> <span class="material-input-bar"></span>
<label class="material-label"> <label class="material-label">
<slot></slot> <slot></slot>
</label> </label>
<div v-if="errorMessages" class="material-errors"> <div v-if="errorMessages" class="material-errors">
<div v-for="error in computedErrors" class="material-error" :key='error'> <div v-for="error in computedErrors" class="material-error" :key='error'>
{{ error }} {{ error }}
</div> </div>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
// source:https://github.com/wemake-services/vue-material-input/blob/master/src/components/MaterialInput.vue // source:https://github.com/wemake-services/vue-material-input/blob/master/src/components/MaterialInput.vue
export default { export default {
name: 'material-input', name: 'material-input',
computed: { computed: {
computedErrors() { computedErrors() {
......
...@@ -6,75 +6,75 @@ ...@@ -6,75 +6,75 @@
</template> </template>
<script> <script>
import 'simplemde/dist/simplemde.min.css'; import 'simplemde/dist/simplemde.min.css'
import SimpleMDE from 'simplemde'; import SimpleMDE from 'simplemde'
export default { export default {
name: 'simplemde-md', name: 'simplemde-md',
props: { props: {
value: String, value: String,
id: { id: {
type: String, type: String,
default: 'markdown-editor' default: 'markdown-editor'
},
autofocus: {
type: Boolean,
default: false
},
placeholder: {
type: String,
default: ''
},
height: {
type: Number,
default: 150
},
zIndex: {
type: Number,
default: 10
},
toolbar: {
type: Array
}
}, },
data() { autofocus: {
return { type: Boolean,
simplemde: null, default: false
hasChange: false
};
}, },
watch: { placeholder: {
value(val) { type: String,
if (val === this.simplemde.value() && !this.hasChange) return; default: ''
this.simplemde.value(val);
}
}, },
mounted() { height: {
this.simplemde = new SimpleMDE({ type: Number,
element: document.getElementById(this.id), default: 150
autofocus: this.autofocus,
toolbar: this.toolbar,
spellChecker: false,
insertTexts: {
link: ['[', ']( )']
},
// hideIcons: ['guide', 'heading', 'quote', 'image', 'preview', 'side-by-side', 'fullscreen'],
placeholder: this.placeholder
});
if (this.value) {
this.simplemde.value(this.value);
}
this.simplemde.codemirror.on('change', () => {
if (this.hasChange) {
this.hasChange = true
}
this.$emit('input', this.simplemde.value());
});
}, },
destroyed() { zIndex: {
this.simplemde = null; type: Number,
default: 10
},
toolbar: {
type: Array
}
},
data() {
return {
simplemde: null,
hasChange: false
}
},
watch: {
value(val) {
if (val === this.simplemde.value() && !this.hasChange) return
this.simplemde.value(val)
}
},
mounted() {
this.simplemde = new SimpleMDE({
element: document.getElementById(this.id),
autofocus: this.autofocus,
toolbar: this.toolbar,
spellChecker: false,
insertTexts: {
link: ['[', ']( )']
},
// hideIcons: ['guide', 'heading', 'quote', 'image', 'preview', 'side-by-side', 'fullscreen'],
placeholder: this.placeholder
})
if (this.value) {
this.simplemde.value(this.value)
} }
}; this.simplemde.codemirror.on('change', () => {
if (this.hasChange) {
this.hasChange = true
}
this.$emit('input', this.simplemde.value())
})
},
destroyed() {
this.simplemde = null
}
}
</script> </script>
<style> <style>
......
...@@ -10,27 +10,27 @@ ...@@ -10,27 +10,27 @@
</template> </template>
<script> <script>
export default { export default {
name: 'PanThumb', name: 'PanThumb',
props: { props: {
image: { image: {
type: String, type: String,
required: true required: true
}, },
zIndex: { zIndex: {
type: Number, type: Number,
default: 100 default: 100
}, },
width: { width: {
type: String, type: String,
default: '150px' default: '150px'
}, },
height: { height: {
type: String, type: String,
default: '150px' default: '150px'
}
} }
}; }
}
</script> </script>
<style scoped> <style scoped>
......
...@@ -7,41 +7,41 @@ ...@@ -7,41 +7,41 @@
</template> </template>
<script> <script>
import screenfull from 'screenfull'; import screenfull from 'screenfull'
export default { export default {
name: 'hamburger', name: 'hamburger',
props: { props: {
width: { width: {
type: Number, type: Number,
default: 22 default: 22
},
height: {
type: Number,
default: 22
},
fill: {
type: String,
default: '#48576a'
}
}, },
data() { height: {
return { type: Number,
isFullscreen: false default: 22
}
}, },
methods: { fill: {
click() { type: String,
if (!screenfull.enabled) { default: '#48576a'
this.$message({ }
message: 'you browser can not work', },
type: 'warning' data() {
}); return {
return false; isFullscreen: false
} }
screenfull.toggle(); },
methods: {
click() {
if (!screenfull.enabled) {
this.$message({
message: 'you browser can not work',
type: 'warning'
})
return false
} }
screenfull.toggle()
} }
} }
}
</script> </script>
<style scoped> <style scoped>
......
...@@ -5,16 +5,16 @@ ...@@ -5,16 +5,16 @@
</template> </template>
<script> <script>
export default { export default {
name: 'Pane', name: 'Pane',
data() { data() {
const classes = ['Pane', this.$parent.split, 'className']; const classes = ['Pane', this.$parent.split, 'className']
return { return {
classes: classes.join(' '), classes: classes.join(' '),
percent: 50 percent: 50
} }
} }
} }
</script> </script>
<style scoped> <style scoped>
......
...@@ -3,26 +3,26 @@ ...@@ -3,26 +3,26 @@
</template> </template>
<script> <script>
export default { export default {
props: { props: {
split: { split: {
validator(value) { validator(value) {
return ['vertical', 'horizontal'].indexOf(value) >= 0 return ['vertical', 'horizontal'].indexOf(value) >= 0
},
required: true
}, },
onMouseDown: { required: true
type: Function,
required: true
}
}, },
data() { onMouseDown: {
const classes = ['Resizer', this.split, 'className']; type: Function,
return { required: true
classes: classes.join(' ') }
} },
data() {
const classes = ['Resizer', this.split, 'className']
return {
classes: classes.join(' ')
} }
} }
}
</script> </script>
<style scoped> <style scoped>
......
...@@ -11,86 +11,86 @@ ...@@ -11,86 +11,86 @@
</template> </template>
<script> <script>
import Resizer from './Resizer'; import Resizer from './Resizer'
import Pane from './Pane'; import Pane from './Pane'
export default { export default {
name: 'splitPane', name: 'splitPane',
components: { Resizer, Pane }, components: { Resizer, Pane },
props: { props: {
margin: { margin: {
type: Number, type: Number,
default: 10 default: 10
},
split: {
validator(value) {
return ['vertical', 'horizontal'].indexOf(value) >= 0
}, },
split: { required: true
validator(value) { }
return ['vertical', 'horizontal'].indexOf(value) >= 0 },
}, data() {
required: true return {
} active: false,
hasMoved: false,
height: null,
percent: 50,
type: this.split === 'vertical' ? 'width' : 'height',
resizeType: this.split === 'vertical' ? 'left' : 'top'
}
},
computed: {
userSelect() {
return this.active ? 'none' : ''
}, },
data() { cursor() {
return { return this.active ? 'col-resize' : ''
active: false, }
hasMoved: false, },
height: null, methods: {
percent: 50, onClick() {
type: this.split === 'vertical' ? 'width' : 'height', if (!this.hasMoved) {
resizeType: this.split === 'vertical' ? 'left' : 'top' this.percent = 50
this.$emit('resize')
} }
}, },
computed: { onMouseDown() {
userSelect() { this.active = true
return this.active ? 'none' : '' this.hasMoved = false
},
cursor() {
return this.active ? 'col-resize' : ''
}
}, },
methods: { onMouseUp() {
onClick() { this.active = false
if (!this.hasMoved) { },
this.percent = 50; onMouseMove(e) {
this.$emit('resize'); if (e.buttons === 0 || e.which === 0) {
} this.active = false
}, }
onMouseDown() { if (this.active) {
this.active = true; let offset = 0
this.hasMoved = false; let target = e.currentTarget
}, if (this.split === 'vertical') {
onMouseUp() { while (target) {
this.active = false; offset += target.offsetLeft
}, target = target.offsetParent
onMouseMove(e) {
if (e.buttons === 0 || e.which === 0) {
this.active = false;
}
if (this.active) {
let offset = 0;
let target = e.currentTarget;
if (this.split === 'vertical') {
while (target) {
offset += target.offsetLeft;
target = target.offsetParent;
}
} else {
while (target) {
offset += target.offsetTop;
target = target.offsetParent;
}
} }
} else {
const currentPage = this.split === 'vertical' ? e.pageX : e.pageY; while (target) {
const targetOffset = this.split === 'vertical' ? e.currentTarget.offsetWidth : e.currentTarget.offsetHeight; offset += target.offsetTop
const percent = Math.floor(((currentPage - offset) / targetOffset) * 10000) / 100; target = target.offsetParent
if (percent > this.margin && percent < 100 - this.margin) {
this.percent = percent;
} }
this.$emit('resize');
this.hasMoved = true;
} }
const currentPage = this.split === 'vertical' ? e.pageX : e.pageY
const targetOffset = this.split === 'vertical' ? e.currentTarget.offsetWidth : e.currentTarget.offsetHeight
const percent = Math.floor(((currentPage - offset) / targetOffset) * 10000) / 100
if (percent > this.margin && percent < 100 - this.margin) {
this.percent = percent
}
this.$emit('resize')
this.hasMoved = true
} }
} }
} }
}
</script> </script>
<style scoped> <style scoped>
......
...@@ -9,66 +9,66 @@ ...@@ -9,66 +9,66 @@
</template> </template>
<script> <script>
export default { export default {
name: 'Sticky', name: 'Sticky',
props: { props: {
stickyTop: { stickyTop: {
type: Number, type: Number,
default: 0 default: 0
},
zIndex: {
type: Number,
default: 1
},
className: {
type: String
}
}, },
data() { zIndex: {
return { type: Number,
active: false, default: 1
position: '',
currentTop: '',
width: undefined,
height: undefined,
child: null,
stickyHeight: 0
};
}, },
methods: { className: {
sticky() { type: String
if (this.active) { }
return },
} data() {
this.position = 'fixed'; return {
this.active = true; active: false,
this.width = this.width + 'px'; position: '',
}, currentTop: '',
reset() { width: undefined,
if (!this.active) { height: undefined,
return child: null,
} stickyHeight: 0
this.position = '';
this.width = 'auto' }
this.active = false },
}, methods: {
handleScroll() { sticky() {
this.width = this.$el.getBoundingClientRect().width; if (this.active) {
const offsetTop = this.$el.getBoundingClientRect().top; return
if (offsetTop <= this.stickyTop) {
this.sticky();
return
}
this.reset()
} }
this.position = 'fixed'
this.active = true
this.width = this.width + 'px'
}, },
mounted() { reset() {
this.height = this.$el.getBoundingClientRect().height; if (!this.active) {
window.addEventListener('scroll', this.handleScroll); return
}
this.position = ''
this.width = 'auto'
this.active = false
}, },
destroyed() { handleScroll() {
window.removeEventListener('scroll', this.handleScroll); this.width = this.$el.getBoundingClientRect().width
const offsetTop = this.$el.getBoundingClientRect().top
if (offsetTop <= this.stickyTop) {
this.sticky()
return
}
this.reset()
} }
}; },
mounted() {
this.height = this.$el.getBoundingClientRect().height
window.addEventListener('scroll', this.handleScroll)
},
destroyed() {
window.removeEventListener('scroll', this.handleScroll)
}
}
</script> </script>
...@@ -5,80 +5,79 @@ ...@@ -5,80 +5,79 @@
</template> </template>
<script> <script>
// import { getToken, upload } from 'api/qiniu'; // 七牛 export default {
export default { name: 'tinymce',
name: 'tinymce', props: {
props: { id: {
id: { type: String,
type: String, default: 'tinymceEditor'
default: 'tinymceEditor' },
}, value: {
value: { type: String,
type: String, default: ''
default: '' },
}, toolbar: {
toolbar: { type: Array,
type: Array, required: false,
required: false, default() {
default() { return ['removeformat undo redo | bullist numlist | outdent indent | forecolor | fullscreen code', 'bold italic blockquote | h2 p media link | alignleft aligncenter alignright']
return ['removeformat undo redo | bullist numlist | outdent indent | forecolor | fullscreen code', 'bold italic blockquote | h2 p media link | alignleft aligncenter alignright'] }
} },
}, data() {
data() { return {
return { hasChange: false,
hasChange: false, hasInit: false
hasInit: false }
} },
}, menubar: {
menubar: { default: ''
default: '' },
}, height: {
height: { type: Number,
type: Number, required: false,
required: false, default: 360
default: 360 }
} },
}, watch: {
watch: { value(val) {
value(val) { if (!this.hasChange && this.hasInit) {
if (!this.hasChange && this.hasInit) { this.$nextTick(() => window.tinymce.get(this.id).setContent(val))
this.$nextTick(() => tinymce.get(this.id).setContent(val)) }
} }
} },
}, mounted() {
mounted() { const _this = this
const _this = this; window.tinymce.init({
tinymce.init({ selector: `#${this.id}`,
selector: `#${this.id}`, height: this.height,
height: this.height, body_class: 'panel-body ',
body_class: 'panel-body ', object_resizing: false,
object_resizing: false,
// language: 'zh_CN', // language: 'zh_CN',
// language_url: '/static/tinymce/langs/zh_CN.js', // language_url: '/static/tinymce/langs/zh_CN.js',
toolbar: this.toolbar, toolbar: this.toolbar,
menubar: this.menubar, menubar: this.menubar,
plugins: 'advlist,autolink,code,paste,textcolor, colorpicker,fullscreen,link,lists,media,wordcount, imagetools,watermark', plugins: 'advlist,autolink,code,paste,textcolor, colorpicker,fullscreen,link,lists,media,wordcount, imagetools,watermark',
end_container_on_empty_block: true, end_container_on_empty_block: true,
powerpaste_word_import: 'clean', powerpaste_word_import: 'clean',
code_dialog_height: 450, code_dialog_height: 450,
code_dialog_width: 1000, code_dialog_width: 1000,
advlist_bullet_styles: 'square', advlist_bullet_styles: 'square',
advlist_number_styles: 'default', advlist_number_styles: 'default',
block_formats: '普通标签=p;小标题=h2;', block_formats: '普通标签=p;小标题=h2;',
imagetools_cors_hosts: ['wpimg.wallstcn.com', 'wallstreetcn.com'], imagetools_cors_hosts: ['wpimg.wallstcn.com', 'wallstreetcn.com'],
imagetools_toolbar: 'watermark', imagetools_toolbar: 'watermark',
default_link_target: '_blank', default_link_target: '_blank',
link_title: false, link_title: false,
init_instance_callback: editor => { init_instance_callback: editor => {
if (_this.value) { if (_this.value) {
editor.setContent(_this.value) editor.setContent(_this.value)
} }
_this.hasInit = true; _this.hasInit = true
editor.on('NodeChange Change KeyUp', () => { editor.on('NodeChange Change KeyUp', () => {
this.hasChange = true; this.hasChange = true
this.$emit('input', editor.getContent({ format: 'raw' })); this.$emit('input', editor.getContent({ format: 'raw' }))
}); })
}, },
// 整合七牛上传 // 整合七牛上传
// images_dataimg_filter(img) { // images_dataimg_filter(img) {
// setTimeout(() => { // setTimeout(() => {
...@@ -112,44 +111,44 @@ ...@@ -112,44 +111,44 @@
// console.log(err); // console.log(err);
// }); // });
// }, // },
setup(editor) { setup(editor) {
editor.addButton('h2', { editor.addButton('h2', {
title: '小标题', // tooltip text seen on mouseover title: '小标题', // tooltip text seen on mouseover
text: '小标题', text: '小标题',
onclick() { onclick() {
editor.execCommand('mceToggleFormat', false, 'h2'); editor.execCommand('mceToggleFormat', false, 'h2')
}, },
onPostRender() { onPostRender() {
const btn = this; const btn = this
editor.on('init', () => { editor.on('init', () => {
editor.formatter.formatChanged('h2', state => { editor.formatter.formatChanged('h2', state => {
btn.active(state); btn.active(state)
}); })
}); })
} }
}); })
editor.addButton('p', { editor.addButton('p', {
title: '正文', title: '正文',
text: '正文', text: '正文',
onclick() { onclick() {
editor.execCommand('mceToggleFormat', false, 'p'); editor.execCommand('mceToggleFormat', false, 'p')
}, },
onPostRender() { onPostRender() {
const btn = this; const btn = this
editor.on('init', () => { editor.on('init', () => {
editor.formatter.formatChanged('p', state => { editor.formatter.formatChanged('p', state => {
btn.active(state); btn.active(state)
}); })
}); })
} }
}); })
} }
}); })
}, },
destroyed() { destroyed() {
tinymce.get(this.id).destroy(); window.tinymce.get(this.id).destroy()
}
} }
}
</script> </script>
<style scoped> <style scoped>
......
...@@ -84,12 +84,10 @@ export default { ...@@ -84,12 +84,10 @@ export default {
this.setLocalStorgae() this.setLocalStorgae()
}, },
deleteTodo(todo) { deleteTodo(todo) {
console.log(todo)
this.todos.splice(this.todos.indexOf(todo), 1) this.todos.splice(this.todos.indexOf(todo), 1)
this.setLocalStorgae() this.setLocalStorgae()
}, },
editTodo({ todo, value }) { editTodo({ todo, value }) {
console.log(todo, value)
todo.text = value todo.text = value
this.setLocalStorgae() this.setLocalStorgae()
}, },
......
...@@ -17,52 +17,53 @@ ...@@ -17,52 +17,53 @@
</template> </template>
<script> <script>
// 预览效果见付费文章 // 预览效果见付费文章
import { getToken } from 'api/qiniu'; import { getToken } from 'api/qiniu'
export default {
name: 'singleImageUpload', export default {
props: { name: 'singleImageUpload',
value: String props: {
value: String
}, },
computed: { computed: {
imageUrl() { imageUrl() {
return this.value return this.value
} }
}, },
data() { data() {
return { return {
tempUrl: '', tempUrl: '',
dataObj: { token: '', key: '' } dataObj: { token: '', key: '' }
}; }
}, },
methods: { methods: {
rmImage() { rmImage() {
this.emitInput(''); this.emitInput('')
}, },
emitInput(val) { emitInput(val) {
this.$emit('input', val); this.$emit('input', val)
}, },
handleImageScucess() { handleImageScucess() {
this.emitInput(this.tempUrl) this.emitInput(this.tempUrl)
}, },
beforeUpload() { beforeUpload() {
const _self = this; const _self = this
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
getToken().then(response => { getToken().then(response => {
const key = response.data.qiniu_key; const key = response.data.qiniu_key
const token = response.data.qiniu_token; const token = response.data.qiniu_token
_self._data.dataObj.token = token; _self._data.dataObj.token = token
_self._data.dataObj.key = key; _self._data.dataObj.key = key
this.tempUrl = response.data.qiniu_url; this.tempUrl = response.data.qiniu_url
resolve(true); resolve(true)
}).catch(err => { }).catch(err => {
console.log(err); console.log(err)
reject(false) reject(false)
}); })
}); })
} }
} }
}; }
</script> </script>
<style rel="stylesheet/scss" lang="scss" scoped> <style rel="stylesheet/scss" lang="scss" scoped>
......
...@@ -18,8 +18,8 @@ ...@@ -18,8 +18,8 @@
<script> <script>
// 预览效果见专题 // 预览效果见专题
import { getToken } from 'api/qiniu'; import { getToken } from 'api/qiniu'
export default { export default {
name: 'singleImageUpload2', name: 'singleImageUpload2',
props: { props: {
value: String value: String
...@@ -33,36 +33,35 @@ ...@@ -33,36 +33,35 @@
return { return {
tempUrl: '', tempUrl: '',
dataObj: { token: '', key: '' } dataObj: { token: '', key: '' }
}; }
}, },
methods: { methods: {
rmImage() { rmImage() {
this.emitInput(''); this.emitInput('')
}, },
emitInput(val) { emitInput(val) {
this.$emit('input', val); this.$emit('input', val)
}, },
handleImageScucess() { handleImageScucess() {
this.emitInput(this.tempUrl) this.emitInput(this.tempUrl)
}, },
beforeUpload() { beforeUpload() {
const _self = this; const _self = this
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
getToken().then(response => { getToken().then(response => {
const key = response.data.qiniu_key; const key = response.data.qiniu_key
const token = response.data.qiniu_token; const token = response.data.qiniu_token
_self._data.dataObj.token = token; _self._data.dataObj.token = token
_self._data.dataObj.key = key; _self._data.dataObj.key = key
this.tempUrl = response.data.qiniu_url; this.tempUrl = response.data.qiniu_url
resolve(true); resolve(true)
}).catch(err => { }).catch(() => {
console.log(err); reject(false)
reject(false) })
}); })
});
} }
} }
}; }
</script> </script>
<style rel="stylesheet/scss" lang="scss" scoped> <style rel="stylesheet/scss" lang="scss" scoped>
......
...@@ -27,8 +27,8 @@ ...@@ -27,8 +27,8 @@
<script> <script>
// 预览效果见文章 // 预览效果见文章
import { getToken } from 'api/qiniu'; import { getToken } from 'api/qiniu'
export default { export default {
name: 'singleImageUpload', name: 'singleImageUpload',
props: { props: {
value: String value: String
...@@ -42,36 +42,36 @@ ...@@ -42,36 +42,36 @@
return { return {
tempUrl: '', tempUrl: '',
dataObj: { token: '', key: '' } dataObj: { token: '', key: '' }
}; }
}, },
methods: { methods: {
rmImage() { rmImage() {
this.emitInput(''); this.emitInput('')
}, },
emitInput(val) { emitInput(val) {
this.$emit('input', val); this.$emit('input', val)
}, },
handleImageScucess(file) { handleImageScucess(file) {
this.emitInput(file.files.file) this.emitInput(file.files.file)
}, },
beforeUpload() { beforeUpload() {
const _self = this; const _self = this
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
getToken().then(response => { getToken().then(response => {
const key = response.data.qiniu_key; const key = response.data.qiniu_key
const token = response.data.qiniu_token; const token = response.data.qiniu_token
_self._data.dataObj.token = token; _self._data.dataObj.token = token
_self._data.dataObj.key = key; _self._data.dataObj.key = key
this.tempUrl = response.data.qiniu_url; this.tempUrl = response.data.qiniu_url
resolve(true); resolve(true)
}).catch(err => { }).catch(err => {
console.log(err); console.log(err)
reject(false) reject(false)
}); })
}); })
} }
} }
}; }
</script> </script>
<style rel="stylesheet/scss" lang="scss" scoped> <style rel="stylesheet/scss" lang="scss" scoped>
......
...@@ -5,52 +5,52 @@ ...@@ -5,52 +5,52 @@
</template> </template>
<script> <script>
import CodeMirror from 'codemirror'; import CodeMirror from 'codemirror'
import 'codemirror/addon/lint/lint.css'; import 'codemirror/addon/lint/lint.css'
import 'codemirror/lib/codemirror.css'; import 'codemirror/lib/codemirror.css'
import 'codemirror/theme/rubyblue.css'; import 'codemirror/theme/rubyblue.css'
require('script-loader!jsonlint'); require('script-loader!jsonlint')
import 'codemirror/mode/javascript/javascript' import 'codemirror/mode/javascript/javascript'
import 'codemirror/addon/lint/lint' import 'codemirror/addon/lint/lint'
import 'codemirror/addon/lint/json-lint'; import 'codemirror/addon/lint/json-lint'
export default { export default {
name: 'jsonEditor', name: 'jsonEditor',
data() { data() {
return { return {
jsonEditor: false jsonEditor: false
} }
}, },
props: ['value'], props: ['value'],
watch: { watch: {
value(value) { value(value) {
const editor_value = this.jsonEditor.getValue(); const editor_value = this.jsonEditor.getValue()
if (value !== editor_value) { if (value !== editor_value) {
this.jsonEditor.setValue(JSON.stringify(this.value, null, 2)); this.jsonEditor.setValue(JSON.stringify(this.value, null, 2))
}
} }
}, }
mounted() { },
this.jsonEditor = CodeMirror.fromTextArea(this.$refs.textarea, { mounted() {
lineNumbers: true, this.jsonEditor = CodeMirror.fromTextArea(this.$refs.textarea, {
mode: 'application/json', lineNumbers: true,
gutters: ['CodeMirror-lint-markers'], mode: 'application/json',
theme: 'rubyblue', gutters: ['CodeMirror-lint-markers'],
lint: true theme: 'rubyblue',
}); lint: true
})
this.jsonEditor.setValue(JSON.stringify(this.value, null, 2)); this.jsonEditor.setValue(JSON.stringify(this.value, null, 2))
this.jsonEditor.on('change', cm => { this.jsonEditor.on('change', cm => {
this.$emit('changed', cm.getValue()) this.$emit('changed', cm.getValue())
this.$emit('input', cm.getValue()) this.$emit('input', cm.getValue())
}) })
}, },
methods: { methods: {
getValue() { getValue() {
return this.jsonEditor.getValue() return this.jsonEditor.getValue()
}
} }
} }
}
</script> </script>
<style> <style>
......
...@@ -26,74 +26,74 @@ ...@@ -26,74 +26,74 @@
</template> </template>
<script> <script>
import draggable from 'vuedraggable' import draggable from 'vuedraggable'
export default { export default {
name: 'twoDndList', name: 'twoDndList',
components: { draggable }, components: { draggable },
computed: { computed: {
filterList2() { filterList2() {
return this.list2.filter(v => { return this.list2.filter(v => {
if (this.isNotInList1(v)) { if (this.isNotInList1(v)) {
return v return v
} }
return false; return false
}) })
}
},
props: {
list1: {
type: Array,
default() {
return []
} }
}, },
props: { list2: {
list1: { type: Array,
type: Array, default() {
default() { return []
return []
}
},
list2: {
type: Array,
default() {
return []
}
},
list1Title: {
type: String,
default: 'list1'
},
list2Title: {
type: String,
default: 'list2'
},
width1: {
type: String,
default: '48%'
},
width2: {
type: String,
default: '48%'
} }
}, },
methods: { list1Title: {
isNotInList1(v) { type: String,
return this.list1.every(k => v.id !== k.id) default: 'list1'
}, },
isNotInList2(v) { list2Title: {
return this.list2.every(k => v.id !== k.id) type: String,
}, default: 'list2'
deleteEle(ele) { },
for (const item of this.list1) { width1: {
if (item.id === ele.id) { type: String,
const index = this.list1.indexOf(item); default: '48%'
this.list1.splice(index, 1) },
break width2: {
} type: String,
} default: '48%'
if (this.isNotInList2(ele)) { }
this.list2.unshift(ele) },
methods: {
isNotInList1(v) {
return this.list1.every(k => v.id !== k.id)
},
isNotInList2(v) {
return this.list2.every(k => v.id !== k.id)
},
deleteEle(ele) {
for (const item of this.list1) {
if (item.id === ele.id) {
const index = this.list1.indexOf(item)
this.list1.splice(index, 1)
break
} }
},
pushEle(ele) {
this.list1.push(ele)
} }
if (this.isNotInList2(ele)) {
this.list2.unshift(ele)
}
},
pushEle(ele) {
this.list1.push(ele)
} }
} }
}
</script> </script>
<style rel="stylesheet/scss" lang="scss" scoped> <style rel="stylesheet/scss" lang="scss" scoped>
......
const vueSticky = {}; const vueSticky = {}
let listenAction; let listenAction
vueSticky.install = Vue => { vueSticky.install = Vue => {
Vue.directive('sticky', { Vue.directive('sticky', {
inserted(el, binding) { inserted(el, binding) {
const params = binding.value || {}, const params = binding.value || {}
stickyTop = params.stickyTop || 0, const stickyTop = params.stickyTop || 0
zIndex = params.zIndex || 1000, const zIndex = params.zIndex || 1000
elStyle = el.style; const elStyle = el.style
elStyle.position = '-webkit-sticky'; elStyle.position = '-webkit-sticky'
elStyle.position = 'sticky'; elStyle.position = 'sticky'
// if the browser support css sticky(Currently Safari, Firefox and Chrome Canary) // if the browser support css sticky(Currently Safari, Firefox and Chrome Canary)
// if (~elStyle.position.indexOf('sticky')) { // if (~elStyle.position.indexOf('sticky')) {
// elStyle.top = `${stickyTop}px`; // elStyle.top = `${stickyTop}px`;
// elStyle.zIndex = zIndex; // elStyle.zIndex = zIndex;
// return // return
// } // }
const elHeight = el.getBoundingClientRect().height; const elHeight = el.getBoundingClientRect().height
const elWidth = el.getBoundingClientRect().width; const elWidth = el.getBoundingClientRect().width
elStyle.cssText = `top: ${stickyTop}px; z-index: ${zIndex}`; elStyle.cssText = `top: ${stickyTop}px; z-index: ${zIndex}`
const parentElm = el.parentNode || document.documentElement; const parentElm = el.parentNode || document.documentElement
const placeholder = document.createElement('div'); const placeholder = document.createElement('div')
placeholder.style.display = 'none'; placeholder.style.display = 'none'
placeholder.style.width = `${elWidth}px`; placeholder.style.width = `${elWidth}px`
placeholder.style.height = `${elHeight}px`; placeholder.style.height = `${elHeight}px`
parentElm.insertBefore(placeholder, el) parentElm.insertBefore(placeholder, el)
let active = false; let active = false
const getScroll = (target, top) => { const getScroll = (target, top) => {
const prop = top ? 'pageYOffset' : 'pageXOffset'; const prop = top ? 'pageYOffset' : 'pageXOffset'
const method = top ? 'scrollTop' : 'scrollLeft'; const method = top ? 'scrollTop' : 'scrollLeft'
let ret = target[prop]; let ret = target[prop]
if (typeof ret !== 'number') { if (typeof ret !== 'number') {
ret = window.document.documentElement[method]; ret = window.document.documentElement[method]
} }
return ret; return ret
}; }
const sticky = () => { const sticky = () => {
if (active) { if (active) {
...@@ -47,36 +47,36 @@ vueSticky.install = Vue => { ...@@ -47,36 +47,36 @@ vueSticky.install = Vue => {
elStyle.height = `${el.offsetHeight}px` elStyle.height = `${el.offsetHeight}px`
} }
elStyle.position = 'fixed'; elStyle.position = 'fixed'
elStyle.width = `${elWidth}px`; elStyle.width = `${elWidth}px`
placeholder.style.display = 'inline-block'; placeholder.style.display = 'inline-block'
active = true active = true
}; }
const reset = () => { const reset = () => {
if (!active) { if (!active) {
return return
} }
elStyle.position = ''; elStyle.position = ''
placeholder.style.display = 'none'; placeholder.style.display = 'none'
active = false; active = false
}; }
const check = () => { const check = () => {
const scrollTop = getScroll(window, true); const scrollTop = getScroll(window, true)
const offsetTop = el.getBoundingClientRect().top; const offsetTop = el.getBoundingClientRect().top
if (offsetTop < stickyTop) { if (offsetTop < stickyTop) {
sticky(); sticky()
} else { } else {
if (scrollTop < elHeight + stickyTop) { if (scrollTop < elHeight + stickyTop) {
reset() reset()
} }
} }
}; }
listenAction = () => { listenAction = () => {
check() check()
}; }
window.addEventListener('scroll', listenAction) window.addEventListener('scroll', listenAction)
}, },
...@@ -85,7 +85,7 @@ vueSticky.install = Vue => { ...@@ -85,7 +85,7 @@ vueSticky.install = Vue => {
window.removeEventListener('scroll', listenAction) window.removeEventListener('scroll', listenAction)
} }
}) })
}; }
export default vueSticky export default vueSticky
import './waves.css'; import './waves.css'
export default{ export default{
bind(el, binding) { bind(el, binding) {
el.addEventListener('click', e => { el.addEventListener('click', e => {
const customOpts = Object.assign({}, binding.value); const customOpts = Object.assign({}, binding.value)
const opts = Object.assign({ const opts = Object.assign({
ele: el, // 波纹作用元素 ele: el, // 波纹作用元素
type: 'hit', // hit点击位置扩散center中心点扩展 type: 'hit', // hit点击位置扩散center中心点扩展
color: 'rgba(0, 0, 0, 0.15)' // 波纹颜色 color: 'rgba(0, 0, 0, 0.15)' // 波纹颜色
}, customOpts), }, customOpts)
target = opts.ele; const target = opts.ele
if (target) { if (target) {
target.style.position = 'relative'; target.style.position = 'relative'
target.style.overflow = 'hidden'; target.style.overflow = 'hidden'
const rect = target.getBoundingClientRect(); const rect = target.getBoundingClientRect()
let ripple = target.querySelector('.waves-ripple'); let ripple = target.querySelector('.waves-ripple')
if (!ripple) { if (!ripple) {
ripple = document.createElement('span'); ripple = document.createElement('span')
ripple.className = 'waves-ripple'; ripple.className = 'waves-ripple'
ripple.style.height = ripple.style.width = Math.max(rect.width, rect.height) + 'px'; ripple.style.height = ripple.style.width = Math.max(rect.width, rect.height) + 'px'
target.appendChild(ripple); target.appendChild(ripple)
} else { } else {
ripple.className = 'waves-ripple'; ripple.className = 'waves-ripple'
} }
switch (opts.type) { switch (opts.type) {
case 'center': case 'center':
ripple.style.top = (rect.height / 2 - ripple.offsetHeight / 2) + 'px'; ripple.style.top = (rect.height / 2 - ripple.offsetHeight / 2) + 'px'
ripple.style.left = (rect.width / 2 - ripple.offsetWidth / 2) + 'px'; ripple.style.left = (rect.width / 2 - ripple.offsetWidth / 2) + 'px'
break; break
default: default:
ripple.style.top = (e.pageY - rect.top - ripple.offsetHeight / 2 - document.body.scrollTop) + 'px'; ripple.style.top = (e.pageY - rect.top - ripple.offsetHeight / 2 - document.body.scrollTop) + 'px'
ripple.style.left = (e.pageX - rect.left - ripple.offsetWidth / 2 - document.body.scrollLeft) + 'px'; ripple.style.left = (e.pageX - rect.left - ripple.offsetWidth / 2 - document.body.scrollLeft) + 'px'
} }
ripple.style.backgroundColor = opts.color; ripple.style.backgroundColor = opts.color
ripple.className = 'waves-ripple z-active'; ripple.className = 'waves-ripple z-active'
return false; return false
} }
}, false); }, false)
} }
} }
...@@ -4,11 +4,11 @@ import errLog from '@/store/errLog' ...@@ -4,11 +4,11 @@ import errLog from '@/store/errLog'
// 生产环境错误日志 // 生产环境错误日志
if (process.env.NODE_ENV === 'production') { if (process.env.NODE_ENV === 'production') {
Vue.config.errorHandler = function(err, vm) { Vue.config.errorHandler = function(err, vm) {
console.log(err, window.location.href); console.log(err, window.location.href)
errLog.pushLog({ errLog.pushLog({
err, err,
url: window.location.href, url: window.location.href,
vm vm
}) })
}; }
} }
...@@ -5,7 +5,7 @@ function pluralize(time, label) { ...@@ -5,7 +5,7 @@ function pluralize(time, label) {
return time + label + 's' return time + label + 's'
} }
export function timeAgo(time) { export function timeAgo(time) {
const between = Date.now() / 1000 - Number(time); const between = Date.now() / 1000 - Number(time)
if (between < 3600) { if (between < 3600) {
return pluralize(~~(between / 60), ' minute') return pluralize(~~(between / 60), ' minute')
} else if (between < 86400) { } else if (between < 86400) {
...@@ -17,19 +17,19 @@ export function timeAgo(time) { ...@@ -17,19 +17,19 @@ export function timeAgo(time) {
export function parseTime(time, cFormat) { export function parseTime(time, cFormat) {
if (arguments.length === 0) { if (arguments.length === 0) {
return null; return null
} }
if ((time + '').length === 10) { if ((time + '').length === 10) {
time = +time * 1000 time = +time * 1000
} }
const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}'; const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}'
let date; let date
if (typeof time == 'object') { if (typeof time === 'object') {
date = time; date = time
} else { } else {
date = new Date(parseInt(time)); date = new Date(parseInt(time))
} }
const formatObj = { const formatObj = {
y: date.getFullYear(), y: date.getFullYear(),
...@@ -39,24 +39,24 @@ export function parseTime(time, cFormat) { ...@@ -39,24 +39,24 @@ export function parseTime(time, cFormat) {
i: date.getMinutes(), i: date.getMinutes(),
s: date.getSeconds(), s: date.getSeconds(),
a: date.getDay() a: date.getDay()
}; }
const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => { const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => {
let value = formatObj[key]; let value = formatObj[key]
if (key === 'a') return ['一', '二', '三', '四', '五', '六', '日'][value - 1]; if (key === 'a') return ['一', '二', '三', '四', '五', '六', '日'][value - 1]
if (result.length > 0 && value < 10) { if (result.length > 0 && value < 10) {
value = '0' + value; value = '0' + value
} }
return value || 0; return value || 0
}); })
return time_str; return time_str
} }
export function formatTime(time, option) { export function formatTime(time, option) {
time = +time * 1000; time = +time * 1000
const d = new Date(time); const d = new Date(time)
const now = Date.now(); const now = Date.now()
const diff = (now - d) / 1000; const diff = (now - d) / 1000
if (diff < 30) { if (diff < 30) {
return '刚刚' return '刚刚'
...@@ -83,21 +83,21 @@ export function nFormatter(num, digits) { ...@@ -83,21 +83,21 @@ export function nFormatter(num, digits) {
{ value: 1E9, symbol: 'G' }, { value: 1E9, symbol: 'G' },
{ value: 1E6, symbol: 'M' }, { value: 1E6, symbol: 'M' },
{ value: 1E3, symbol: 'k' } { value: 1E3, symbol: 'k' }
]; ]
for (let i = 0; i < si.length; i++) { for (let i = 0; i < si.length; i++) {
if (num >= si[i].value) { if (num >= si[i].value) {
return (num / si[i].value + 0.1).toFixed(digits).replace(/\.0+$|(\.[0-9]*[1-9])0+$/, '$1') + si[i].symbol; return (num / si[i].value + 0.1).toFixed(digits).replace(/\.0+$|(\.[0-9]*[1-9])0+$/, '$1') + si[i].symbol
} }
} }
return num.toString(); return num.toString()
} }
export function html2Text(val) { export function html2Text(val) {
const div = document.createElement('div'); const div = document.createElement('div')
div.innerHTML = val; div.innerHTML = val
return div.textContent || div.innerText; return div.textContent || div.innerText
} }
export function toThousandslsFilter(num) { export function toThousandslsFilter(num) {
return (+num || 0).toString().replace(/^-?\d+/g, m => m.replace(/(?=(?!\b)(\d{3})+$)/g, ',')); return (+num || 0).toString().replace(/^-?\d+/g, m => m.replace(/(?=(?!\b)(\d{3})+$)/g, ','))
} }
...@@ -29,5 +29,3 @@ new Vue({ ...@@ -29,5 +29,3 @@ new Vue({
template: '<App/>', template: '<App/>',
components: { App } components: { App }
}) })
import Mock from 'mockjs'; import Mock from 'mockjs'
const List = [];
const count = 20;
const List = []
const count = 20
for (let i = 0; i < count; i++) { for (let i = 0; i < count; i++) {
List.push(Mock.mock({ List.push(Mock.mock({
...@@ -13,7 +11,7 @@ for (let i = 0; i < count; i++) { ...@@ -13,7 +11,7 @@ for (let i = 0; i < count; i++) {
author: '@cname', author: '@cname',
display_time: '@datetime', display_time: '@datetime',
pageviews: '@integer(300, 5000)' pageviews: '@integer(300, 5000)'
})); }))
} }
export default { export default {
...@@ -34,4 +32,4 @@ export default { ...@@ -34,4 +32,4 @@ export default {
tags: [], tags: [],
title: '' title: ''
}) })
}; }
import Mock from 'mockjs'; import Mock from 'mockjs'
import { param2Obj } from 'utils'; import { param2Obj } from 'utils'
const List = []; const List = []
const count = 100; const count = 100
for (let i = 0; i < count; i++) { for (let i = 0; i < count; i++) {
List.push(Mock.mock({ List.push(Mock.mock({
...@@ -16,23 +16,23 @@ for (let i = 0; i < count; i++) { ...@@ -16,23 +16,23 @@ for (let i = 0; i < count; i++) {
'type|1': ['CN', 'US', 'JP', 'EU'], 'type|1': ['CN', 'US', 'JP', 'EU'],
'status|1': ['published', 'draft', 'deleted'], 'status|1': ['published', 'draft', 'deleted'],
pageviews: '@integer(300, 5000)' pageviews: '@integer(300, 5000)'
})); }))
} }
export default { export default {
getList: config => { getList: config => {
const { importance, type, title, page, limit, sort } = param2Obj(config.url); const { importance, type, title, page, limit, sort } = param2Obj(config.url)
let mockList = List.filter(item => { let mockList = List.filter(item => {
if (importance && item.importance !== +importance) return false; if (importance && item.importance !== +importance) return false
if (type && item.type !== type) return false; if (type && item.type !== type) return false
if (title && item.title.indexOf(title) < 0) return false; if (title && item.title.indexOf(title) < 0) return false
return true; return true
}); })
if (sort === '-id') { if (sort === '-id') {
mockList = mockList.reverse() mockList = mockList.reverse()
} }
const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1)); const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1))
return { return {
total: mockList.length, total: mockList.length,
items: pageList items: pageList
...@@ -41,4 +41,4 @@ export default { ...@@ -41,4 +41,4 @@ export default {
getPv: () => ({ getPv: () => ({
pvData: [{ key: 'PC网站', pv: 1024 }, { key: 'mobile网站', pv: 1024 }, { key: 'ios', pv: 1024 }, { key: 'android', pv: 1024 }] pvData: [{ key: 'PC网站', pv: 1024 }, { key: 'mobile网站', pv: 1024 }, { key: 'ios', pv: 1024 }, { key: 'android', pv: 1024 }]
}) })
}; }
import { param2Obj } from 'utils'; import { param2Obj } from 'utils'
const userMap = { const userMap = {
admin: { admin: {
...@@ -26,16 +26,16 @@ const userMap = { ...@@ -26,16 +26,16 @@ const userMap = {
export default { export default {
loginByUsername: config => { loginByUsername: config => {
const { username } = JSON.parse(config.body); const { username } = JSON.parse(config.body)
return userMap[username]; return userMap[username]
}, },
getInfo: config => { getInfo: config => {
const { token } = param2Obj(config.url); const { token } = param2Obj(config.url)
if (userMap[token]) { if (userMap[token]) {
return userMap[token]; return userMap[token]
} else { } else {
return Promise.reject('error'); return Promise.reject('error')
} }
}, },
logout: () => 'success' logout: () => 'success'
}; }
import Mock from 'mockjs'; import Mock from 'mockjs'
import { param2Obj } from 'utils'; import { param2Obj } from 'utils'
const NameList = []; const NameList = []
const count = 100; const count = 100
for (let i = 0; i < count; i++) { for (let i = 0; i < count; i++) {
NameList.push(Mock.mock({ NameList.push(Mock.mock({
name: '@first' name: '@first'
})); }))
} }
NameList.push({ name: 'mockPan' }) NameList.push({ name: 'mockPan' })
export default { export default {
searchUser: config => { searchUser: config => {
const { name } = param2Obj(config.url); const { name } = param2Obj(config.url)
const mockNameList = NameList.filter(item => { const mockNameList = NameList.filter(item => {
const lowerCaseName = item.name.toLowerCase() const lowerCaseName = item.name.toLowerCase()
if (name && lowerCaseName.indexOf(name.toLowerCase()) < 0) return false; if (name && lowerCaseName.indexOf(name.toLowerCase()) < 0) return false
return true; return true
}); })
return { items: mockNameList } return { items: mockNameList }
} }
}; }
...@@ -36,7 +36,7 @@ router.beforeEach((to, from, next) => { ...@@ -36,7 +36,7 @@ router.beforeEach((to, from, next) => {
if (hasPermission(store.getters.roles, to.meta.role)) { if (hasPermission(store.getters.roles, to.meta.role)) {
next()// next()//
} else { } else {
next({ path: '/401', query: { noGoBack: true } }) next({ path: '/401', query: { noGoBack: true }})
} }
// 可删 ↑ // 可删 ↑
} }
......
import Vue from 'vue'; import Vue from 'vue'
import Router from 'vue-router'; import Router from 'vue-router'
const _import = require('./_import_' + process.env.NODE_ENV); const _import = require('./_import_' + process.env.NODE_ENV)
// in development env not use Lazy Loading,because Lazy Loading large page will cause webpack hot update too slow.so only in production use Lazy Loading // in development env not use Lazy Loading,because Lazy Loading large page will cause webpack hot update too slow.so only in production use Lazy Loading
Vue.use(Router); Vue.use(Router)
/* layout */ /* layout */
import Layout from '../views/layout/Layout'; import Layout from '../views/layout/Layout'
/** /**
* icon : the icon show in the sidebar * icon : the icon show in the sidebar
...@@ -42,7 +42,7 @@ export default new Router({ ...@@ -42,7 +42,7 @@ export default new Router({
// mode: 'history', //后端支持可开 // mode: 'history', //后端支持可开
scrollBehavior: () => ({ y: 0 }), scrollBehavior: () => ({ y: 0 }),
routes: constantRouterMap routes: constantRouterMap
}); })
export const asyncRouterMap = [ export const asyncRouterMap = [
{ {
...@@ -53,7 +53,7 @@ export const asyncRouterMap = [ ...@@ -53,7 +53,7 @@ export const asyncRouterMap = [
icon: 'quanxian', icon: 'quanxian',
meta: { role: ['admin'] }, meta: { role: ['admin'] },
noDropdown: true, noDropdown: true,
children: [{ path: 'index', component: _import('permission/index'), name: '权限测试页', meta: { role: ['admin'] } }] children: [{ path: 'index', component: _import('permission/index'), name: '权限测试页', meta: { role: ['admin'] }}]
}, },
{ {
path: '/components', path: '/components',
...@@ -110,7 +110,7 @@ export const asyncRouterMap = [ ...@@ -110,7 +110,7 @@ export const asyncRouterMap = [
{ path: 'table', component: _import('example/table/table'), name: '综合table' } { path: 'table', component: _import('example/table/table'), name: '综合table' }
] ]
}, },
{ path: 'form/edit', icon: 'ziliaoshouce', component: _import('example/form'), name: '编辑Form', meta: { isEdit: true } }, { path: 'form/edit', icon: 'ziliaoshouce', component: _import('example/form'), name: '编辑Form', meta: { isEdit: true }},
{ path: 'form/create', icon: 'yinhangqia', component: _import('example/form'), name: '创建Form' }, { path: 'form/create', icon: 'yinhangqia', component: _import('example/form'), name: '创建Form' },
{ path: 'tab/index', icon: 'mobankuangjia', component: _import('example/tab/index'), name: 'Tab' } { path: 'tab/index', icon: 'mobankuangjia', component: _import('example/tab/index'), name: 'Tab' }
...@@ -158,4 +158,4 @@ export const asyncRouterMap = [ ...@@ -158,4 +158,4 @@ export const asyncRouterMap = [
}, },
{ path: '*', redirect: '/404', hidden: true } { path: '*', redirect: '/404', hidden: true }
]; ]
...@@ -6,8 +6,8 @@ const errLog = { ...@@ -6,8 +6,8 @@ const errLog = {
this.state.errLog.unshift(log) this.state.errLog.unshift(log)
}, },
clearLog() { clearLog() {
this.state.errLog = []; this.state.errLog = []
} }
}; }
export default errLog; export default errLog
...@@ -10,5 +10,5 @@ const getters = { ...@@ -10,5 +10,5 @@ const getters = {
setting: state => state.user.setting, setting: state => state.user.setting,
permission_routers: state => state.permission.routers, permission_routers: state => state.permission.routers,
addRouters: state => state.permission.addRouters addRouters: state => state.permission.addRouters
}; }
export default getters export default getters
import Vue from 'vue'; import Vue from 'vue'
import Vuex from 'vuex'; import Vuex from 'vuex'
import app from './modules/app'; import app from './modules/app'
import user from './modules/user'; import user from './modules/user'
import permission from './modules/permission'; import permission from './modules/permission'
import getters from './getters'; import getters from './getters'
Vue.use(Vuex); Vue.use(Vuex)
const store = new Vuex.Store({ const store = new Vuex.Store({
modules: { modules: {
...@@ -14,6 +14,6 @@ const store = new Vuex.Store({ ...@@ -14,6 +14,6 @@ const store = new Vuex.Store({
permission permission
}, },
getters getters
}); })
export default store export default store
import Cookies from 'js-cookie'; import Cookies from 'js-cookie'
const app = { const app = {
state: { state: {
...@@ -12,11 +12,11 @@ const app = { ...@@ -12,11 +12,11 @@ const app = {
mutations: { mutations: {
TOGGLE_SIDEBAR: state => { TOGGLE_SIDEBAR: state => {
if (state.sidebar.opened) { if (state.sidebar.opened) {
Cookies.set('sidebarStatus', 1); Cookies.set('sidebarStatus', 1)
} else { } else {
Cookies.set('sidebarStatus', 0); Cookies.set('sidebarStatus', 0)
} }
state.sidebar.opened = !state.sidebar.opened; state.sidebar.opened = !state.sidebar.opened
}, },
ADD_VISITED_VIEWS: (state, view) => { ADD_VISITED_VIEWS: (state, view) => {
if (state.visitedViews.some(v => v.path === view.path)) return if (state.visitedViews.some(v => v.path === view.path)) return
...@@ -44,6 +44,6 @@ const app = { ...@@ -44,6 +44,6 @@ const app = {
commit('DEL_VISITED_VIEWS', view) commit('DEL_VISITED_VIEWS', view)
} }
} }
}; }
export default app; export default app
...@@ -52,11 +52,11 @@ const permission = { ...@@ -52,11 +52,11 @@ const permission = {
} else { } else {
accessedRouters = filterAsyncRouter(asyncRouterMap, roles) accessedRouters = filterAsyncRouter(asyncRouterMap, roles)
} }
commit('SET_ROUTERS', accessedRouters); commit('SET_ROUTERS', accessedRouters)
resolve(); resolve()
}) })
} }
} }
}; }
export default permission; export default permission
import { loginByUsername, logout, getInfo } from 'api/login'; import { loginByUsername, logout, getInfo } from 'api/login'
import { getToken, setToken, removeToken } from 'utils/auth'; import { getToken, setToken, removeToken } from 'utils/auth'
const user = { const user = {
state: { state: {
...@@ -18,110 +18,110 @@ const user = { ...@@ -18,110 +18,110 @@ const user = {
mutations: { mutations: {
SET_CODE: (state, code) => { SET_CODE: (state, code) => {
state.code = code; state.code = code
}, },
SET_TOKEN: (state, token) => { SET_TOKEN: (state, token) => {
state.token = token; state.token = token
}, },
SET_INTRODUCTION: (state, introduction) => { SET_INTRODUCTION: (state, introduction) => {
state.introduction = introduction; state.introduction = introduction
}, },
SET_SETTING: (state, setting) => { SET_SETTING: (state, setting) => {
state.setting = setting; state.setting = setting
}, },
SET_STATUS: (state, status) => { SET_STATUS: (state, status) => {
state.status = status; state.status = status
}, },
SET_NAME: (state, name) => { SET_NAME: (state, name) => {
state.name = name; state.name = name
}, },
SET_AVATAR: (state, avatar) => { SET_AVATAR: (state, avatar) => {
state.avatar = avatar; state.avatar = avatar
}, },
SET_ROLES: (state, roles) => { SET_ROLES: (state, roles) => {
state.roles = roles; state.roles = roles
} }
}, },
actions: { actions: {
// 用户名登录 // 用户名登录
LoginByUsername({ commit }, userInfo) { LoginByUsername({ commit }, userInfo) {
const username = userInfo.username.trim(); const username = userInfo.username.trim()
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
loginByUsername(username, userInfo.password).then(response => { loginByUsername(username, userInfo.password).then(response => {
const data = response.data; const data = response.data
setToken(response.data.token); setToken(response.data.token)
commit('SET_TOKEN', data.token); commit('SET_TOKEN', data.token)
resolve(); resolve()
}).catch(error => { }).catch(error => {
reject(error); reject(error)
}); })
}); })
}, },
// 获取用户信息 // 获取用户信息
GetInfo({ commit, state }) { GetInfo({ commit, state }) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
getInfo(state.token).then(response => { getInfo(state.token).then(response => {
const data = response.data; const data = response.data
commit('SET_ROLES', data.role); commit('SET_ROLES', data.role)
commit('SET_NAME', data.name); commit('SET_NAME', data.name)
commit('SET_AVATAR', data.avatar); commit('SET_AVATAR', data.avatar)
commit('SET_INTRODUCTION', data.introduction); commit('SET_INTRODUCTION', data.introduction)
resolve(response); resolve(response)
}).catch(error => { }).catch(error => {
reject(error); reject(error)
}); })
}); })
}, },
// 第三方验证登录 // 第三方验证登录
LoginByThirdparty({ commit, state }, code) { // LoginByThirdparty({ commit, state }, code) {
return new Promise((resolve, reject) => { // return new Promise((resolve, reject) => {
commit('SET_CODE', code); // commit('SET_CODE', code)
loginByThirdparty(state.status, state.email, state.code).then(response => { // loginByThirdparty(state.status, state.email, state.code).then(response => {
commit('SET_TOKEN', response.data.token); // commit('SET_TOKEN', response.data.token)
setToken(response.data.token); // setToken(response.data.token)
resolve(); // resolve()
}).catch(error => { // }).catch(error => {
reject(error); // reject(error)
}); // })
}); // })
}, // },
// 登出 // 登出
LogOut({ commit, state }) { LogOut({ commit, state }) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
logout(state.token).then(() => { logout(state.token).then(() => {
commit('SET_TOKEN', ''); commit('SET_TOKEN', '')
commit('SET_ROLES', []); commit('SET_ROLES', [])
removeToken(); removeToken()
resolve(); resolve()
}).catch(error => { }).catch(error => {
reject(error); reject(error)
}); })
}); })
}, },
// 前端 登出 // 前端 登出
FedLogOut({ commit }) { FedLogOut({ commit }) {
return new Promise(resolve => { return new Promise(resolve => {
commit('SET_TOKEN', ''); commit('SET_TOKEN', '')
removeToken(); removeToken()
resolve(); resolve()
}); })
}, },
// 动态修改权限 // 动态修改权限
ChangeRole({ commit }, role) { ChangeRole({ commit }, role) {
return new Promise(resolve => { return new Promise(resolve => {
commit('SET_ROLES', [role]); commit('SET_ROLES', [role])
commit('SET_TOKEN', role); commit('SET_TOKEN', role)
setToken(role); setToken(role)
resolve(); resolve()
}) })
} }
} }
}; }
export default user; export default user
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* Created by jiachenpan on 17/3/8. * Created by jiachenpan on 17/3/8.
*/ */
export default function createUniqueString() { export default function createUniqueString() {
const timestamp = +new Date() + ''; const timestamp = +new Date() + ''
const randomNum = parseInt((1 + Math.random()) * 65536) + ''; const randomNum = parseInt((1 + Math.random()) * 65536) + ''
return (+(randomNum + timestamp)).toString(32); return (+(randomNum + timestamp)).toString(32)
} }
import axios from 'axios'; import axios from 'axios'
import { Message } from 'element-ui'; import { Message } from 'element-ui'
import store from '../store'; import store from '../store'
import { getToken } from 'utils/auth'; import { getToken } from 'utils/auth'
// 创建axios实例 // 创建axios实例
const service = axios.create({ const service = axios.create({
baseURL: process.env.BASE_API, // api的base_url baseURL: process.env.BASE_API, // api的base_url
timeout: 5000 // 请求超时时间 timeout: 5000 // 请求超时时间
}); })
// request拦截器 // request拦截器
service.interceptors.request.use(config => { service.interceptors.request.use(config => {
// Do something before request is sent // Do something before request is sent
if (store.getters.token) { if (store.getters.token) {
config.headers['X-Token'] = getToken(); // 让每个请求携带token--['X-Token']为自定义key 请根据实际情况自行修改 config.headers['X-Token'] = getToken() // 让每个请求携带token--['X-Token']为自定义key 请根据实际情况自行修改
} }
return config; return config
}, error => { }, error => {
// Do something with request error // Do something with request error
console.log(error); // for debug console.log(error) // for debug
Promise.reject(error); Promise.reject(error)
}) })
// respone拦截器 // respone拦截器
...@@ -53,14 +53,14 @@ service.interceptors.response.use( ...@@ -53,14 +53,14 @@ service.interceptors.response.use(
// return response.data; // return response.data;
// } // }
error => { error => {
console.log('err' + error);// for debug console.log('err' + error)// for debug
Message({ Message({
message: error.message, message: error.message,
type: 'error', type: 'error',
duration: 5 * 1000 duration: 5 * 1000
}); })
return Promise.reject(error); return Promise.reject(error)
} }
) )
export default service; export default service
This diff is collapsed.
...@@ -8,20 +8,19 @@ ...@@ -8,20 +8,19 @@
export default function openWindow(url, title, w, h) { export default function openWindow(url, title, w, h) {
// Fixes dual-screen position Most browsers Firefox // Fixes dual-screen position Most browsers Firefox
const dualScreenLeft = window.screenLeft !== undefined ? window.screenLeft : screen.left; const dualScreenLeft = window.screenLeft !== undefined ? window.screenLeft : screen.left
const dualScreenTop = window.screenTop !== undefined ? window.screenTop : screen.top; const dualScreenTop = window.screenTop !== undefined ? window.screenTop : screen.top
const width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width; const width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width
const height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height; const height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height
const left = ((width / 2) - (w / 2)) + dualScreenLeft; const left = ((width / 2) - (w / 2)) + dualScreenLeft
const top = ((height / 2) - (h / 2)) + dualScreenTop; const top = ((height / 2) - (h / 2)) + dualScreenTop
const newWindow = window.open(url, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, copyhistory=no, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left); const newWindow = window.open(url, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, copyhistory=no, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left)
// Puts focus on the newWindow // Puts focus on the newWindow
if (window.focus) { if (window.focus) {
newWindow.focus(); newWindow.focus()
} }
} }
...@@ -5,19 +5,19 @@ ...@@ -5,19 +5,19 @@
/* 是否是公司邮箱*/ /* 是否是公司邮箱*/
export function isvalidUsername(str) { export function isvalidUsername(str) {
const valid_map = ['admin', 'editor'] const valid_map = ['admin', 'editor']
return valid_map.indexOf(str.trim()) >= 0; return valid_map.indexOf(str.trim()) >= 0
} }
/* 合法uri*/ /* 合法uri*/
export function validateURL(textval) { export function validateURL(textval) {
const urlregex = /^(https?|ftp):\/\/([a-zA-Z0-9.-]+(:[a-zA-Z0-9.&%$-]+)*@)*((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}|([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(:[0-9]+)*(\/($|[a-zA-Z0-9.,?'\\+&%$#=~_-]+))*$/; const urlregex = /^(https?|ftp):\/\/([a-zA-Z0-9.-]+(:[a-zA-Z0-9.&%$-]+)*@)*((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}|([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(:[0-9]+)*(\/($|[a-zA-Z0-9.,?'\\+&%$#=~_-]+))*$/
return urlregex.test(textval); return urlregex.test(textval)
} }
/* 小写字母*/ /* 小写字母*/
export function validateLowerCase(str) { export function validateLowerCase(str) {
const reg = /^[a-z]+$/; const reg = /^[a-z]+$/
return reg.test(str); return reg.test(str)
} }
/* 验证key*/ /* 验证key*/
...@@ -28,14 +28,13 @@ export function validateLowerCase(str) { ...@@ -28,14 +28,13 @@ export function validateLowerCase(str) {
/* 大写字母*/ /* 大写字母*/
export function validateUpperCase(str) { export function validateUpperCase(str) {
const reg = /^[A-Z]+$/; const reg = /^[A-Z]+$/
return reg.test(str); return reg.test(str)
} }
/* 大小写字母*/ /* 大小写字母*/
export function validatAlphabets(str) { export function validatAlphabets(str) {
const reg = /^[A-Za-z]+$/; const reg = /^[A-Za-z]+$/
return reg.test(str); return reg.test(str)
} }
...@@ -7,11 +7,11 @@ ...@@ -7,11 +7,11 @@
</template> </template>
<script> <script>
import keyboardChart from 'components/Charts/keyboard'; import keyboardChart from 'components/Charts/keyboard'
export default { export default {
components: { keyboardChart } components: { keyboardChart }
}; }
</script> </script>
<style scoped> <style scoped>
......
...@@ -7,11 +7,11 @@ ...@@ -7,11 +7,11 @@
</template> </template>
<script> <script>
import keyboardChart2 from 'components/Charts/keyboard2'; import keyboardChart2 from 'components/Charts/keyboard2'
export default { export default {
components: { keyboardChart2 } components: { keyboardChart2 }
}; }
</script> </script>
<style scoped> <style scoped>
......
...@@ -7,11 +7,11 @@ ...@@ -7,11 +7,11 @@
</template> </template>
<script> <script>
import lineMarker from 'components/Charts/lineMarker'; import lineMarker from 'components/Charts/lineMarker'
export default { export default {
components: { lineMarker } components: { lineMarker }
}; }
</script> </script>
<style scoped> <style scoped>
......
...@@ -7,11 +7,11 @@ ...@@ -7,11 +7,11 @@
</template> </template>
<script> <script>
import mixChart from 'components/Charts/mixChart'; import mixChart from 'components/Charts/mixChart'
export default { export default {
components: { mixChart } components: { mixChart }
}; }
</script> </script>
<style scoped> <style scoped>
......
...@@ -14,29 +14,29 @@ ...@@ -14,29 +14,29 @@
</template> </template>
<script> <script>
import ImageCropper from 'components/ImageCropper'; import ImageCropper from 'components/ImageCropper'
import PanThumb from 'components/PanThumb'; import PanThumb from 'components/PanThumb'
export default { export default {
components: { ImageCropper, PanThumb }, components: { ImageCropper, PanThumb },
data() { data() {
return { return {
imagecropperShow: false, imagecropperShow: false,
imagecropperKey: 0, imagecropperKey: 0,
image: 'https://wpimg.wallstcn.com/577965b9-bb9e-4e02-9f0c-095b41417191' image: 'https://wpimg.wallstcn.com/577965b9-bb9e-4e02-9f0c-095b41417191'
} }
},
methods: {
cropSuccess(resData) {
this.imagecropperShow = false
this.imagecropperKey = this.imagecropperKey + 1
this.image = resData.files.avatar
}, },
methods: { close() {
cropSuccess(resData) { this.imagecropperShow = false
this.imagecropperShow = false;
this.imagecropperKey = this.imagecropperKey + 1;
this.image = resData.files.avatar;
},
close() {
this.imagecropperShow = false;
}
} }
}; }
}
</script> </script>
<style scoped> <style scoped>
......
...@@ -135,21 +135,22 @@ ...@@ -135,21 +135,22 @@
</template> </template>
<script> <script>
import BackToTop from 'components/BackToTop'; import BackToTop from 'components/BackToTop'
export default {
components: { BackToTop }, export default {
data() { components: { BackToTop },
return { data() {
myBackToTopStyle: { return {
right: '50px', myBackToTopStyle: {
bottom: '50px', right: '50px',
width: '40px', bottom: '50px',
height: '40px', width: '40px',
'border-radius': '4px', height: '40px',
'line-height': '45px', // 请保持与高度一致以垂直居中 'border-radius': '4px',
background: '#e7eaf1'// 按钮的背景颜色 'line-height': '45px', // 请保持与高度一致以垂直居中
} background: '#e7eaf1'// 按钮的背景颜色
} }
} }
} }
}
</script> </script>
This diff is collapsed.
...@@ -8,31 +8,31 @@ ...@@ -8,31 +8,31 @@
</template> </template>
<script> <script>
import DndList from 'components/twoDndList' import DndList from 'components/twoDndList'
import { getList } from 'api/article'; import { getList } from 'api/article'
export default { export default {
components: { DndList }, components: { DndList },
data() { data() {
return { return {
list1: [], list1: [],
list2: [] list2: []
}
},
created() {
this.fetchData();
},
methods: {
fetchData() {
this.listLoading = true;
getList(this.listQuery).then(response => {
this.list1 = response.data.splice(0, 5);
this.list2 = response.data;
console.log(this.list1, this.list2)
})
}
} }
}; },
created() {
this.fetchData()
},
methods: {
fetchData() {
this.listLoading = true
getList(this.listQuery).then(response => {
this.list1 = response.data.splice(0, 5)
this.list2 = response.data
console.log(this.list1, this.list2)
})
}
}
}
</script> </script>
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
</template> </template>
<script> <script>
export default { export default {
name: 'AppMain', name: 'AppMain',
computed: { computed: {
key() { key() {
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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