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

generate-routes-yuri

v0.0.4

Published

生成vue-router的代码

Downloads

4

Readme

generate-routes-yuri

生成vue-router的代码

1 示例

请注意: “组件名称”标记在文件路径后

- components
-- loading
--- css
--- Index.vue               // Loading
-- order
--- Index.vue.             // Order
--- Detail.vue             // OrderDetail
-- user
--- login
---- admin
----- Index.vue             // UserLoginAdmin
----- SubAccount.vue        //UserLoginAdminSubAccount
---- Index.vue              // UserLogin
--- UserInfo.vue            //UserInfo

1.1 routes

const routes = [
  { path: "/loading", name: "Loading", component: () => import("@/components/loading/Index.vue") }, 
  { path: "/order", name: "Order", component: () => import("@/components/order/Index.vue") }, 
  { path: "/order/detail", name: "OrderDetail", component: () => import("@/components/order/Detail.vue") }, 
  { path: "/user/userInfo", name: "UserInfo", component: () => import("@/components/user/UserInfo.vue") }, 
  { path: "/user/login", name: "UserLogin", component: () => import("@/components/user/login/Index.vue") }, 
  { path: "/user/login/admin", name: "UserLoginAdmin", component: () => import("@/components/user/login/admin/Index.vue") }, 
  { path: "/user/login/admin/subAccount", name: "UserLoginAdminSubAccount", component: () => import("@/components/user/login/admin/SubAccount.vue") } 
]

1.2 router-link

<router-link to="/loading">Loading</router-link> 
<router-link to="/order">Order</router-link> 
<router-link to="/order/detail">OrderDetail</router-link> 
<router-link to="/user/userInfo">UserInfo</router-link> 
<router-link to="/user/login">UserLogin</router-link> 
<router-link to="/user/login/admin">UserLoginAdmin</router-link> 
<router-link to="/user/login/admin/subAccount">UserLoginAdminSubAccount</router-link>

2 安装与使用

yarn add -D generate-routes-yuri

案例与测试:github

这个工具项目的功能相对简单,更新频率会很低。如果下次更新间隔太久,需要升级所有的依赖。为了方便,记录重构过程

# 1 请再次确认项目根目录
√~ % pwd
/Users/yuri/workspace/idea/study/reactive-system/vue3-demo/dev-tools/generate-routes/core

# 2 升级(重装依赖)
## 2.1 删除所有依赖
yarn remove @types/lodash lodash @types/node @rollup/plugin-typescript @typescript-eslint/eslint-plugin @typescript-eslint/parser @vitest/coverage-c8 deep-object-diff typescript ts-node vite vite-plugin-dts vitest 

## 2.2 重装
yarn add @types/lodash lodash
yarn add -D @types/node @rollup/plugin-typescript @typescript-eslint/eslint-plugin @typescript-eslint/parser @vitest/coverage-c8 deep-object-diff typescript ts-node vite vite-plugin-dts vitest 

# 3 删除文件/目录
√~ % rm -rf .idea yarn.lock coverage dist node_modules

# 4 重新构建
√~ % yarn

3 约定(组件命名方式)

3.1 自定义组件名称

<script setup lang="ts">
defineOptions({
  name: "Loading",
})
</script>

3.2 目录结构为组件名称

以订单组件为例,目录 /components/order,包含两个页面:

  • 首页,显示订单列表

  • 点击订单编号,显示订单详情

| | 首页 | 详情页 | | ---- | --------- | ----------- | | 文件名 | Index.vue | Detail.vue | | 组件名称 | Order | OrderDetail | | 规则描述 | 目录名称 | 目录名称 + 文件名 |

3.3 文件名为组件名称

/components/user/UserInfo.vue,component name为UserInfo