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

electra-element-ui

v0.0.7

Published

基于 Element-UI 封装的 Electra 后台项目共用组件库 <br />

Downloads

14

Readme

Electra-Element-UI

基于 Element-UI 封装的 Electra 后台项目共用组件库

目录

一、安装步骤

1. Install package

npm install electra-element-ui

2. Install 一个辅助解析的包(安装在 dev 环境即可)

npm install -save-dev @babel/plugin-transform-modules-commonjs

3. 在 vue.config.js 文件中添加如下配置

module.exports = {
    transpileDependencies: ['element-ui']
}

二、文件目录说明

filetree 
├── node_modules
├── src/
├──├── /assets/
│  ├── /components/         // 组件都放在这里,具体的封装方式参考已有组件
│  │  ├── date-picker
├── .babelrc
├── .eslintignore
├── index.js                // 整个项目的入口文件,封装的组件在这里引入并export
├── package-lock.json
├── package.json
├── README.md
└── vue.config.js

三、组件使用说明

my-date-picker 组件使用说明

1. 组件说明

本组件基于 element-ui 组件库中的 el-date-picker 开发,实现了可以在时间选择面板中选择时区,点击确定时可直接拿到根据已选时区计算好的 timestamp 值,可正常回显时区与时间。

2. 封装解释

在 el-date-picker 基础之上改动部分:

  • 增加 timezone 属性,用于初次展示或回显展示,非必传,默认为 Europe/London
  • value-format 属性需指定为 "yyyy-MM-dd HH:mm:ss",所以组件回显时需要按时区计算并进行一次格式转换(timestamp -> 'yyyy-MM-dd HH:mm:ss'),具体见示例代码
  • 修改 input 事件的返回值:增加 timezone 返回值,且时间格式为 timestamp,返回值示例如下:
{
    timeZoneId: 'Europe/London',
    time: [1629275540000, 1629275540000]
}

3. 使用示例

<template>
    <my-date-picker
        v-model="timeRange"
        type="datetimerange"
        :clearable="false"
        value-format="yyyy-MM-dd HH:mm:ss"
        start-placeholder="Start Time"
        end-placeholder="End Time"
        :timezone="timezone"
        @input="handleDateChange"
    />
</template>

<script>
import moment from 'moment-timezone'
import { MyDatePicker } from 'electra-element-ui'
export default {
    components: { MyDatePicker },
    data() {
        return {
            timezone: '',
            timeRange: ['', '']
        }
    },
    methods: {
        handleDateChange(val, obj) {
            const { timeZoneId, time } = obj
            console.log('Current Timezone:', timeZoneId)
            console.log('Start Time:', time[0])
            console.log('End Time:', time[1])
        },

        // 注意回显时需要按时区计算时间并转换为 yyyy-MM-dd HH:mm:ss 格式
        getData() {
            const formData = {
                startTime: 1629275540000,
                endTime: 1629275540000
            }
            const start = this.convertUtcToLocalStr(formData.startTime, this.timezone)
            const end = this.convertUtcToLocalStr(formData.endTime, this.timezone)
            this.timeRange = [start, end]
        },

        convertUtcToLocalStr(val, timeZoneId) {
            return moment(val).tz(timeZoneId).format('YYYY-MM-DD HH:mm:ss')
        }
    }
}