mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-05-25 07:49:15 +08:00
Merge pull request #161 from chenjiahan/dev
fix: remove zan-utils/validate & lodash/find dependencies
This commit is contained in:
commit
08c31e5045
@ -1,6 +1,7 @@
|
|||||||
const webpack = require('webpack');
|
const webpack = require('webpack');
|
||||||
const config = require('./webpack.config.dev.js');
|
const config = require('./webpack.config.dev.js');
|
||||||
const isMinify = process.argv.indexOf('-p') !== -1;
|
const isMinify = process.argv.indexOf('-p') !== -1;
|
||||||
|
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
||||||
|
|
||||||
config.entry = {
|
config.entry = {
|
||||||
'vant': './packages/index.js'
|
'vant': './packages/index.js'
|
||||||
@ -39,6 +40,11 @@ config.plugins = [
|
|||||||
new webpack.optimize.ModuleConcatenationPlugin()
|
new webpack.optimize.ModuleConcatenationPlugin()
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// analyze bundle size if need
|
||||||
|
// if (isMinify) {
|
||||||
|
// config.plugins.push(new BundleAnalyzerPlugin());
|
||||||
|
// }
|
||||||
|
|
||||||
delete config.devtool;
|
delete config.devtool;
|
||||||
|
|
||||||
module.exports = config;
|
module.exports = config;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
var webpack = require('webpack');
|
const webpack = require('webpack');
|
||||||
var merge = require('webpack-merge');
|
const merge = require('webpack-merge');
|
||||||
var path = require('path');
|
const path = require('path');
|
||||||
var devConfig = require('./webpack.config.dev.js');
|
const devConfig = require('./webpack.config.dev.js');
|
||||||
|
|
||||||
module.exports = merge(devConfig, {
|
module.exports = merge(devConfig, {
|
||||||
output: {
|
output: {
|
||||||
|
@ -117,6 +117,7 @@
|
|||||||
"vue-style-loader": "^3.0.0",
|
"vue-style-loader": "^3.0.0",
|
||||||
"vue-template-compiler": "^2.4.2",
|
"vue-template-compiler": "^2.4.2",
|
||||||
"webpack": "^3.5.5",
|
"webpack": "^3.5.5",
|
||||||
|
"webpack-bundle-analyzer": "^2.9.0",
|
||||||
"webpack-dev-server": "^2.7.1",
|
"webpack-dev-server": "^2.7.1",
|
||||||
"webpack-merge": "^4.1.0",
|
"webpack-merge": "^4.1.0",
|
||||||
"zan-doc": "0.2.17"
|
"zan-doc": "0.2.17"
|
||||||
|
@ -41,7 +41,7 @@ import Icon from '../icon';
|
|||||||
import Field from '../field';
|
import Field from '../field';
|
||||||
import Cell from '../cell';
|
import Cell from '../cell';
|
||||||
import CellGroup from '../cell-group';
|
import CellGroup from '../cell-group';
|
||||||
import UA from 'zan-utils/browser/ua_browser';
|
import isAndroid from '../utils/env/is-andriod';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'van-address-edit-detail',
|
name: 'van-address-edit-detail',
|
||||||
@ -62,7 +62,7 @@ export default {
|
|||||||
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
isAndroid: UA.isAndroid(),
|
isAndroid: isAndroid(),
|
||||||
isFocused: false
|
isFocused: false
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
@ -76,7 +76,7 @@ import Dialog from '../dialog';
|
|||||||
import Area from '../area';
|
import Area from '../area';
|
||||||
import Detail from './Detail';
|
import Detail from './Detail';
|
||||||
import SwitchCell from '../switch-cell';
|
import SwitchCell from '../switch-cell';
|
||||||
import validateMobile from 'zan-utils/validate/mobile';
|
import validateMobile from '../utils/validate/mobile';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'van-address-edit',
|
name: 'van-address-edit',
|
||||||
|
@ -31,7 +31,7 @@ import Button from '../button';
|
|||||||
import CellGroup from '../cell-group';
|
import CellGroup from '../cell-group';
|
||||||
import Dialog from '../dialog';
|
import Dialog from '../dialog';
|
||||||
import Toast from '../toast';
|
import Toast from '../toast';
|
||||||
import validateMobile from 'zan-utils/validate/mobile';
|
import validateMobile from '../utils/validate/mobile';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'van-contact-edit',
|
name: 'van-contact-edit',
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import find from 'lodash/find';
|
|
||||||
import urlHelper from 'zan-utils/url/helper';
|
import urlHelper from 'zan-utils/url/helper';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@ -53,9 +52,13 @@ export default {
|
|||||||
if (!id) return;
|
if (!id) return;
|
||||||
|
|
||||||
// 目前skuImg都挂载在skuTree中s1那类sku上
|
// 目前skuImg都挂载在skuTree中s1那类sku上
|
||||||
const treeItem = find(this.skuTree, (treeItem) => treeItem.k_s === 's1') || {};
|
const treeItem = this.skuTree.filter(treeItem => treeItem.k_s === 's1')[0] || {};
|
||||||
const matchedSku = find(treeItem.v, (skuValue) => skuValue.id === id);
|
|
||||||
|
|
||||||
|
if (!treeItem.v) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const matchedSku = treeItem.v.filter(skuValue => skuValue.id === id)[0];
|
||||||
if (matchedSku && matchedSku.imgUrl) {
|
if (matchedSku && matchedSku.imgUrl) {
|
||||||
return urlHelper.getCdnImageUrl(matchedSku.imgUrl);
|
return urlHelper.getCdnImageUrl(matchedSku.imgUrl);
|
||||||
}
|
}
|
||||||
|
@ -25,8 +25,8 @@
|
|||||||
<script>
|
<script>
|
||||||
import Field from '../../field';
|
import Field from '../../field';
|
||||||
import CellGroup from '../../cell-group';
|
import CellGroup from '../../cell-group';
|
||||||
import validateEmail from 'zan-utils/validate/email';
|
import validateEmail from '../../utils/validate/email';
|
||||||
import validateNumber from 'zan-utils/validate/number';
|
import validateNumber from '../../utils/validate/number';
|
||||||
import { DEFAULT_PLACEHOLDER_MAP } from '../constants';
|
import { DEFAULT_PLACEHOLDER_MAP } from '../constants';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import find from 'lodash/find';
|
|
||||||
/*
|
/*
|
||||||
normalize sku tree
|
normalize sku tree
|
||||||
|
|
||||||
@ -50,12 +49,11 @@ export const isAllSelected = (skuTree, selectedSku) => {
|
|||||||
|
|
||||||
// 根据已选择的sku获取skuComb
|
// 根据已选择的sku获取skuComb
|
||||||
export const getSkuComb = (skuList, selectedSku) => {
|
export const getSkuComb = (skuList, selectedSku) => {
|
||||||
const skuComb = find(skuList, skuComb => {
|
const skuComb = skuList.filter(skuComb => {
|
||||||
return Object.keys(selectedSku).every(skuKeyStr => {
|
return Object.keys(selectedSku).every(skuKeyStr => {
|
||||||
// 后端给的key有时数字有时字符串,需要兼容=。=
|
return String(skuComb[skuKeyStr]) === String(selectedSku[skuKeyStr]); // eslint-disable-line
|
||||||
return skuComb[skuKeyStr] == selectedSku[skuKeyStr]; // eslint-disable-line
|
|
||||||
});
|
});
|
||||||
});
|
})[0];
|
||||||
return skuComb;
|
return skuComb;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -67,7 +65,7 @@ export const getSelectedSkuValues = (skuTree, selectedSku) => {
|
|||||||
const skuValueId = selectedSku[skuKeyStr];
|
const skuValueId = selectedSku[skuKeyStr];
|
||||||
|
|
||||||
if (skuValueId) {
|
if (skuValueId) {
|
||||||
const skuValue = find(skuValues, skuValue => skuValue.id === skuValueId);
|
const skuValue = skuValues.filter(skuValue => skuValue.id === skuValueId)[0];
|
||||||
skuValue && selectedValues.push(skuValue);
|
skuValue && selectedValues.push(skuValue);
|
||||||
}
|
}
|
||||||
return selectedValues;
|
return selectedValues;
|
||||||
|
3
packages/utils/env/is-andriod.js
vendored
Normal file
3
packages/utils/env/is-andriod.js
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export default function() {
|
||||||
|
return /android/.test(navigator.userAgent.toLowerCase());
|
||||||
|
}
|
4
packages/utils/validate/email.js
Normal file
4
packages/utils/validate/email.js
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
export default function email(value) {
|
||||||
|
const reg = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i;
|
||||||
|
return reg.test(value);
|
||||||
|
}
|
4
packages/utils/validate/mobile.js
Normal file
4
packages/utils/validate/mobile.js
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
export default function mobile(value) {
|
||||||
|
return /^((\+86)|(86))?(1)\d{10}$/.test(value) ||
|
||||||
|
/^\+?(9[976]\d|8[987530]\d|6[987]\d|5[90]\d|42\d|3[875]\d|2[98654321]\d|9[8543210]|8[6421]|6[6543210]|5[87654321]|4[987654310]|3[9643210]|2[70]|7|1|)-?\d{1,14}$/.test(String(value));
|
||||||
|
}
|
3
packages/utils/validate/number.js
Normal file
3
packages/utils/validate/number.js
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export default function number(value) {
|
||||||
|
return /^\d+$/.test(value);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user