-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from vipshop/develop
v0.15.11
- Loading branch information
Showing
178 changed files
with
4,575 additions
and
770 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
const path = require('path'); | ||
const webpack = require('webpack'); | ||
const { VueLoaderPlugin } = require('vue-loader'); | ||
const vueLoaderConfig = require('./vue-loader.conf'); | ||
const HtmlWebpackPlugin = require('html-webpack-plugin'); | ||
const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin'); | ||
|
||
const config = require('./config'); | ||
|
||
module.exports = { | ||
mode: 'development', | ||
entry: { | ||
app: ['./examples/dev/app.js'] | ||
}, | ||
devtool: 'cheap-source-map', | ||
resolve: { | ||
extensions: ['.js', '.vue', '.json'], | ||
alias: { | ||
'@ams-team/ams': path.join(__dirname, '../') | ||
} | ||
}, | ||
devServer: { | ||
clientLogLevel: 'warning', | ||
historyApiFallback: true, | ||
hot: true, | ||
compress: true, | ||
host: 'localhost', | ||
port: config.dev.port, | ||
open: true, | ||
overlay: { warnings: false, errors: true }, | ||
publicPath: '/', | ||
proxy: {}, | ||
quiet: true, // necessary for FriendlyErrorsPlugin | ||
watchOptions: { | ||
poll: false | ||
}, | ||
headers: { | ||
'Access-Control-Allow-Origin': '*', | ||
'Access-Control-Allow-Headers': 'Content-Type' | ||
} | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.(jsx?|babel|es6)$/, | ||
include: process.cwd(), | ||
exclude: config.jsexclude, | ||
loader: 'babel-loader' | ||
}, | ||
{ | ||
test: /\.vue$/, | ||
loader: 'vue-loader', | ||
options: vueLoaderConfig | ||
}, | ||
{ | ||
test: /\.css$/, | ||
loaders: ['style-loader', 'css-loader', 'postcss-loader'] | ||
}, | ||
{ | ||
test: /\.scss$/, | ||
loaders: ['style-loader', 'css-loader', 'sass-loader'] | ||
}, | ||
{ | ||
test: /\.otf|ttf|woff2?|eot(\?\S*)?$/, | ||
loader: 'url-loader', | ||
query: { | ||
limit: 10000, | ||
name: path.posix.join('./lib/theme-default', '[name].[hash:7].[ext]') | ||
} | ||
}, | ||
{ | ||
test: /\.svg(\?\S*)?$/, | ||
loader: 'url-loader', | ||
query: { | ||
limit: 10000, | ||
name: path.posix.join('./lib/theme-default', '[name].[hash:7].[ext]') | ||
} | ||
}, | ||
{ | ||
test: /\.(gif|png|jpe?g)(\?\S*)?$/, | ||
loader: 'url-loader', | ||
query: { | ||
limit: 10000, | ||
name: path.posix.join('./lib/theme-default', '[name].[hash:7].[ext]') | ||
} | ||
} | ||
] | ||
}, | ||
plugins: [ | ||
new VueLoaderPlugin(), | ||
new webpack.HotModuleReplacementPlugin(), | ||
new HtmlWebpackPlugin(), | ||
new FriendlyErrorsPlugin({ | ||
compilationSuccessInfo: { | ||
messages: [ | ||
`Your application is running here: http://localhost:${config.dev.port}` | ||
] | ||
} | ||
}) | ||
// new BundleAnalyzerPlugin() | ||
] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
export default { | ||
getSetView: { | ||
resources: { | ||
getSetView: { | ||
api: { | ||
prefix: '/test/', | ||
create: 'create' | ||
}, | ||
fields: { | ||
datetime: { | ||
label: '时间', | ||
type: 'datetime', | ||
get(value) { | ||
// 格式化成13位时间戳(datetime组件) | ||
console.log('get', value); | ||
return Number(value.slice(5)); | ||
}, | ||
set(value) { | ||
// localValue可能为Date或者是时间戳 | ||
console.log('set', value); | ||
return 'date:' + (value instanceof Date ? value.getTime() : value); | ||
}, | ||
view(value) { | ||
// 格式化13位时间戳 | ||
console.log('view', value); | ||
return value.slice(5) / 1000; | ||
} | ||
}, | ||
testSelect: { | ||
type: 'select', | ||
label: '字符串多选', | ||
props: { | ||
multiple: true, | ||
options: { | ||
'a': '黄金糕', | ||
'b': '双皮奶', | ||
'c': '蚵仔煎' | ||
} | ||
} | ||
}, | ||
testArraySelect: { | ||
type: 'select', | ||
label: '数组多选', | ||
props: { | ||
multiple: true, | ||
options: { | ||
'a': '黄金糕', | ||
'b': '双皮奶', | ||
'c': '蚵仔煎' | ||
} | ||
}, | ||
get(value) { | ||
console.log('get', value); | ||
if (typeof value === 'string') { | ||
return value.split(','); | ||
} | ||
return value; | ||
}, | ||
set(value) { | ||
// localValue可能为Date或者是时间戳 | ||
console.log('set', value); | ||
if (typeof value === 'string') { | ||
return value.split(','); | ||
} | ||
return value; | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
blocks: { | ||
editGetSetView: { | ||
data: { | ||
datetime: '', | ||
testSelect: '', | ||
testArraySelect: [] | ||
}, | ||
type: 'form', | ||
resource: 'getSetView', | ||
ctx: 'edit', | ||
style: { | ||
width: '50%' | ||
}, | ||
events: { | ||
init: 'initFn', | ||
submit: '@alert @create' | ||
}, | ||
actions: { | ||
initFn() { | ||
setTimeout(() => { | ||
this.data.datetime = 'date:1546278503030'; | ||
this.data.testSelect = 'a,b' | ||
this.data.testArraySelect = ['a', 'b']; | ||
}, 1000); | ||
}, | ||
alert() { | ||
alert('提交的表单数据是:' + JSON.stringify(this.data)); | ||
} | ||
}, | ||
operations: { | ||
submit: { | ||
type: 'button', | ||
label: '提交' | ||
} | ||
} | ||
}, | ||
viewGetSetView: { | ||
data: { | ||
datetime: 'date:1546278503030', | ||
testSelect: 'a,b', | ||
testArraySelect: ['a', 'b'] | ||
}, | ||
type: 'form', | ||
resource: 'getSetView', | ||
ctx: 'view', | ||
style: { | ||
width: '50%' | ||
}, | ||
events: { | ||
submit: '@create' | ||
} | ||
} | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<template> | ||
<el-card shadow="hover" class="demo demo-card"> | ||
<ams-block v-if="init" :name="blockName" class="demo-card-preview"/> | ||
<div :class="`demo-card-config ${showConfig ? 'open': ''}`"> | ||
<highlight-code lang="javascript"> | ||
{{ configCode }} | ||
</highlight-code> | ||
</div> | ||
<div class="demo-card-config-btn" @click="toggleDemoCofig"> | ||
<i :class="`el-icon-caret-${showConfig ? 'top': 'bottom'}`"></i> | ||
{{ showConfig ? '隐藏' : '显示'}}配置 | ||
<el-link v-if="onlineDemo" :href="onlineDemo" target="_blank" type="success">在线运行</el-link> | ||
</div> | ||
</el-card> | ||
</template> | ||
|
||
<script> | ||
import demoMixins from '../../demo/demo-mixin' | ||
import block from './block' | ||
import stringify from '@ams-team/json-stringify' | ||
import beautify from 'js-beautify' | ||
export default { | ||
mixins: [demoMixins], | ||
mounted(){ | ||
const stringConfig = stringify(block[this.blockName]) | ||
this.configCode = beautify(stringConfig, { indent_size: 2, space_in_empty_paren: true }) | ||
// 如果已经注册过则不再注册 | ||
if (ams && ams.blocks && ams.blocks[this.blockName]) { | ||
this.init = true; | ||
return; | ||
} | ||
ams.block(this.blockName, block[this.blockName]) | ||
this.init = true | ||
} | ||
} | ||
</script> |
Oops, something went wrong.