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 🙏

© 2026 – Pkg Stats / Ryan Hefner

uniapp-routerx

v1.2.46

Published

为uniapp项目适配路由管理

Readme

Uniapp-routerx

1. 安装

// 使用pnpm安装
pnpm add uniapp-routerx

2. 在vite中使用

import { defineConfig } from 'vite';
import AutoImport from 'unplugin-auto-import/vite';
// 1. 引入模块
import { UniAppRouter, uniappRouterxAutoImport } from 'uniapp-routerx/vite';

export default defineConfig(async () => {
  return {
    plugins:[
      // 2. 在uni之前使用,并配置ts类型文件地址
      UniAppRouter({
        dts: 'src/types/route.d.ts'
      }),
      AutoImport({
        // 3. 配置自动导入(可选)
        imports:['vue', 'pinia', uniappRouterxAutoImport]
      }),
      uni()
    ]
  };
});

3. 创建路由配置

在项目根目录创建 route.config.ts,并返回 route 和 tabbarRoute

route.config.ts配置案例

path 路径中,开头的 斜杠 可加可不加,在内部会进行统一处理

import { IRoute } from 'uniapp-routerx';

/**
 * 路由配置
 */
const route: IRoute[] = [
  {
    path: '/src/pages/config/index',
    name: 'config',
    meta: {
      des: '配置页面,加载小程序内需要用的配置信息,全部加载完毕后,才可进入主页'
    }
  }
];

/**
 * tabbar 路由配置
 */
const tabbarRoute = [
  {
    path: 'src/pages/index/index',
    name: 'index',
    meta: {
      title: '主页'
    }
  },
  {
    path: 'src/pages/mine/index',
    name: 'mine',
    meta: {
      title: '我的页面'
    }
  }
];

export default {
  route,
  tabbarRoute
};

IRoute类型说明

/**
 * UniApp 路由接口定义
 * 用于规范路由对象的结构
 */
interface IRoute {
    /** 页面路径 */
    path: string;
    /** 路由名称 */
    name: string;
    /** 是否为 tabbar 路由 */
    isTabbar?: boolean;
    /** 路由元信息 */
    meta?: {
        /** 页面标题 */
        title?: string;
        /** 描述 */
        des?: string;
    };
}

4. 在 main.js 中初始化

// 1. 引入路由配置
import routerConfig from './route.config.ts';
// 2. 引入宏函数
import { defineRouter } from 'uniapp-routerx';
// 3. 初始化路由配置
defineRouter(routerConfig);

5. 在页面中使用

UniRouter.navigateTo(UniPages.index);

API

UniRouter

| 函数名称 | 参数 | 描述 | | ---------- | ------------------ | :----------------------------- | | navigateTo | route,类型 IRoute | 跳转至任意页面,包括tabbar页面 | | | | | | | | |

UniPages

在模块内部,会把普通页面和tabbar页面的路由合并,组装到该对象内,键为路由的name,值为路由对象

案例

// 原始路由
const route: IRoute[] = [
  {
    path: '/src/pages/config/index',
    name: 'config',
    meta: {
      des: '配置页面,加载小程序内需要用的配置信息,全部加载完毕后,才可进入主页'
    }
  }
];
const tabbarRoute = [
  {
    path: 'src/pages/index/index',
    name: 'index',
    meta: {
      title: '主页'
    }
  },
  {
    path: 'src/pages/mine/index',
    name: 'mine',
    meta: {
      title: '我的页面'
    }
  }
];

// 聚合后的UniPages对象内容
const UniPages = {
 config:{
    path: '/src/pages/config/index',
    name: 'config',
    meta: {
      des: '配置页面,加载小程序内需要用的配置信息,全部加载完毕后,才可进入主页'
    }
  },
  index: {
    path: 'src/pages/index/index',
    name: 'index',
    meta: {
      title: '主页'
    }
  },
  mine: {
    path: 'src/pages/mine/index',
    name: 'mine',
    meta: {
      title: '我的页面'
    }
  }
}