Skip to content

Commit

Permalink
chore(projects): update version and perf code
Browse files Browse the repository at this point in the history
  • Loading branch information
honghuangdc committed Oct 21, 2023
1 parent 314e813 commit 970352c
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 39 deletions.
23 changes: 2 additions & 21 deletions build/plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import type { PluginOption } from 'vite';
import vue from '@vitejs/plugin-vue';
import vueJsx from '@vitejs/plugin-vue-jsx';
import VueDevtools from 'vite-plugin-vue-devtools';
import ElegantVueRouter from '@elegant-router/vue/vite';
import type { RouteKey } from '@elegant-router/types';
import progress from 'vite-plugin-progress';
import { setupElegantRouter } from './router';
import { setupUnocss } from './unocss';
import { setupUnplugin } from './unplugin';

Expand All @@ -17,25 +16,7 @@ export function setupVitePlugins(viteEnv: Env.ImportMeta) {
}),
vueJsx(),
VueDevtools(),
ElegantVueRouter({
layouts: {
base: 'src/layouts/base-layout/index.vue',
blank: 'src/layouts/blank-layout/index.vue'
},
routePathTransformer(routeName, routePath) {
const key = routeName as RouteKey;

if (key === 'login') {
const modules: UnionKey.LoginModule[] = ['pwd-login', 'code-login', 'register', 'reset-pwd', 'bind-wechat'];

const moduleReg = modules.join('|');

return `/login/:module(${moduleReg})?`;
}

return routePath;
}
}),
setupElegantRouter(),
setupUnocss(viteEnv),
...setupUnplugin(viteEnv),
progress()
Expand Down
24 changes: 24 additions & 0 deletions build/plugins/router.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import ElegantVueRouter from '@elegant-router/vue/vite';
import type { RouteKey } from '@elegant-router/types';

export function setupElegantRouter() {
return ElegantVueRouter({
layouts: {
base: 'src/layouts/base-layout/index.vue',
blank: 'src/layouts/blank-layout/index.vue'
},
routePathTransformer(routeName, routePath) {
const key = routeName as RouteKey;

if (key === 'login') {
const modules: UnionKey.LoginModule[] = ['pwd-login', 'code-login', 'register', 'reset-pwd', 'bind-wechat'];

const moduleReg = modules.join('|');

return `/login/:module(${moduleReg})?`;
}

return routePath;
}
});
}
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@sa/antd",
"version": "2.0.0",
"description": "A fresh and elegant admin template, based on Vue3Vite3,TypeScript,AntDesign and UnoCSS.",
"version": "1.0.0",
"description": "A fresh and elegant admin template, based on Vue3,Vite3,TypeScript,AntDesign and UnoCSS.",
"author": {
"name": "Soybean",
"email": "soybeanjs@outlook.com",
Expand All @@ -21,7 +21,7 @@
"prepare": "simple-git-hooks"
},
"dependencies": {
"@iconify/vue": "^4.1.1",
"@iconify/vue": "4.1.1",
"@sa/hooks": "workspace:*",
"@sa/materials": "workspace:*",
"@sa/utils": "workspace:*",
Expand Down Expand Up @@ -65,7 +65,7 @@
"unplugin-icons": "0.17.1",
"unplugin-vue-components": "0.25.2",
"vite": "4.5.0",
"vite-plugin-progress": "^0.0.7",
"vite-plugin-progress": "0.0.7",
"vite-plugin-svg-icons": "2.0.1",
"vite-plugin-vue-devtools": "1.0.0-rc.5",
"vue-tsc": "1.8.19"
Expand Down
2 changes: 1 addition & 1 deletion packages/color-palette/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sa/color-palette",
"version": "2.0.0",
"version": "1.0.0",
"exports": {
".": "./src/index.ts"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sa/docs",
"version": "2.0.0",
"version": "1.0.0",
"scripts": {
"dev": "vitepress dev",
"build": "vitepress build",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-config-sa",
"version": "2.0.0",
"version": "1.0.0",
"description": "SoybeanAdmin's eslint config resets",
"exports": {
".": "./index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/hooks/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sa/hooks",
"version": "2.0.0",
"version": "1.0.0",
"exports": {
".": "./src/index.ts"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/materials/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sa/materials",
"version": "2.0.0",
"version": "1.0.0",
"exports": {
".": "./src/index.ts"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/request/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sa/request",
"version": "2.0.0",
"version": "1.0.0",
"exports": {
".": "./src/index.ts"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/scripts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sa/scripts",
"version": "2.0.0",
"version": "1.0.0",
"exports": {
".": "./src/index.ts"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/uno-preset/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sa/uno-preset",
"version": "2.0.0",
"version": "1.0.0",
"exports": {
".": "./src/index.ts"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sa/utils",
"version": "2.0.0",
"version": "1.0.0",
"exports": {
".": "./src/index.ts"
},
Expand Down
8 changes: 3 additions & 5 deletions src/layouts/modules/global-header/components/switch-lang.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script setup lang="ts">
import { ref } from 'vue';
import type { MenuInfo } from 'ant-design-vue/es/menu/src/interface';
import { setLocale } from '@/locales';
import { localStg } from '@/utils/storage';
Expand All @@ -26,8 +25,7 @@ const options: LocaleOption[] = [
}
];
function handleSelect(e: MenuInfo) {
const key = e.key as App.I18n.LangType;
function handleSelect(key: App.I18n.LangType) {
locale.value = key;
setLocale(key);
localStg.set('lang', key);
Expand All @@ -42,8 +40,8 @@ function handleSelect(e: MenuInfo) {
</div>
</AButton>
<template #overlay>
<AMenu :selected-keys="[locale]" @click="handleSelect">
<AMenuItem v-for="option in options" :key="option.key">
<AMenu :selected-keys="[locale]">
<AMenuItem v-for="option in options" :key="option.key" @click="handleSelect(option.key)">
{{ option.label }}
</AMenuItem>
</AMenu>
Expand Down

0 comments on commit 970352c

Please sign in to comment.