@suplink/tf-base
TypeScript icon, indicating that this package has built-in type declarations

0.1.6 • Public • Published

功能概述

本包用于天坊跨平台兼容方案,为基础应用、领域应用及其他基础依赖包提供运行时匹配工具、基础TS类型及全域变量初始化方法。

安装使用

  • 任意项目执行npm i @suplink/tf-base

API说明

mount

挂载全域变量

参数

参数 类型 含义 默认 必须
suposVersion string supos版本
ideVersion string ide版本
tfClient string 终端类型,any - 任意,pc - pc端,mobile - 移动端 any
tfPlatform string 平台类型,any - 任意,suplink - suplink平台 any
tfLang string 语言类型,zh-cn - 中文,en-us - 英文 zh-cn

案例

import { mount } from '@suplink/tf-base';

mount({ suposVersion, ideVersion, tfClient, tfPlatform, tfLang });

console.log(window.$suposVersion, window.$ideVersion, window.$tfClient, window.$tfPlatform, window.$tfLang);

match

匹配相应组件/方法

参数

参数 类型 含义 默认 必须
defaultApi any 默认api
apiList array[] 其他根据全域变量待匹配的api列表

案例

const fun = match(fun1, [
    [fun2, { suposVersion: '2.7.0' }],
    [fun3, { suposVersion: '3.0.0', tfClient: 'mobile' }],
    [fun4, { tfClient: 'mobile' }],
]);

matchFunction

封装一个函数,在执行时自动匹配

参数

参数 类型 含义 默认 必须
defaultFunction any 默认函数
functionList array[] 根据全域变量待匹配的函数列表

案例

const fun = matchFunction(fun1, [
    [fun2, { suposVersion: '2.7.0' }],
    [fun3, { suposVersion: '3.0.0', tfClient: 'mobile' }],
    [fun4, { tfClient: 'mobile' }],
]);

fun();

compareSuposVersion

与当前环境supos版本进行比较

参数

参数 类型 含义 默认 必须
version string 待比较的版本号
operator string 比较符号 >=

案例

const matchV30 = compareSuposVersion('3.0.0');
const lessV30 = compareSuposVersion('3.0.0', '<');

Readme

Keywords

Package Sidebar

Install

npm i @suplink/tf-base

Weekly Downloads

0

Version

0.1.6

License

ISC

Unpacked Size

19.5 kB

Total Files

12

Last publish

Collaborators

  • suplinks