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

@g-tech/gtech-ui

v0.0.17

Published

Component Library By GTech

Downloads

23

Readme

GTech-UI

开始使用

引入

import Vue from 'vue';
// UI
import GTechUI from "@g-tech/gtech-ui"
// 样式
import "@g-tech/gtech-ui/dist/theme-chalk/index.css"
import App from './App.vue';

Vue.use(GTechUI);

new Vue({
  el: '#app',
  render: h => h(App)
});

多语言

默认使用中文

Vue.use(GTechUI)

更换默认语言

目前仅支持 en | zh-TW | zh-CN

import enLocale from "@g-tech/gtech-ui/dist/locale/en";

// 这里以默认使用英文为例
Vue.use(GTechUI,{
		locale: enLocale  
})

使用vue-i18n

仅支持使用vue-i18n,且版本 > 6.x

// entry file
import Vue from 'vue'
import App from './App.vue'
// 使用vue-i18n
import VueI18n from 'vue-i18n';
// UI
import GTechUI from "@g-tech/gtech-ui"
// 引入语言包
import enLocale from "@g-tech/gtech-ui/dist/locale/en";
import zhTWLocale from "@g-tech/gtech-ui/dist/locale/zh-TW";
import zhCNLocale from "@g-tech/gtech-ui/dist/locale/zh-CN";
// sheet
import "@g-tech/gtech-ui/dist/theme-chalk/index.css"

Vue.config.productionTip = false

Vue.use(VueI18n);

const i18n = new VueI18n({
  locale: localStorage.language || 'zh-CN',
  messages: {
    'zh-CN': {
      ...zhCNLocale,
    },
    en: {
      ...enLocale,
    },
    'zh-TW': {
      ...zhTWLocale,
    },
  },
});

Vue.use(GTechUI, {
  i18n: (key, value) => i18n.t(key, value),
});

new Vue({
  render: h => h(App),
  i18n
}).$mount('#app')

当需要切换到其他语言时候

// other file
localStorage.setItem('language', lang)
window.location.reload()

这里将多语言的使用类型简单的放到了localStorage中,方便代码的演示。最佳实践是将i18n实例放到vuex状态管理中。当需要切换语言时候,提交mutation以达到页面不刷新的情况下实现语言切换

// i18n.js
import Vue from 'vue';
import VueI18n from 'vue-i18n';
import enLocale from '../src/locale/lang/en';
import zhTWLocale from '../src/locale/lang/zh-TW';
import zhCNLocale from '../src/locale/lang/zh-CN';

Vue.use(VueI18n);

// 这里可以将项目的 messages 和 GTechUI的locale合并
export default new VueI18n({
  locale: localStorage.lang || 'zh-CN',
  messages: {
    'zh-CN': {
      root: {
        home: {
          back_to_home: '返回首页',
          switch_lang: '切换语言',
        },
      },
      ...zhCNLocale,
    },
    en: {
      root: {
        home: {
          back_to_home: 'Go back home',
          switch_lang: 'Switch Language',
        },
      },
      ...enLocale,
    },
    'zh-TW': {
      root: {
        home: {
          back_to_home: '返回主页',
          switch_lang: '切換語言',
        },
      },
      ...zhTWLocale,
    },
  },
});
// store.js
import Vue from 'vue';
import Vuex from 'vuex';
import i18n from './i18n';

Vue.use(Vuex);

export default new Vuex.Store({
 state: {
 		i18n,
 },
 mutations: {
 		resetLocale(payload, value) {
 			payload.i18n.locale = value;
 		},
});
// 在需要切换语言的地方
{
  methods:{
    switchLanguage(){
      this.$store.commit('resetLocale', 'en'// other language type)
    }
  }
}

开发

Eslint

  • Use // eslint-disable-next-line to ignore the next line.
  • Use /* eslint-disable */ to ignore all warnings in a file.

样式

  • 使用BEM命名

行动项

  • [ ] 文档方案
  • [x] 样式表可单独引入
  • [ ] 模块化引入方案
  • [x] 多语言方案
  • [ ] 新增组件的脚本工具