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

dd-common-router

v1.0.10

Published

## 目的

Downloads

32

Readme

vue-genre-router

目的

生成 routes 文件 动态路由是 :id 这种

配置文件

dd.config.js

/**
 * @param path 默认layout的目录 默认为 ./src/layout
 * @param defaultLayout 默认未指定layout页面使用的layout 取得是目录下面的文件名称
 * @param pageLayout 可以是正则或者方法 正则会拿match的第一项 方法返回的是字符串
 */
interface ILayoutOpt {
  path?: string;
  defaultLayout?: string;
  pageLayout?: RegExp | ((content: string) => string);
}
module.exports = {
  path: "./src/views", // 默认路由页面代码
  defaultRoutes: "./src/router/routes.ts", // 生成到哪个文件
  exportSuffix: "export default __routes", // 导出方式 文件里有个变量叫 __routes
  layout: ILayoutOpt,
  alias: "@", // 生成路由 由哪个alias
  isLazy: true, // 是否懒加载
  action: { afterGenre: (route: IVueRouter) => IVueRouter }, // 每次生成后的 执行这个方法 可以修改具体的routes
};

使用

配置完成后在 package.json 里面可以通过 dd-router 生成

{
  "scripts": {
    "dev": "cross-env NODE_ENV=development dd-router"
  }
}

指定路由页面的 layout

<script lang="ts" layout="default">
  const _defineMeta = { title: "ddd" }
  去指定路由meta信息

结果

const r_rwek8funts = () => import("@/views/index.vue");
const __routes = [
  {
    path: "/",
    name: "_src_views_indexvue_layout",
    meta: { title: "ddd" },
    children: [
      {
        path: "",
        name: "_src_views_indexvue",
        meta: { title: "ddd" },
        component: r_rwek8funts,
      },
    ],
  },
];
export default __routes;