Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: tiny-pro vue enhancement #224

Merged
merged 71 commits into from
Nov 13, 2024
Merged
Changes from 1 commit
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
1e062fe
feat: 支持 NestJS 后端
Muyu-art Jul 9, 2024
0ea755a
feat: 新增获取所有用户,修复deleteAt失效问题 (#143)
Muyu-art Jul 11, 2024
f870c0b
feat: 添加ITreeNode字段/新增role接口/新增getUser分页 (#144)
Muyu-art Jul 20, 2024
0c7afef
fix: 前后端登录功能修复 & 联调 (#146)
Muyu-art Jul 25, 2024
5e39596
feat: 新增用户管理模块-查看所有用户&分页&删除 (#148)
Muyu-art Aug 1, 2024
fc37bf8
feat: 新增权限管理模块 (#149)
Muyu-art Aug 2, 2024
8f3bf0e
feat: 新增角色管理模块&菜单管理模块 (#151)
Muyu-art Aug 6, 2024
2429e9b
WIP feat: 新增动态添加路由&多级菜单 (#152)
Muyu-art Aug 8, 2024
1d44071
feat: 新增页签模式&地图错误修复&404问题修复 (#153)
Muyu-art Aug 9, 2024
6e3ec5a
feat: 支持在初始化项目时选择vite/webpack/rspack/farm等构建工具 (#154)
Muyu-art Aug 10, 2024
41d1add
feat: 新增rspack构建工具 (#156)
Muyu-art Aug 11, 2024
7120121
feat: vue2 初始化 (#155)
Muyu-art Aug 11, 2024
64e20d6
fix: vue2新增permission模块&修复登录登出功能&修复路由 (#157)
Muyu-art Aug 12, 2024
c2c7b53
fix: rspack/webpack/vite菜单修复 (#158)
Muyu-art Aug 12, 2024
8668302
feat: 新增按钮级权限 (#159)
Muyu-art Aug 12, 2024
9a50279
fix: cli选择构建工具修复 (#160)
Muyu-art Aug 13, 2024
32e6ddc
feat: vue2新增菜单管理模块 (#161)
Muyu-art Aug 13, 2024
426ec6e
feat: vue2新增角色管理模块&menu/permission部分问题修复 (#162)
Muyu-art Aug 13, 2024
2ab613d
feat: vue2新增user管理模块 (#163)
Muyu-art Aug 14, 2024
6e5a649
fix: vue3问题修复&优化 (#164)
Muyu-art Aug 15, 2024
7a53a42
fix: 修复i18n失效问题&菜单高亮问题&部分弹窗提示国际化 (#165)
Muyu-art Aug 16, 2024
14a3034
fix: vue3部分问题优化 (#166)
Muyu-art Aug 16, 2024
f9b5da6
WIP feat: vue2新增动态路由&多级菜单&页签模式&按钮级权限 (#167)
Muyu-art Aug 18, 2024
7427ff3
fix: vue3问题修复 (#168)
Muyu-art Aug 19, 2024
7781cfe
feat: vue3新增菜单demo页&添加未存在菜单默认加载demo页 (#169)
Muyu-art Aug 19, 2024
da79036
feat: cli多打包 (#170)
Muyu-art Aug 20, 2024
bcdc535
feat: vue2多打包vite/rspack/webpack (#171)
Muyu-art Aug 21, 2024
32d2843
fix: vue2角色模块优化 (#172)
Muyu-art Aug 21, 2024
8656a39
fix: vue3角色模块优化 (#173)
Muyu-art Aug 21, 2024
e9ca6c0
fix: vue2修复404与白屏 (#174)
Muyu-art Aug 21, 2024
01f0ce4
fix: vue2页签Tabs重构 (#175)
Muyu-art Aug 21, 2024
a92d7fe
feat: vue2新增三级菜单 (#176)
Muyu-art Aug 21, 2024
54d0756
fix: 用户模块修改用户和添加用户优化为弹窗 (#177)
Muyu-art Aug 21, 2024
aa7defd
fix: vue2用户模块修改和添加弹窗优化 (#178)
Muyu-art Aug 21, 2024
f3774f4
fix: vue页签Tabs优化 (#179)
Muyu-art Aug 22, 2024
6e280c7
feat: nest后端新增国际化 (#180)
Muyu-art Aug 22, 2024
9c612fe
fix: menu优化-将用户、菜单、权限、角色管理合并入系统管理下 (#181)
Muyu-art Aug 22, 2024
b33fbab
feat: tiny-pro新增国际化服务 (#182)
Muyu-art Aug 23, 2024
2b42032
fix: vue2/3修复rspack跳转问题 (#183)
Muyu-art Aug 23, 2024
bb3d702
fix: tiny-pro部分问题解决及优化 (#184)
Muyu-art Aug 25, 2024
a5ea55c
fix: vue修复mock/dashboard样式/下拉选择超长问题/菜单管理虚拟滚动 (#185)
Muyu-art Aug 25, 2024
5b76864
fix: tiny-pro部分问题修复 (#186)
Muyu-art Aug 26, 2024
33494d1
fix: vue死锁问题修复 (#187)
Muyu-art Aug 27, 2024
3c17a42
fix: tiny-pro部分问题修复 (#188)
Muyu-art Aug 28, 2024
afb72f9
fix: tiny-pro部分问题修复 (#189)
Muyu-art Aug 29, 2024
75d953a
fix: tiny-pro部分问题优化 (#190)
Muyu-art Aug 30, 2024
7393b32
fix: vue2菜单/用户管理模块重构 & tiny-pro部分问题修复 (#191)
Muyu-art Sep 1, 2024
5471127
fix: vue菜单模块删除menuType并允许parentId为null (#192)
Muyu-art Sep 1, 2024
970dcb5
fix: vue2/3菜单模块部分问题修改 (#193)
Muyu-art Sep 1, 2024
b670439
fix: vue2角色模块绑定菜单和tabs (#194)
Muyu-art Sep 2, 2024
ab6b340
fix: vue修改默认主题&添加角色修改data.permission (#195)
Muyu-art Sep 2, 2024
2238134
fix: vue修复menu管理删除menu时tabs未更新问题 (#196)
Muyu-art Sep 2, 2024
223584f
fix: vue&nest优化国际化服务i18n&高度统一 (#197)
Muyu-art Sep 3, 2024
752e32c
fix: tiny-pro部分问题优化 (#198)
Muyu-art Sep 3, 2024
8b1e86d
feat: vue新增路由过渡动画 (#199)
Muyu-art Sep 4, 2024
dccbcb3
feat: user过滤 & 合同页面异常捕获 (#200)
Muyu-art Sep 4, 2024
34077c0
fix: vue&nest角色模块分页&筛选优化 (#201)
Muyu-art Sep 5, 2024
2e89f5b
fix: vue&nest权限模块优化分页&过滤 (#202)
Muyu-art Sep 5, 2024
5aaa518
fix: vue&nest国际化模块优化分页和过滤 (#203)
Muyu-art Sep 5, 2024
207757d
fix: tiny-pro下线cli的vue2选择 (#204)
Muyu-art Sep 6, 2024
348ddf0
feat: nest补充docker和开发文档&vue新增开发文档 (#205)
Muyu-art Sep 7, 2024
ffb753b
fix: tiny-cli部分问题优化 (#206)
Muyu-art Sep 8, 2024
f1b9473
fix: vue表单校验优化 (#207)
Muyu-art Sep 9, 2024
6418e2e
fix: cli删除console (#208)
Muyu-art Sep 10, 2024
6a5ab11
fix: tiny-cli部分问题修改&优化 (#209)
Muyu-art Sep 14, 2024
0c04612
fix: cli忽略lock文件 (#210)
Muyu-art Sep 17, 2024
cd634db
fix: cli补充redis (#211)
Muyu-art Sep 18, 2024
a9a9cf4
fix: vue表单按钮宽度修复 (#212)
Muyu-art Sep 19, 2024
9713d73
fix: cli初始化如果不配置后端则不显示redis配置 (#213)
Muyu-art Sep 19, 2024
ae95a33
fix: cli不配置mysql数据库配置项留空 (#214)
Muyu-art Sep 20, 2024
0363c2c
fix: 新增贡献者和维护者文档 (#215)
Muyu-art Oct 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: vue2修复404与白屏 (#174)
* fix: vue2修复404与白屏

* fix: 检视意见修改
Muyu-art authored Aug 21, 2024
commit e9ca6c0f324f0df7bc7e6ea450ac0227ef405e02
10 changes: 10 additions & 0 deletions packages/toolkits/pro/template/tinyvue2/src/api/user.ts
Original file line number Diff line number Diff line change
@@ -38,6 +38,16 @@ export interface UserData {
filterType?: [];
}

export type Role = {
id: number;
name: string;
permission: {
name: string;
desc: string;
id: number;
}[];
};

export function login(data: LoginData) {
return axios.post<LoginRes>('/api/auth/login', data);
}
2 changes: 2 additions & 0 deletions packages/toolkits/pro/template/tinyvue2/src/main.ts
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@ import chinaMap from './assets/chaina.json';
import { registerMap } from 'echarts';
import Breadcrumb from '@/components/breadcrumb/index.vue';
import * as icons from '@opentiny/vue-icon';
import VueRouter from 'vue-router';

// 全局注册所有图标组件
Object.keys(icons).forEach((key) => {
@@ -22,6 +23,7 @@ Object.keys(icons).forEach((key) => {
registerMap('china', chinaMap as any);

Vue.use(PiniaVuePlugin);
Vue.use(VueRouter);
Vue.component('Breadcrumb', Breadcrumb);
Vue.use(directive);

Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { setupMenuGuard } from './menu';
import { setupTabsGuard } from './tabs';
// import setupInfoGuard from './info';
import setupInfoGuard from './info';
import setupPermissionGuard from './permission';

function setupPageGuard(router: any) {
setupPermissionGuard(router);
// setupInfoGuard(router);
setupInfoGuard(router);
setupMenuGuard(router);
setupTabsGuard(router);
}
30 changes: 30 additions & 0 deletions packages/toolkits/pro/template/tinyvue2/src/router/guard/info.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { getUserInfo, type Role } from '@/api/user';
import { useUserStore } from '@/stores';
import { setToken } from '@/utils/auth';

export default function setupInfoGuard(router) {
router.beforeEach(async (to, from, next) => {
if (to.name === 'login' || to.name === 'notFound') {
next();
return;
}
const userStore = useUserStore();
const { data } = (await getUserInfo()) ?? { data: null };
if (!data) {
next({
name: 'login',
query: {
redirect: to.name,
...to.query,
},
});
setToken('');
return;
}
userStore.setInfo(data);
userStore.rolePermission = (data.role as unknown as Role[])
.flatMap((role) => role.permission)
.map((permission) => permission.name);
next();
});
}
11 changes: 9 additions & 2 deletions packages/toolkits/pro/template/tinyvue2/src/router/guard/menu.ts
Original file line number Diff line number Diff line change
@@ -61,9 +61,16 @@ export const toRoutes = (menus: ITreeNodeData[]) => {
};

export const setupMenuGuard = (router: any) => {
let depth = 100;
let has404 = false;
router.beforeEach(async (to, from, next) => {
await nextTick();
if (to.name === 'notFound') {
next();
return;
}
if ((depth -= 1) <= 0) {
return;
}
has404 = router
.getRoutes()
.some((route: RouteRecord) => route.name === 'notFound');
@@ -77,7 +84,7 @@ export const setupMenuGuard = (router: any) => {
const menuStore = useMenuStore();
if (menuStore.menuList.length) {
if (!to.matched.length) {
next({ name: 'login', replace: true });
next({ name: 'notFound', replace: true });
return;
}
next();
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import { getUserInfo } from '@/api/user';
import { useUserStore } from '@/stores';
import { clearToken, isLogin } from '@/utils/auth';
import { nextTick } from 'vue';
import { isLogin } from '@/utils/auth';

export default function setupPermissionGuard(router: any) {
router.beforeEach(async (to, from, next) => {
router.beforeEach((to, from, next) => {
if (!isLogin()) {
if (to.name === 'login') {
if (to.name === 'login' || to.name === 'notFound') {
next();
return;
}
@@ -15,22 +12,9 @@ export default function setupPermissionGuard(router: any) {
query: {
redirect: to.name,
...to.query,
} as any,
},
});
} else {
await nextTick();
const userStore = useUserStore();
if (!userStore.email) {
clearToken();
next({
name: 'login',
query: {
redirect: to.name,
...to.query,
} as any,
});
return;
}
next();
}
});
3 changes: 0 additions & 3 deletions packages/toolkits/pro/template/tinyvue2/src/router/index.ts
Original file line number Diff line number Diff line change
@@ -7,9 +7,6 @@ import appRoutes from './routes';
import { getToken } from '@/utils/auth';
import createRouteGuard from '@/router/guard';
import { notFound } from './not-found';

Vue.use(VueRouter);

const router = new VueRouter({
mode: 'history',
routes: [
5 changes: 5 additions & 0 deletions packages/toolkits/pro/template/tinyvue2/src/stores/user.ts
Original file line number Diff line number Diff line change
@@ -89,6 +89,11 @@ export const useUserStore = defineStore('user', {
this.$reset();
},

async fetchInfo() {
const { data } = await getUserInfo();
this.setInfo(data);
},

// Login
async login(loginForm: LoginData) {
try {
Original file line number Diff line number Diff line change
@@ -138,7 +138,29 @@ function handleSubmit() {
const route = router
.getRoutes()
.filter((route) => route.name === redirectTo)[0];
router.replace({ path: route.path });
if (!route) {
const firstRoute = router.getRoutes().filter((route) => {
return (
route.path !== '' &&
!route.path.includes('login') &&
!route.path.includes('preview') &&
!route.path.includes('404') &&
route.path !== '/vue-pro'
);
})[0];
if (firstRoute) {
router.replace({ path: firstRoute.path });
return;
}
Notify({
type: 'error',
title: t('login.route.error'),
position: 'top-right',
duration: 2000,
});
} else {
router.replace({ path: route.path });
}
} catch (err) {
Notify({
type: 'error',
Original file line number Diff line number Diff line change
@@ -46,4 +46,6 @@ export default {
'login.tip.mail': "User name: admin{'@'}example.com; password: admin",
'login.tip.right': 'Enter the correct user name and password',
'login.main.text': 'TinyPro Mid-Back-End Front-End Solution',
'login.route.error':
'Uncapted routing exception, please contact the website administrator',
};
Original file line number Diff line number Diff line change
@@ -40,7 +40,8 @@ export default {
'login.banner.subSlogan3': '实现灵活的区块式开发',
'login.icon.language': '语言',
'login.tip.info': '用户名:admin,密码 admin',
'login.tip.mail': "用户名:[email protected],密码 admin",
'login.tip.mail': '用户名:[email protected],密码 admin',
'login.tip.right': '请输入正确的用户名密码',
'login.main.text': 'TinyPro 中后台前端解决方案',
'login.route.error': '路由出现错误, 请联系管理员',
};