Merge pull request #3869 from rex-zsd/pref/20201217_1

perf(tags): remove useless code
This commit is contained in:
rex 2020-12-17 19:47:06 +08:00 committed by GitHub
commit 2f040ffeba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 20 additions and 24 deletions

View File

@ -1,7 +1,8 @@
import { VantComponent } from '../common/component'; import { VantComponent } from '../common/component';
import { isObj } from '../common/utils';
import { BLUE, WHITE } from '../common/color'; import { BLUE, WHITE } from '../common/color';
import { adaptor } from './canvas'; import { adaptor } from './canvas';
import { isObj } from '../common/validator';
import { getSystemInfoSync } from '../common/utils';
function format(rate) { function format(rate) {
return Math.min(Math.max(rate, 0), 100); return Math.min(Math.max(rate, 0), 100);
@ -74,7 +75,7 @@ VantComponent({
return Promise.resolve(ctx); return Promise.resolve(ctx);
} }
const dpr = wx.getSystemInfoSync().pixelRatio; const dpr = getSystemInfoSync().pixelRatio;
return new Promise((resolve) => { return new Promise((resolve) => {
wx.createSelectorQuery() wx.createSelectorQuery()

View File

@ -1,15 +1,6 @@
import { isNumber, isPlainObject, isPromise } from './validator'; import { isDef, isNumber, isPlainObject, isPromise } from './validator';
import { canIUseGroupSetData } from './version'; import { canIUseGroupSetData } from './version';
export function isDef(value: any): boolean {
return value !== undefined && value !== null;
}
export function isObj(x: any): boolean {
const type = typeof x;
return x !== null && (type === 'object' || type === 'function');
}
export function range(num: number, min: number, max: number) { export function range(num: number, min: number, max: number) {
return Math.min(Math.max(num, min), max); return Math.min(Math.max(num, min), max);
} }

View File

@ -10,7 +10,7 @@ export function isPromise<T = unknown>(val: unknown): val is Promise<T> {
return isPlainObject(val) && isFunction(val.then) && isFunction(val.catch); return isPlainObject(val) && isFunction(val.then) && isFunction(val.catch);
} }
export function isDef(value: any): boolean { export function isDef(value: unknown): boolean {
return value !== undefined && value !== null; return value !== undefined && value !== null;
} }

View File

@ -1,5 +1,5 @@
import { VantComponent } from '../common/component'; import { VantComponent } from '../common/component';
import { isDef } from '../common/utils'; import { isDef } from '../common/validator';
import { pickerProps } from '../picker/shared'; import { pickerProps } from '../picker/shared';
const currentYear = new Date().getFullYear(); const currentYear = new Date().getFullYear();

View File

@ -1,5 +1,5 @@
import { VantComponent } from '../common/component'; import { VantComponent } from '../common/component';
import { addUnit, getRect } from '../common/utils'; import { addUnit, getRect, getSystemInfoSync } from '../common/utils';
type TrivialInstance = WechatMiniprogram.Component.TrivialInstance; type TrivialInstance = WechatMiniprogram.Component.TrivialInstance;
let ARRAY: TrivialInstance[] = []; let ARRAY: TrivialInstance[] = [];
@ -59,7 +59,7 @@ VantComponent({
}, },
beforeCreate() { beforeCreate() {
const { windowHeight } = wx.getSystemInfoSync(); const { windowHeight } = getSystemInfoSync();
this.windowHeight = windowHeight; this.windowHeight = windowHeight;
ARRAY.push(this); ARRAY.push(this);
}, },

View File

@ -97,7 +97,7 @@ VantComponent({
return Promise.all( return Promise.all(
this.children.map( this.children.map(
(anchor: WechatMiniprogram.Component.TrivialInstance) => (anchor: WechatMiniprogram.Component.TrivialInstance) =>
getRect.call(anchor, '.van-index-anchor-wrapper').then((rect) => { getRect(anchor, '.van-index-anchor-wrapper').then((rect) => {
Object.assign(anchor, { Object.assign(anchor, {
height: rect.height, height: rect.height,
top: rect.top + this.scrollTop, top: rect.top + this.scrollTop,
@ -140,7 +140,7 @@ VantComponent({
}, },
getAnchorRect(anchor) { getAnchorRect(anchor) {
return getRect.call(anchor, '.van-index-anchor-wrapper').then((rect) => ({ return getRect(anchor, '.van-index-anchor-wrapper').then((rect) => ({
height: rect.height, height: rect.height,
top: rect.top, top: rect.top,
})); }));

View File

@ -1,5 +1,6 @@
// @ts-nocheck // @ts-nocheck
import { isObj, requestAnimationFrame } from '../common/utils'; import { requestAnimationFrame } from '../common/utils';
import { isObj } from '../common/validator';
const getClassNames = (name: string) => ({ const getClassNames = (name: string) => ({
enter: `van-${name}-enter van-${name}-enter-active enter-class enter-active-class`, enter: `van-${name}-enter van-${name}-enter-active enter-class enter-active-class`,

View File

@ -1,5 +1,6 @@
import { VantComponent } from '../common/component'; import { VantComponent } from '../common/component';
import { WHITE } from '../common/color'; import { WHITE } from '../common/color';
import { getSystemInfoSync } from '../common/utils';
VantComponent({ VantComponent({
props: { props: {
@ -33,7 +34,7 @@ VantComponent({
}, },
created() { created() {
const { statusBarHeight } = wx.getSystemInfoSync(); const { statusBarHeight } = getSystemInfoSync();
this.setData({ statusBarHeight }); this.setData({ statusBarHeight });
}, },

View File

@ -1,5 +1,6 @@
import { VantComponent } from '../common/component'; import { VantComponent } from '../common/component';
import { isObj, range } from '../common/utils'; import { range } from '../common/utils';
import { isObj } from '../common/validator';
const DEFAULT_DURATION = 200; const DEFAULT_DURATION = 200;

View File

@ -1,5 +1,5 @@
import { VantComponent } from '../common/component'; import { VantComponent } from '../common/component';
import { isDef } from '../common/utils'; import { isDef } from '../common/validator';
const LONG_PRESS_START_TIME = 600; const LONG_PRESS_START_TIME = 600;
const LONG_PRESS_INTERVAL = 200; const LONG_PRESS_INTERVAL = 200;

View File

@ -1,6 +1,7 @@
import { VantComponent } from '../common/component'; import { VantComponent } from '../common/component';
import { touch } from '../mixins/touch'; import { touch } from '../mixins/touch';
import { getAllRect, getRect, groupSetData, isDef } from '../common/utils'; import { getAllRect, getRect, groupSetData } from '../common/utils';
import { isDef } from '../common/validator';
type TrivialInstance = WechatMiniprogram.Component.TrivialInstance; type TrivialInstance = WechatMiniprogram.Component.TrivialInstance;

View File

@ -1,4 +1,4 @@
import { isObj } from '../common/utils'; import { isObj } from '../common/validator';
type ToastMessage = string | number; type ToastMessage = string | number;