Skip to content

feat: adapt fba backend menu #8

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

Merged
merged 1 commit into from
Apr 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# FastAPI Best Architecture UI

Front-end Implementation of
the [FastAPI Best Architecture](https://github.com/fastapi-practices/fastapi_best_architecture)
Front-end Implementation of the [FastAPI Best Architecture](https://github.com/fastapi-practices/fastapi_best_architecture)

## Run

Expand Down Expand Up @@ -30,10 +29,8 @@ pnpm build

## Sponsor us

If this program has helped you, you can sponsor us with some coffee
beans: [:coffee: Sponsor :coffee:](https://wu-clan.github.io/sponsor/)
If this program has helped you, you can sponsor us with some coffee beans: [:coffee: Sponsor :coffee:](https://wu-clan.github.io/sponsor/)

## License

This project is licensed under the terms of
the [MIT](https://github.com/fastapi-practices/fba_ui/blob/master/LICENSE) license
This project is licensed under the terms of the [MIT](https://github.com/fastapi-practices/fba_ui/blob/master/LICENSE) license
7 changes: 0 additions & 7 deletions apps/web-antd/src/api/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,3 @@ export async function logoutApi() {
withCredentials: true,
});
}

/**
* 获取用户权限码
*/
export async function getAccessCodesApi() {
return requestClient.get<string[]>('/auth/codes');
}
2 changes: 1 addition & 1 deletion apps/web-antd/src/api/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ import { requestClient } from '#/api/request';
* 获取用户所有菜单
*/
export async function getAllMenusApi() {
return requestClient.get<RouteRecordStringComponent[]>('/menu/all');
return requestClient.get<RouteRecordStringComponent[]>('/api/v1/sys/menus');
}
4 changes: 1 addition & 3 deletions apps/web-antd/src/api/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,8 @@ function createRequestClient(baseURL: string, options?: RequestClientOptions) {
// 通用的错误处理,如果没有进入上面的错误处理逻辑,就会进入这里
client.addResponseInterceptor(
errorMessageResponseInterceptor((msg: string, error) => {
// 这里可以根据业务进行定制,你可以拿到 error 内的信息进行定制化处理,根据不同的 code 做不同的提示,而不是直接使用 message.error 提示 msg
// 当前mock接口返回的错误字段是 error 或者 message
const responseData = error?.response?.data ?? {};
const errorMessage = responseData?.error ?? responseData?.message ?? '';
const errorMessage = responseData?.msg ?? '';
// 如果没有错误信息,则会根据状态码进行提示
message.error(errorMessage || msg);
}),
Expand Down
4 changes: 2 additions & 2 deletions apps/web-antd/src/api/user.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { UserInfo } from '@vben/types';
import type { MyUserInfo } from '#/types';

import { requestClient } from '#/api/request';

/**
* 获取用户信息
*/
export async function getUserInfoApi() {
return requestClient.get<UserInfo>('/api/v1/sys/users/me');
return requestClient.get<MyUserInfo>('/api/v1/sys/users/me');
}
12 changes: 0 additions & 12 deletions apps/web-antd/src/locales/langs/en-US/demos.json

This file was deleted.

17 changes: 17 additions & 0 deletions apps/web-antd/src/locales/langs/en-US/page.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,22 @@
"analytics": "Analytics",
"title": "Dashboard",
"workspace": "Workspace"
},
"menu": {
"admin": "System Admin",
"automation": "System Auto",
"codeGenerator": "Code Generator",
"log": "System Log",
"login": "Login Log",
"monitor": "System Monitor",
"opera": "Opera Log",
"redis": "Redis",
"server": "Server",
"sysApi": "System API",
"sysDataRule": "System Data Rule",
"sysDept": "System Dept",
"sysMenu": "System User",
"sysRole": "System Role",
"sysUser": "System User"
}
}
12 changes: 0 additions & 12 deletions apps/web-antd/src/locales/langs/zh-CN/demos.json

This file was deleted.

17 changes: 17 additions & 0 deletions apps/web-antd/src/locales/langs/zh-CN/page.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,22 @@
"analytics": "分析页",
"title": "概览",
"workspace": "工作台"
},
"menu": {
"admin": "系统管理",
"automation": "系统自动化",
"codeGenerator": "代码生成",
"log": "系统日志",
"login": "登录日志",
"monitor": "系统监控",
"opera": "操作日志",
"redis": "Redis",
"server": "服务器",
"sysApi": "系统 API",
"sysDataRule": "系统数据规则",
"sysDept": "系统部门",
"sysMenu": "系统菜单",
"sysRole": "系统角色",
"sysUser": "系统角色"
}
}
114 changes: 114 additions & 0 deletions apps/web-antd/src/preferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,120 @@ import { defineOverridesPreferences } from '@vben/preferences';
export const overridesPreferences = defineOverridesPreferences({
// overrides
app: {
accessMode: 'backend',
authPageLayout: 'panel-right',
checkUpdatesInterval: 1,
colorGrayMode: false,
colorWeakMode: false,
compact: false,
contentCompact: 'wide',
defaultAvatar:
'https://unpkg.com/@vbenjs/static-source@0.1.7/source/avatar-v1.webp',
dynamicTitle: true,
enableCheckUpdates: true,
enablePreferences: true,
enableRefreshToken: false,
isMobile: false,
layout: 'sidebar-nav',
locale: 'zh-CN',
loginExpiredMode: 'page',
name: import.meta.env.VITE_APP_TITLE,
preferencesButtonPosition: 'auto',
watermark: false,
},
breadcrumb: {
enable: true,
hideOnlyOne: false,
showHome: false,
showIcon: true,
styleType: 'normal',
},
copyright: {
companyName: 'FastAPI Practices',
companySiteLink: 'https://github.com/fastapi-practices',
date: '2025',
enable: true,
icp: '',
icpLink: '',
settingShow: true,
},
footer: {
enable: true,
fixed: true,
},
header: {
enable: true,
hidden: false,
menuAlign: 'start',
mode: 'fixed',
},
logo: {
enable: true,
source: 'https://wu-clan.github.io/picx-images-hosting/logo/fba.png',
},
navigation: {
accordion: true,
split: true,
styleType: 'rounded',
},
shortcutKeys: {
enable: true,
globalLockScreen: true,
globalLogout: true,
globalPreferences: true,
globalSearch: true,
},
sidebar: {
autoActivateChild: false,
collapsed: false,
collapsedButton: true,
collapsedShowTitle: false,
enable: true,
expandOnHover: true,
extraCollapse: false,
fixedButton: true,
hidden: false,
width: 224,
},
tabbar: {
draggable: true,
enable: true,
height: 38,
keepAlive: true,
maxCount: 0,
middleClickToClose: false,
persist: true,
showIcon: true,
showMaximize: true,
showMore: true,
styleType: 'chrome',
wheelable: true,
},
theme: {
builtinType: 'default',
colorDestructive: 'hsl(348 100% 61%)',
colorPrimary: 'hsl(212 100% 45%)',
colorSuccess: 'hsl(144 57% 58%)',
colorWarning: 'hsl(42 84% 61%)',
mode: 'auto',
radius: '0.5',
semiDarkHeader: false,
semiDarkSidebar: false,
},
transition: {
enable: true,
loading: true,
name: 'fade-slide',
progress: true,
},
widget: {
fullscreen: true,
globalSearch: true,
languageToggle: true,
lockScreen: true,
notification: true,
refresh: true,
sidebarToggle: true,
themeToggle: true,
},
});
67 changes: 67 additions & 0 deletions apps/web-antd/src/router/routes/modules/admin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import type { RouteRecordRaw } from 'vue-router';

import { $t } from '#/locales';

const routes: RouteRecordRaw[] = [
{
name: 'admin',
path: '/admin',
meta: {
title: $t('page.menu.admin'),
icon: 'icon-settings',
order: 1,
},
children: [
{
name: 'SysDept',
path: 'sys-dept',
component: () => import('#/views/admin/dept/index.vue'),
meta: {
title: $t('page.menu.sysDept'),
},
},
{
name: 'SysUser',
path: 'sys-user',
component: () => import('#/views/admin/user/index.vue'),
meta: {
title: $t('page.menu.sysUser'),
},
},
{
name: 'SysRole',
path: 'sys-role',
component: () => import('#/views/admin/role/index.vue'),
meta: {
title: $t('page.menu.sysRole'),
},
},
{
name: 'SysMenu',
path: 'sys-menu',
component: () => import('#/views/admin/menu/index.vue'),
meta: {
title: $t('page.menu.sysMenu'),
},
},
{
name: 'SysApi',
path: 'sys-api',
component: () => import('#/views/admin/api/index.vue'),
meta: {
title: $t('page.menu.sysApi'),
},
},
{
name: 'SysDataRule',
path: 'sys-data-rule',
component: () => import('#/views/admin/data-rule/index.vue'),
meta: {
title: $t('page.menu.sysDataRule'),
},
},
],
},
];

export default routes;
27 changes: 27 additions & 0 deletions apps/web-antd/src/router/routes/modules/automation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import type { RouteRecordRaw } from 'vue-router';

import { $t } from '#/locales';

const routes: RouteRecordRaw[] = [
{
name: 'automation',
path: '/automation',
meta: {
title: $t('page.menu.automation'),
icon: 'icon-code-square',
order: 2,
},
children: [
{
name: 'CodeGenerator',
path: 'code-generator',
component: () => import('#/views/automation/code-generator/index.vue'),
meta: {
title: $t('page.menu.codeGenerator'),
},
},
],
},
];

export default routes;
4 changes: 2 additions & 2 deletions apps/web-antd/src/router/routes/modules/dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import { $t } from '#/locales';

const routes: RouteRecordRaw[] = [
{
name: 'dashboard',
path: '/dashboard',
meta: {
icon: 'lucide:layout-dashboard',
order: -1,
title: $t('page.dashboard.title'),
},
name: 'Dashboard',
path: '/dashboard',
children: [
{
name: 'Analytics',
Expand Down
28 changes: 0 additions & 28 deletions apps/web-antd/src/router/routes/modules/demos.ts

This file was deleted.

Loading