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 { adaptor } from './canvas';
|
||||
import { isObj } from '../common/validator';
|
||||
import { VantComponent } from '../common/component';
|
||||
import { getSystemInfoSync } from '../common/utils';
|
||||
import { isObj } from '../common/validator';
|
||||
import { canIUseCanvas2d } from '../common/version';
|
||||
import { adaptor } from './canvas';
|
||||
|
||||
function format(rate) {
|
||||
return Math.min(Math.max(rate, 0), 100);
|
||||
@ -70,7 +71,7 @@ VantComponent({
|
||||
getContext() {
|
||||
const { type, size } = this.data;
|
||||
|
||||
if (type === '') {
|
||||
if (type === '' || !canIUseCanvas2d()) {
|
||||
const ctx = wx.createCanvasContext('van-circle', this);
|
||||
return Promise.resolve(ctx);
|
||||
}
|
||||
|
@ -27,26 +27,32 @@ function compareVersion(v1, v2) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
export function canIUseModel() {
|
||||
function gte(version: string) {
|
||||
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() {
|
||||
const system = getSystemInfoSync();
|
||||
return compareVersion(system.SDKVersion, '2.10.3') >= 0;
|
||||
return gte('2.10.3');
|
||||
}
|
||||
|
||||
export function canIUseAnimate() {
|
||||
const system = getSystemInfoSync();
|
||||
return compareVersion(system.SDKVersion, '2.9.0') >= 0;
|
||||
return gte('2.9.0');
|
||||
}
|
||||
|
||||
export function canIUseGroupSetData() {
|
||||
const system = getSystemInfoSync();
|
||||
return compareVersion(system.SDKVersion, '2.4.0') >= 0;
|
||||
return gte('2.4.0');
|
||||
}
|
||||
|
||||
export function canIUseNextTick() {
|
||||
return wx.canIUse('nextTick');
|
||||
}
|
||||
|
||||
export function canIUseCanvas2d() {
|
||||
return gte('2.9.0');
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user