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

@lingxiteam/engine-mobile

v1.0.9-beta.4

Published

灵犀低代码平台-app引擎包

Downloads

162

Readme

使用方法

1、 lcdpApi 发送请求 拦截器 全局配置方法配置方法如下:

  import { lcdpApi } from 'lingxiteam/engine-mobile';

  const request = lcdpApi.fetch;

  const uploadRequest = lcdpApi.fetch;

  request.interceptors.request.use((url, options) => {
    return {
      url: `${url}&interceptors=yes`,
      options: { ...options, interceptors: true },
    };
  });

  request.interceptors.response.use((response, options) => {
    response.headers.append('interceptors', 'yes yo');
    return response;
  });

lcdpApi.fetch导出的是umi-request。具体使用方法可参考:umi-request

2、 更新用户信息

lcdpApi.setData('user', userInfo);


>6.30版本 集成方式

  1. 在入口文件处增加基础配置,示例如下
import { initBasicConfig } from '@lingxiteam/engine-mobile';
import { history, setPageNavBar } from 'alita'

// 设置基础配置(内置组件注册,注入history/setPageNavBar/apis/工具类等)  opts参数如下介绍:
initBasicConfig(opts);

// opts 类型定义
export interface InitialBasicConfig {
  history: any, // 路由管理
  setPageNavBar?: any; // 设置页面导航
  ignoreRegisterComponent?: boolean;  // 是否忽略内置组件注册
}
  1. 路由拦截处合并路由, 例如:基于UMI框架的项目可以到app.ts文件下的render、patchRoutes方法拦截处理
import { beforeRender } from '@lingxiteam/engine-mobile';

let dRoutes: any[] = [];
export function patchRoutes({ routes }: any) {
  let targetRoutes = merge(routes, dRoutes);
  routes[0].routes = targetRoutes;
}

export async function render(oldRender: () => void) {
  try {
    // 返回具体的路由列表
    dRoutes = await renderBefore();
    oldRender();
  } catch(err) {
    oldRender();
  }
}
  1. 开启路由保活(KeepAlive)。 示例:基于Alita框架
import { getKeepAlive } from '@lingxiteam/engine-mobile';

// 需要在config.ts中开启keepalive选项

export {
  getKeepAlive
}
  1. 自定义部分信息回调函数
import { lcdpApi, queryDynamicRoutesService } from '@lingxiteam/engine-mobile';


lcdpApi.handleMessage = {
  login: {
    success: () => {  /*内置登录成功*/ },
    updateRoutes: async (routes: any[], next: (arg0: any[]) => void) => {
      // 登录完成后需要合并路由
      const dynamicRoutes = await queryDynamicRoutesService();
      const targetRoutes = merge(routes, dynamicRoutes);
      routes[0].routes = targetRoutes;
      next(routes);
    }
  },
  auth: {
    fail: () => {
      /* 验证失败 */
    },
    success: (e) => {
      /* 校验成功 */
      const { loginInfo = {} } = e?.resultObject;
      lcdpApi.setData('user', loginInfo || {});
      // 需要更新用户信息
    }
  },
  page: {
    onListener(e){
      console.log("每次页面刷新会触发该回调", e);
    }    
  }
}