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

@dragonfly-js/seed

v1.0.0

Published

This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.

Downloads

2

Readme

Dragonfly 种子工程

使用方法

开始调试

进入项目根目录,运行 npm run start 命令,启动开发服务器。

在浏览器中访问 http://localhost:5173/,可以看到 dragonfly 应用已经正常启动。

构建生产包

运行 npm run build 执行项目编译,默认在 dist 目录下输出构建生产包。

代码检查

进入项目根目录,可执行以下命令进行多种文件格式的代码检查,默认检查 src 目录下的文件

# typescript 文件
npm run check-ts
npm run fix-ts

# scss,css 文件
npm run check-css
npm run fix-css

# html 文件
npm run check-html
npm run fix-html

通过执行 npm run format 对代码做代码风格格式化。

单元测试

Dragonfly 内置 Jest 和 @vue/test-utils 测试库,提供单元测试、组件/页面集成测试等功能。

src/__tests__ 目录下编写测试用例。

执行 npm run test:unit,会运行项目下所有的测试用例。

目录结构

|-- dist // 生产构建输出目录
|-- node_modules // 第三方依赖安装目录
|-- public // 第三方静态资源文件存放目录
|-- scripts // 定制化执行脚本
   |-- postBuild.js
|-- src // 源代码存放目录
   |-- __tests__ // 单元测试用例
   |-- assets // 静态资源文件
   |-- components // 公共组件
   |-- frameworks // 整体框架文件
   |-- i18n // 国际化文件
   |-- models // 常量类或数据类型文件
   |-- router // 路由定义文件
   |-- services // 公用逻辑处理或utils类文件
   |-- store // 数据存储操作文件
   |-- views // 页面层级组件
   |-- App.vue
   |-- main.ts
   |-- style.scss
   |-- typing.d.ts
   |-- vite-env.d.ts

国际化

Dragonfly 应用支持多语言切换即国际化功能,国际化资源文件存放在 src/i18n 目录下。

按照地域标识码规范,一个 json 文件对应一种语言,如 zh-CN 对应中文,en-US 对应英文。

src/frameworks/Framework.vue 下有一个基于 piniavue-i18n 实现国际化动态切换的示例:

<script setup lang="ts">
import { useI18n } from 'vue-i18n';
import pinia from '@/store/store';
import { useDataChangeStore } from '@/store/data-change';
import ProjectHeader from '@/components/ProjectHeader.vue';
const $i18n = useI18n();

const dataStore = useDataChangeStore(pinia);

dataStore.$subscribe((mutation) => {
  const data = mutation.events as any;
  if (data.key === 'lang') {
    const langMap = {
      'zh': 'zh-cn',
      'en': 'en-us',
    }
    const newLang = langMap[data.newValue as 'zh' | 'en'];
    if (newLang) {
      localStorage.setItem('lang', newLang);
      $i18n.locale = newLang as any;
      window.location.reload();
    }
  }
});

$i18n.locale = 'zh-cn' as any;
setTimeout(() => {
  $i18n.locale = 'en-us' as any;
}, 3000);

</script>

使用国际化文件只需要用 $t(key) 方法即可,如:

<template>
   <p>{{ $t('home.title') }}</p>
</template>

主题切换

Dragonfly 应用基于 DevUI Theme 提供的强大的主题定制方案能力,封装了多主题切换的功能:

// main.ts

// ...
import { ThemeServiceInit, devuiLightTheme, devuiDarkTheme, devuiGreenTheme, devuiGreenDarkTheme, ThemeService } from 'devui-theme';

const themeService = ThemeServiceInit(
  {
    'light-theme': devuiLightTheme,
    'dark-theme': devuiDarkTheme,
    'green-theme': devuiGreenTheme,
    'green-dark-theme': devuiGreenDarkTheme,
  },
  'light-theme'
) as ThemeService;
themeService.applyTheme(devuiLightTheme);

dataStore.$subscribe((mutation) => {
  const data = mutation.events as any;
  if (data.key === 'theme') {
    const themeMap = {
      light: devuiLightTheme,
      dark: devuiDarkTheme,
    };
    const newTheme = themeMap[data.newValue as 'light' | 'dark'];
    if (newTheme) {
      themeService.applyTheme(newTheme);
    }
  }
});

更多使用方法请参看:

参考链接

DevUI:

Vue: