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

dong-composables

v1.0.1

Published

A TypeScript React component library with Vue 3 support

Readme

Dong Composables

一个基于 Vue 3 的 TypeScript 组合式函数库,提供了常用的业务组件和工具函数,特别集成了 Ant Design Vue 的列表组件混入功能。

简介

Dong Composables 是一个轻量级的 Vue 3 组合式函数库,专注于提供可复用的业务逻辑。该库主要包含以下功能:

该库支持 Vue 3 和 React 混合使用,具有良好的类型安全性和可扩展性。

特性

  • 🚀 TypeScript 支持: 完整的类型定义,提供优秀的开发体验
  • 📦 轻量级: 专注于核心功能,保持库的轻量级
  • 🔧 易于使用: 简单的 API 设计,快速上手
  • 🎨 Ant Design 集成: 与 Ant Design Vue 无缝集成
  • 🧪 测试覆盖: 包含完整的单元测试

安装

npm install dong-composables
# 或
yarn add dong-composables
# 或
pnpm add dong-composables

快速开始

使用 dongAntListMixin

dongAntListMixin 提供了完整的列表页面功能,包括分页、搜索、排序、增删改查等:

typescript
import { dongAntListMixin } from 'dong-composables';

// 定义数据类型
interface User {
id: string;
name: string;
createTime: string;
}

// 创建混入实例
const {
queryParam,
loading,
dataSource,
Pagination,
url,
handleAdd,
handleEdit,
handleDetails,
handleDel,
loadData
} = dongAntListMixin<User>();

// 配置接口地址
url.value = {
listAction: (params) => fetchUserList(params), // 列表接口
deleteAction: (record) => deleteUser(record), // 删除接口
deleteBatchAction: (params) => batchDeleteUser(params) // 批量删除接口
};

// 加载数据
loadData();

使用 getCurrentTimeInFormat

时间格式化工具函数,支持多种格式:

typescript
import { getCurrentTimeInFormat } from 'dong-composables';

// 基本用法
const time1 = getCurrentTimeInFormat('YYYY-MM-DD hh:mm:ss A');
// 返回 '2023-06-15 05:49:38 PM'

// 使用12小时制
const time2 = getCurrentTimeInFormat('MM/DD/YYYY h:m a');
// 返回 '06/15/2023 5:49 pm'

// 使用24小时制
const time3 = getCurrentTimeInFormat('YYYY-MM-DD HH:mm:ss');
// 返回 '2023-06-15 17:49:38'

API 文档

dongAntListMixin<T>(disableCreated = false)

创建一个列表页面混入实例。

参数

  • disableCreated: 是否禁用初始化加载,默认为 false

返回值

返回一个包含以下属性和方法的对象:

属性
方法

getCurrentTimeInFormat(format, nowDate)

获取当前时间并按照指定格式返回。

参数

  • format: 时间格式字符串,默认为 'YYYY-MM-DD hh:mm:ss'
  • nowDate: 当前时间对象,默认为当前时间

格式占位符

  • YYYY: 4位数年份
  • MM: 2位数月份(带前导零)
  • M: 月份(不带前导零)
  • DD: 2位数日期(带前导零)
  • D: 日期(不带前导零)
  • hh: 2位数小时(若格式中包含 'A' 或 'a',自动使用12小时制,带前导零)
  • h: 小时(若格式中包含 'A' 或 'a',自动使用12小时制)
  • mm: 2位数分钟(带前导零)
  • m: 分钟(不带前导零)
  • ss: 2位数秒(带前导零)
  • s: 秒(不带前导零)
  • SSS: 3位数毫秒(带前导零)
  • A: 大写 AM 或 PM
  • a: 小写 am 或 pm

构建

项目使用 Vite 进行构建:

bash
# 构建库
npm run build

# 运行测试
npm run test

# 运行测试并监听变化
npm run test:watch

# 检查代码
npm run lint:eslint

# 格式化代码
npm run format

测试

项目使用 Vitest 进行单元测试,测试文件位于 src/**/test/ 目录下。

贡献

欢迎提交 Issue 和 Pull Request 来改进项目。

许可证

MIT



## 项目结构

src/ ├── composables/ # 组合式函数 │ └── dongAntListMixin/ # 列表混入函数 │ ├── index.ts # 主要实现 │ └── test/ # 测试文件 ├── utils/ # 工具函数 │ └── index.ts # 时间格式化工具 └── index.ts # 入口文件



这个 README.md 文件全面介绍了项目,包括其功能、使用方法和API文档,基于项目文件的实际内容编写。