no message

Former-commit-id: 0a96bb54e9270e451e59b72e00e35053a7c0e152
Former-commit-id: c250ba90da6546626b9831847630aae786c88344
Former-commit-id: c1182b1bdc6ea9b3934275286a93e2760a643bfe
This commit is contained in:
李杨
2018-01-14 22:51:12 +08:00
parent e667b66cf3
commit 173520d20e
210 changed files with 10281 additions and 0 deletions

View File

@@ -0,0 +1,64 @@
<template>
<el-card class="mb">
<div slot="header" class="clearfix">
<el-button type="text" size="mini">{{title}}</el-button>
<el-tooltip content="重新 mock 数据" placement="top-end">
<el-button type="primary" size="mini" @click="$emit('reload')" style="float: right;">刷新</el-button>
</el-tooltip>
</div>
<el-row :gutter="10">
<el-col :span="12">
<div class="col col-l">
<Highlight :code="code"></Highlight>
</div>
</el-col>
<el-col :span="12">
<div class="col col-r">
<Highlight :code="mock"></Highlight>
</div>
</el-col>
</el-row>
</el-card>
</template>
<script>
export default {
props: {
title: {
type: String,
required: false,
default: 'Mock Demo'
},
code: {
type: String,
required: false,
default: ''
},
mock: {
type: String,
required: false,
default: ''
}
}
}
</script>
<style lang="scss" scoped>
@import '~@/assets/style/public.scss';
.col {
padding: $margin;
border-radius: $border-radius;
border-width: 1px;
border-style: solid;
}
.col-l {
background-color: lighten($color-info, 40%);
border-color: lighten($color-info, 35%);
}
.col-r {
background-color: lighten($color-success, 47%);
border-color: lighten($color-success, 40%);
}
</style>

View File

@@ -0,0 +1,15 @@
/* eslint-disable */
export default [
// 字符串
{
title: "占位符演示",
json: {
"name": {
first: '@FIRST',
middle: '@FIRST',
last: '@LAST',
full: '@first @middle @last'
}
}
}
]

View File

@@ -0,0 +1,111 @@
/* eslint-disable */
export default [
// 字符串
{
title: "复制1-10次固定字符串",
json: {
"string|1-10": "★"
}
},
{
title: "复制3次",
json: {
"string|3": "Ha"
}
},
// 数字
{
title: "范围随机取值",
json: {
"number|1-100": 50
}
},
{
title: "累加1",
json: {
"number|+1": 10
}
},
{
title: "累加2",
json: {
"number|+2": 10
}
},
{
title: "浮点数",
json: {
"number1|1-100.1-10": 1,
"number2|123.1-10": 1,
"number3|123.3": 1,
"number4|123.10": 1.123
}
},
// 布尔值
{
title: "true 的概率是 1/2",
json: {
"boolean|1": true
}
},
// 对象
{
title: '随机选择3个属性',
json: {
"obj|3": {
name: 'FairyEver',
use: 'vue.js',
sex: 1,
qq: '1711467488',
tel: '123-4567-8910',
city: 'beijing',
phone: 'Apple',
mail: '1711467488liyang@gmail.com',
github: 'https://github.com/FairyEver',
blog: 'http://www.fairyever.com/'
}
}
},
{
title: '随机选择3-6个属性',
json: {
"obj|3-6": {
name: 'FairyEver',
use: 'vue.js',
sex: 1,
qq: '1711467488',
tel: '123-4567-8910',
city: 'beijing',
phone: 'Apple',
mail: '1711467488liyang@gmail.com',
github: 'https://github.com/FairyEver',
blog: 'http://www.fairyever.com/'
}
}
},
// 数组
{
title: '随机选1个',
json: {
"arr|1": ['1-vue', '2-react', '3-angular', '4-node', '5-java']
}
},
{
title: '顺序选1个',
json: {
"arr|+1": ['1-vue', '2-react', '3-angular', '4-node', '5-java']
}
},
{
title: '重复3次',
json: {
"arr|3": ['o', 'o - o', 'o - o - o']
}
},
{
title: '重复2-10次',
json: {
"arr|2-10": ['-', '----']
}
}
]

View File

@@ -0,0 +1,45 @@
<template>
<Container type="ghost">
<el-card class="mb">
<Markdown url="/static/markdownFiles/article/mock演示页面介绍.md"></Markdown>
</el-card>
<MockDemoCard
v-for="(item, index) in settingDPD"
:key="index"
:title="item.title"
:code="JSON.stringify(item.json, null, 2)"
:mock="mockResult[index]"
@reload="doMock(index)">
</MockDemoCard>
</Container>
</template>
<script>
import Vue from 'vue'
import * as tool from '@/assets/library/tool/tool.js'
import Mock from 'mockjs'
import settingDPD from './data/settingDPD'
import MockDemoCard from './componnets/MockDemoCard'
export default {
components: {
MockDemoCard
},
data () {
return {
mockResult: [],
settingDPD,
settingDPDClone: tool.clone(settingDPD)
}
},
mounted () {
this.settingDPD.forEach((e, i) => {
this.doMock(i)
})
},
methods: {
doMock (n = 0) {
Vue.set(this.mockResult, n, JSON.stringify(Mock.mock(this.settingDPDClone[n].json), null, 2))
}
}
}
</script>

View File

@@ -0,0 +1,66 @@
<template>
<Container type="ghost">
<el-card class="mb">
<Markdown url="/static/markdownFiles/article/mock演示页面介绍.md"></Markdown>
</el-card>
<MockDemoCard
v-for="(item, index) in settingDTD"
:key="index"
:title="item.title"
:code="JSON.stringify(item.json, null, 2)"
:mock="mockResult[index]"
@reload="doMock(index)">
</MockDemoCard>
<MockDemoCard
:title="fn.title"
:code="fn.code"
:mock="fn.mocked"
@reload="fnMock()">
</MockDemoCard>
<MockDemoCard
:title="regexp.title"
:code="regexp.code"
:mock="regexp.mocked"
@reload="regexpMock()">
</MockDemoCard>
</Container>
</template>
<script>
import Vue from 'vue'
import * as tool from '@/assets/library/tool/tool.js'
import Mock from 'mockjs'
import settingDTD from './data/settingDTD'
import MockDemoCard from './componnets/MockDemoCard'
// mixin
import regexp from './mixins/regexp'
import fn from './mixins/function'
export default {
mixins: [
regexp,
fn
],
components: {
MockDemoCard
},
data () {
return {
mockResult: [],
settingDTD,
settingDTDClone: tool.clone(settingDTD)
}
},
mounted () {
this.settingDTD.forEach((e, i) => {
this.doMock(i)
})
this.fnMock()
this.regexpMock()
},
methods: {
doMock (n = 0) {
Vue.set(this.mockResult, n, JSON.stringify(Mock.mock(this.settingDTDClone[n].json), null, 2))
}
}
}
</script>

View File

@@ -0,0 +1,5 @@
<template>
<Container>
<Markdown url="/static/markdownFiles/article/mock语法规范.md"></Markdown>
</Container>
</template>

View File

@@ -0,0 +1,30 @@
/* eslint-disable */
import Mock from 'mockjs'
export default {
data () {
return {
// 测试函数
fn: {
title: '函数',
code: `{
"name": "FairyEver",
"say": function() {
return 'I AM ' + this.name
}
}`,
json: {
"name": "FairyEver",
"say": function() {
return 'I AM ' + this.name
}
},
mocked: ''
}
}
},
methods: {
fnMock () {
this.fn.mocked = JSON.stringify(Mock.mock(this.fn.json), null, 2)
}
}
}

View File

@@ -0,0 +1,28 @@
/* eslint-disable */
import Mock from 'mockjs'
export default {
data () {
return {
// 测试正则表达式
regexp: {
title: '正则表达式',
code: `{
'regexp1': /[a-z][A-Z][0-9]/,
'regexp2': /\w\W\s\S\d\D/,
'regexp3': /\d{5,10}/
}`,
json: {
'regexp1': /[a-z][A-Z][0-9]/,
'regexp2': /\w\W\s\S\d\D/,
'regexp3': /\d{5,10}/
},
mocked: ''
}
}
},
methods: {
regexpMock () {
this.regexp.mocked = JSON.stringify(Mock.mock(this.regexp.json), null, 2)
}
}
}

View File

@@ -0,0 +1,7 @@
<template>
<Container>
<p slot="title">README.md</p>
<p slot="more"><GithubLink url="https://github.com/nuysoft/Mock"></GithubLink></p>
<Markdown url="https://raw.githubusercontent.com/nuysoft/Mock/refactoring/README.md"></Markdown>
</Container>
</template>