mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-06 03:58:05 +08:00
perf(circle): downgrade to native when sdk version lower than 2.9.0 (#4050)
This commit is contained in:
parent
c5b4858214
commit
f9d067e0e8
@ -1,8 +1,9 @@
|
|||||||
import { VantComponent } from '../common/component';
|
|
||||||
import { BLUE, WHITE } from '../common/color';
|
import { BLUE, WHITE } from '../common/color';
|
||||||
import { adaptor } from './canvas';
|
import { VantComponent } from '../common/component';
|
||||||
import { isObj } from '../common/validator';
|
|
||||||
import { getSystemInfoSync } from '../common/utils';
|
import { getSystemInfoSync } from '../common/utils';
|
||||||
|
import { isObj } from '../common/validator';
|
||||||
|
import { canIUseCanvas2d } from '../common/version';
|
||||||
|
import { adaptor } from './canvas';
|
||||||
|
|
||||||
function format(rate) {
|
function format(rate) {
|
||||||
return Math.min(Math.max(rate, 0), 100);
|
return Math.min(Math.max(rate, 0), 100);
|
||||||
@ -70,7 +71,7 @@ VantComponent({
|
|||||||
getContext() {
|
getContext() {
|
||||||
const { type, size } = this.data;
|
const { type, size } = this.data;
|
||||||
|
|
||||||
if (type === '') {
|
if (type === '' || !canIUseCanvas2d()) {
|
||||||
const ctx = wx.createCanvasContext('van-circle', this);
|
const ctx = wx.createCanvasContext('van-circle', this);
|
||||||
return Promise.resolve(ctx);
|
return Promise.resolve(ctx);
|
||||||
}
|
}
|
||||||
|
@ -27,26 +27,32 @@ function compareVersion(v1, v2) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function canIUseModel() {
|
function gte(version: string) {
|
||||||
const system = getSystemInfoSync();
|
const system = getSystemInfoSync();
|
||||||
return compareVersion(system.SDKVersion, '2.9.3') >= 0;
|
|
||||||
|
return compareVersion(system.SDKVersion, version) >= 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function canIUseModel() {
|
||||||
|
return gte('2.9.3');
|
||||||
}
|
}
|
||||||
|
|
||||||
export function canIUseFormFieldButton() {
|
export function canIUseFormFieldButton() {
|
||||||
const system = getSystemInfoSync();
|
return gte('2.10.3');
|
||||||
return compareVersion(system.SDKVersion, '2.10.3') >= 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function canIUseAnimate() {
|
export function canIUseAnimate() {
|
||||||
const system = getSystemInfoSync();
|
return gte('2.9.0');
|
||||||
return compareVersion(system.SDKVersion, '2.9.0') >= 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function canIUseGroupSetData() {
|
export function canIUseGroupSetData() {
|
||||||
const system = getSystemInfoSync();
|
return gte('2.4.0');
|
||||||
return compareVersion(system.SDKVersion, '2.4.0') >= 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function canIUseNextTick() {
|
export function canIUseNextTick() {
|
||||||
return wx.canIUse('nextTick');
|
return wx.canIUse('nextTick');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function canIUseCanvas2d() {
|
||||||
|
return gte('2.9.0');
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user