npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

sws-micro-app-adapter-mobile

v0.0.19

Published

SWS移动端微应用适配器

Downloads

159

Readme

SWS微应用适配器

用于快速接入SWS TIME APP的微应用适配器

API

1. 获取微应用运行环境

import {getRuntimeEnvironment} from "sws-micro-app-adapter-mobile";

// h5 or cordova
const runtimeEnvironment = getRuntimeEnvironment(); 

2. 挂载微应用

支持独立运行在浏览器中,但需要提前调用login方法,进行用户信息初始化

import {mountApp} from "sws-micro-app-adapter-mobile";

mountApp(() => {
    // initial app
});

3. 卸载微应用

import {unmountApp} from "sws-micro-app-adapter-mobile";

unmountApp(() => {
    // destroy app
});

4. 获取用户信息

import {getUserInfo} from "sws-micro-app-adapter-mobile";

const userInfo = getUserInfo();

5. 获取访问Token

import {getAccessToken} from "sws-micro-app-adapter-mobile";

const accessToken = getAccessToken();

6. 获取APP配置数据

import {getAppConfig} from "sws-micro-app-adapter-mobile";

getAppConfig("appId").then(configData => {
    console.log(configData);
})

7. 登录

用于开发时让微应用独立在浏览器中运行,不建议在生产中使用

import {login} from "sws-micro-app-adapter-mobile";

login("工号", "密码").then(userInfo => {
    console.log(userInfo);
})

8. 扫码

import {scanCode} from "sws-micro-app-adapter-mobile";

scanCode().then(data => {
    console.log(data);
})

9. 获取当前的地理位置

import {getLocation} from "sws-micro-app-adapter-mobile";

getLocation().then(data => {
    console.log(data);
})

10. 获取设备语言

import {getLocale} from "sws-micro-app-adapter-mobile";

getLocale().then(data => {
    console.log(data);
})

11. 获取设备颜色模式

import {getColorMode} from "sws-micro-app-adapter-mobile";

getColorMode().then(data => {
    console.log(data); // light or dark
})

12.监听设备颜色模式的改变

import {onColorModeChange} from "sws-micro-app-adapter-mobile";

onColorModeChange((colorMode) => {
    console.log(colorMode); // light or dark
})

12. 获取设备的生物认证方式

import {getSupportBiometricAuthentication} from "sws-micro-app-adapter-mobile";

getSupportBiometricAuthentication().then(data => {
    console.log(data); // facial or fingerPrint
})

13. 调用设备进行生物认证

import {startBiometricAuthentication} from "sws-micro-app-adapter-mobile";

startBiometricAuthentication().then(data => {
    // 生物认证成功
})

14. 从文件系统中读取指定路径的文件

import {readFile} from "sws-micro-app-adapter-mobile";

readFile("filePath").then(file => {
    console.log(file);
})

15. 拍摄照片

import {takePhoto} from "sws-micro-app-adapter-mobile";

takePhoto().then(image => {
    // 将File对象转换成DataURL
    const fileReader = new FileReader();
    fileReader.readAsDataURL(image);
    fileReader.onload = function(e) {
        console.log(e.target.result);
    };
})

16. 录制视频

import {recordVideo} from "sws-micro-app-adapter-mobile";

recordVideo().then(video => {
    // 将File对象转换成DataURL
    const fileReader = new FileReader();
    fileReader.readAsDataURL(video);
    fileReader.onload = function(e) {
        console.log(e.target.result);
    };
})