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

jyfe-ui2

v1.0.5

Published

``` npm install jyfe-ui2 ``` ### 组件使用示例 ```` <template> <div> <h1>用户列表</h1> <EnhancedDataTable :searchFields="searchFields" :tableColumns="tableColumns" :fetchData="fetchUserData"

Downloads

4

Readme

安装

npm install jyfe-ui2

组件使用示例

<template>
    <div>
        <h1>用户列表</h1>
        <EnhancedDataTable
                :searchFields="searchFields"
                :tableColumns="tableColumns"
                :fetchData="fetchUserData"
                :showSelection="true"
                :showOperations="true"
                :operations="tableOperations"
                :checkPermission="checkPermission"
                @selection-change="handleSelectionChange"
        >
            <!-- 自定义搜索slot -->
            <template v-slot:customSearch="{ form, field }">
                <el-input v-model="form[field.prop]" :placeholder="field.placeholder">
                    <el-button slot="append" icon="el-icon-search"></el-button>
                </el-input>
            </template>

            <!-- 自定义列slot -->
            <template #operateTable>
                <el-button>操作</el-button>
            </template>

            <!-- 自定义列slot -->
            <template v-slot:customColumn="{ row }">
                <el-tag :type="row.status === 'active' ? 'success' : 'danger'">
                    {{ row.status }}
                </el-tag>
            </template>
        </EnhancedDataTable>
    </div>
</template>

<script>
import EnhancedDataTable from '@/components/table/EnhancedDataTable.vue'

export default {
    components: {
        EnhancedDataTable
    },
    data() {
        return {
            searchFields: [
                { label: '用户名', prop: 'username', type: 'input' },
                { label: '邮箱', prop: 'email', type: 'input' },
                {
                    label: '角色',
                    prop: 'role',
                    type: 'select',
                    fetchOptions: this.fetchRoleOptions
                },
                {
                    label: '地区',
                    prop: 'region',
                    type: 'cascader',
                    props: {
                        value: 'code',
                        label: 'name',
                        children: 'items'
                    },
                    fetchOptions: this.fetchRegionOptions
                },
                { label: '注册日期', prop: 'registrationDate', type: 'date' },
                { label: '活跃时间范围', prop: 'activeRange', type: 'datetimerange' },
                {
                    label: '状态',
                    prop: 'status',
                    type: 'radio',
                    options: [
                        { label: '全部', value: '' },
                        { label: '活跃', value: 'active' },
                        { label: '禁用', value: 'disabled' }
                    ]
                },
                {
                    label: '自定义搜索',
                    prop: 'customSearch',
                    type: 'slot',
                    slotName: 'customSearch',
                    placeholder: '请输入自定义搜索内容'
                }
            ],
            tableColumns: [
                { prop: 'id', label: 'ID', width: '80' },
                { prop: 'username', label: '用户名' },
                { prop: 'email', label: '邮箱' },
                { prop: 'role', label: '角色' },
                { prop: 'region', label: '地区' },
                { prop: 'registrationDate', label: '注册日期', formatter: this.formatDate },
                { prop: 'status', label: '状态', slot: true, slotName: 'customColumn' }
            ],
            tableOperations: [
                { name: '编辑', type: 'primary', handler: this.handleEdit },
                { name: '删除', type: 'danger', handler: this.handleDelete }
            ]
        }
    },
    methods: {
        async fetchUserData(params) {
            console.log('params:', params)
            // 模拟 API 调用
            return new Promise(resolve => {
                setTimeout(() => {
                    resolve({
                        data: [
                            { id: 1, username: 'user1', email: '[email protected]', role: 'admin', region: '中国/广东/深圳', registrationDate: '2023-01-01', status: 'active' },
                            { id: 2, username: 'user2', email: '[email protected]', role: 'user', region: '中国/北京/朝阳', registrationDate: '2023-02-15', status: 'disabled' },
                        ],
                        total: 2
                    })
                }, 1000)
            })
        },
        async fetchRoleOptions() {
            // 模拟从服务器获取角色选项
            return new Promise(resolve => {
                setTimeout(() => {
                    resolve([
                        { value: 'admin', label: '管理员' },
                        { value: 'user', label: '普通用户' },
                        { value: 'guest', label: '访客' }
                    ])
                }, 500)
            })
        },
        async fetchRegionOptions() {
            // 模拟从服务器获取地区选项
            return new Promise(resolve => {
                setTimeout(() => {
                    resolve([
                        {
                            code: 'china',
                            name: '中国',
                            items: [
                                {
                                    code: 'guangdong',
                                    name: '广东',
                                    items: [
                                        { code: 'shenzhen', name: '深圳' },
                                        { code: 'guangzhou', name: '广州' }
                                    ]
                                },
                                {
                                    code: 'beijing',
                                    name: '北京',
                                    items: [
                                        { code: 'chaoyang', name: '朝阳' },
                                        { code: 'haidian', name: '海淀' }
                                    ]
                                }
                            ]
                        }
                    ])
                }, 500)
            })
        },
        formatDate(row, column, cellValue) {
            return new Date(cellValue).toLocaleDateString()
        },
        handleEdit(row) {
            console.log('Editing:', row)
        },
        handleDelete(row) {
            console.log('Deleting:', row)
        },
        handleSelectionChange(selectedRows) {
            console.log('Selected rows:', selectedRows)
        },
        checkPermission(permission, row) {
            // 这里应该实现实际的权限检查逻辑
            // 现在只是一个示例,始终返回 true
            return true
        }
    }
}
</script>