Skip to content

Commit

Permalink
fix(cli,ui): 支持组件库,文档i18n
Browse files Browse the repository at this point in the history
affects: @varlet/cli, @varlet/eslint-config, @varlet/ui
  • Loading branch information
齐皓 authored and 齐皓 committed Feb 26, 2021
1 parent 0c5893d commit b76e664
Show file tree
Hide file tree
Showing 126 changed files with 536 additions and 336 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
"packages/varlet-ui/es/**",
"packages/varlet-ui/cjs/**",
"packages/varlet-ui/umd/**",
"packages/varlet-ui/src/*/__tests__/**"
"packages/varlet-ui/src/*/__tests__/**",
"packages/varlet"
],
"extends": [
"@varlet"
Expand Down
33 changes: 0 additions & 33 deletions packages/varlet-cli/README.md

This file was deleted.

1 change: 0 additions & 1 deletion packages/varlet-cli/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ commander_1.command('dev').description('Run varlet development environment').act
commander_1.command('build').description('Build varlet site for production').action(build_1.build);
commander_1.command('compile')
.description('Compile varlet components library code')
.option('-w, --watch', 'Watch files change auto compile')
.action(compile_1.compile);
commander_1.command('create <name>').description('Create a component directory').action(create_1.create);
commander_1.command('jest')
Expand Down
8 changes: 4 additions & 4 deletions packages/varlet-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@
"files": [
"lib",
"site",
"../varlet-ui/shims-vue.d.ts",
"../varlet-ui/shims-md.d.ts",
"tsconfig.json",
"varlet.default.config.js"
"varlet.default.config.js",
"CHANGELOG.md"
],
"repository": {
"type": "git",
Expand All @@ -39,17 +38,18 @@
"@babel/preset-typescript": "^7.12.1",
"@testing-library/vue": "^6.0.0",
"@varlet/markdown-loader": "^0.7.0",
"@varlet/ui": "^0.7.0",
"@vue/compiler-sfc": "^3.0.2",
"autoprefixer": "9",
"babel-jest": "^26.6.3",
"babel-loader": "^8.1.0",
"chalk": "^4.1.0",
"chokidar": "^3.4.3",
"clean-webpack-plugin": "^3.0.0",
"clipboard": "^2.0.6",
"commander": "^6.2.0",
"compression-webpack-plugin": "^7.1.2",
"css-loader": "^5.0.0",
"execa": "^5.0.0",
"file-loader": "^6.2.0",
"fork-ts-checker-webpack-plugin": "^5.2.1",
"fs-extra": "^9.0.1",
Expand Down
48 changes: 26 additions & 22 deletions packages/varlet-cli/site/pc/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,66 +65,70 @@
</template>

<script lang="ts">
import { defineComponent, ref, Ref, getCurrentInstance, watch } from 'vue'
import Ripple from '../../../varlet-ui/src/ripple'
// @ts-ignore
import config from '@config'
import Ripple from '@varlet/ui/es/ripple'
import '@varlet/ui/es/ripple/style'
import Cell from '@varlet/ui/es/cell'
import '@varlet/ui/es/cell/style'
import { defineComponent, ref, Ref, watch } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import Cell from '../../../varlet-ui/src/cell'
type Menu = {
isTitle: boolean
doc: string
text: Record<string, string>
}
type Header = {
i18nButton: Record<string, string>
logo: string
search: Record<string, string>
}
export default defineComponent({
directives: { Ripple },
components: {
[Cell.name]: Cell,
},
setup() {
type Menu = {
isTitle: boolean
doc: string
text: Record<string, string>
}
type Header = {
i18nButton: Record<string, string>
logo: string
search: Record<string, string>
}
const menu: Ref<Menu[]> = ref([])
const language: Ref<string> = ref('')
const header: Ref<Header> = ref({ i18nButton: {}, logo: '', search: {} })
const componentName = ref('button')
const title: Ref<string> = ref('')
const versionList: Ref<string[]> = ref()[('2.10.14', '1.x', '3.x')]
const isHideVersion: Ref<boolean> = ref(true)
const config = getCurrentInstance().appContext.config.globalProperties.$config
const { pc = {}, title: configTitle } = config
const { pc = {}, title: configTitle, language: configLanguage } = config
const {
header: configHeader = { i18nButton: {}, logo: '', search: {} },
menu: configMenu = [],
language: configLanguage,
} = pc
menu.value = configMenu
language.value = configLanguage
header.value = configHeader
title.value = configTitle
const route = useRoute()
const router = useRouter()
const switchLanguage = () => {
language.value = language.value === 'zh_CN' ? 'en_US' : 'zh_CN'
language.value = language.value === 'zh-CN' ? 'en-US' : 'zh-CN'
const pathArr = route.fullPath.split('/')
const componentName = pathArr[pathArr.length - 1]
router.push(`/${language.value}/${componentName}`)
}
const changeRoute = (item) => {
if (item.isTitle) {
return false
}
router.push(`/${language.value}/${item.doc}`)
}
console.log(header.value)
watch(
() => route.path,
(to: string) => {
const index = to.lastIndexOf('/')
componentName.value = to.slice(index + 1)
}
(to: string) => componentName.value = to.slice(to.lastIndexOf('/') + 1)
)
return {
menu,
Expand Down
3 changes: 0 additions & 3 deletions packages/varlet-cli/site/pc/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import App from './App.vue'
import '@varlet/touch-emulator'
// @ts-ignore
import routes from '@pc-routes'
// @ts-ignore
import config from '@config'

const router = createRouter({
history: createWebHashHistory(),
Expand All @@ -14,5 +12,4 @@ const router = createRouter({

const app = createApp(App as any)

app.config.globalProperties.$config = config
app.use(router).mount('#app')
Loading

0 comments on commit b76e664

Please sign in to comment.