Skip to content

Commit

Permalink
feat(projects): add function page: hide-child,super-page,toggle-auth
Browse files Browse the repository at this point in the history
  • Loading branch information
honghuangdc committed Apr 13, 2024
1 parent dd6fce3 commit 886ea57
Show file tree
Hide file tree
Showing 21 changed files with 674 additions and 78 deletions.
3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@ VITE_SERVICE_MODAL_LOGOUT_CODES=7777,7778

# token expired codes of backend service, when the code is received, it will refresh the token and resend the request
VITE_SERVICE_EXPIRED_TOKEN_CODES=9999,9998

# when the route mode is static, the defined super role
VITE_STATIC_SUPER_ROLE=R_SUPER
7 changes: 4 additions & 3 deletions src/components/common/exception-base.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script lang="ts" setup>
import { computed } from 'vue';
import { $t } from '@/locales';
import { useRouterPush } from '@/hooks/common/router';
defineOptions({ name: 'ExceptionBase' });
Expand All @@ -19,6 +20,8 @@ interface Props {
const props = defineProps<Props>();
const { routerPushByKey } = useRouterPush();
const iconMap: Record<ExceptionType, string> = {
'403': 'no-permission',
'404': 'not-found',
Expand All @@ -33,9 +36,7 @@ const icon = computed(() => iconMap[props.type]);
<div class="flex text-400px text-primary">
<SvgIcon :local-icon="icon" />
</div>
<RouterLink to="/">
<AButton type="primary">{{ $t('common.backToHome') }}</AButton>
</RouterLink>
<AButton type="primary" @clikc="routerPushByKey('root')">{{ $t('common.backToHome') }}</AButton>
</div>
</template>

Expand Down
21 changes: 21 additions & 0 deletions src/hooks/business/auth.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { useAuthStore } from '@/store/modules/auth';

export function useAuth() {
const authStore = useAuthStore();

function hasAuth(codes: string | string[]) {
if (!authStore.isLogin) {
return false;
}

if (typeof codes === 'string') {
return authStore.userInfo.buttons.includes(codes);
}

return codes.some(code => authStore.userInfo.buttons.includes(code));
}

return {
hasAuth
};
}
176 changes: 159 additions & 17 deletions src/locales/langs/en-us.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,44 @@ const local: App.I18n.Schema = {
title: 'SoybeanAdmin'
},
common: {
tip: 'Tip',
action: 'Action',
add: 'Add',
addSuccess: 'Add Success',
edit: 'Edit',
editSuccess: 'Edit Success',
delete: 'Delete',
deleteSuccess: 'Delete Success',
backToHome: 'Back to home',
batchDelete: 'Batch Delete',
confirm: 'Confirm',
cancel: 'Cancel',
pleaseCheckValue: 'Please check whether the value is valid',
action: 'Action',
backToHome: 'Back to home',
lookForward: 'Coming soon',
userCenter: 'User Center',
close: 'Close',
check: 'Check',
columnSetting: 'Column Setting',
config: 'Config',
confirm: 'Confirm',
delete: 'Delete',
deleteSuccess: 'Delete Success',
confirmDelete: 'Are you sure you want to delete?',
edit: 'Edit',
index: 'Index',
keywordSearch: 'Please enter keyword',
logout: 'Logout',
logoutConfirm: 'Are you sure you want to log out?',
trigger: 'Trigger'
lookForward: 'Coming soon',
modify: 'Modify',
modifySuccess: 'Modify Success',
noData: 'No Data',
operate: 'Operate',
pleaseCheckValue: 'Please check whether the value is valid',
refresh: 'Refresh',
reset: 'Reset',
search: 'Search',
switch: 'Switch',
tip: 'Tip',
trigger: 'Trigger',
update: 'Update',
updateSuccess: 'Update Success',
userCenter: 'User Center',
yesOrNo: {
yes: 'Yes',
no: 'No'
}
},
request: {
logout: 'Logout user after request failed',
Expand Down Expand Up @@ -128,11 +148,13 @@ const local: App.I18n.Schema = {
'function_hide-child_two': 'Two',
'function_hide-child_three': 'Three',
function_request: 'Request',
'function_toggle-auth': 'Toggle Auth',
'function_super-page': 'Super Admin Visible',
manage: 'System Manage',
manage_user: 'User Manage',
'manage_user-detail': 'User Detail',
manage_role: 'Role Manage',
manage_route: 'Route Manage',
manage_menu: 'Menu Manage',
'multi-menu': 'Multi Menu',
'multi-menu_first': 'Menu One',
'multi-menu_first_child': 'Menu One Child',
Expand Down Expand Up @@ -167,9 +189,9 @@ const local: App.I18n.Schema = {
register: 'Register',
otherAccountLogin: 'Other Account Login',
otherLoginMode: 'Other Login Mode',
superAdmin: 'Super Administrator',
admin: 'Administrator',
user: 'Ordinary User'
superAdmin: 'Super Admin',
admin: 'Admin',
user: 'User'
},
codeLogin: {
title: 'Verification Code Login',
Expand Down Expand Up @@ -255,6 +277,126 @@ const local: App.I18n.Schema = {
multiTab: {
routeParam: 'Route Param',
backTab: 'Back function_tab'
},
toggleAuth: {
toggleAccount: 'Toggle Account',
authHook: 'Auth Hook Function `hasAuth`',
superAdminVisible: 'Super Admin Visible',
adminVisible: 'Admin Visible',
adminOrUserVisible: 'Admin and User Visible'
}
},
manage: {
common: {
status: {
enable: 'Enable',
disable: 'Disable'
}
},
role: {
title: 'Role List',
roleName: 'Role Name',
roleCode: 'Role Code',
roleStatus: 'Role Status',
roleDesc: 'Role Description',
menuAuth: 'Menu Auth',
buttonAuth: 'Button Auth',
form: {
roleName: 'Please enter role name',
roleCode: 'Please enter role code',
roleStatus: 'Please select role status',
roleDesc: 'Please enter role description'
},
addRole: 'Add Role',
editRole: 'Edit Role'
},
user: {
title: 'User List',
userName: 'User Name',
userGender: 'Gender',
nickName: 'Nick Name',
userPhone: 'Phone Number',
userEmail: 'Email',
userStatus: 'User Status',
userRole: 'User Role',
form: {
userName: 'Please enter user name',
userGender: 'Please select gender',
nickName: 'Please enter nick name',
userPhone: 'Please enter phone number',
userEmail: 'Please enter email',
userStatus: 'Please select user status',
userRole: 'Please select user role'
},
addUser: 'Add User',
editUser: 'Edit User',
gender: {
male: 'Male',
female: 'Female'
}
},
menu: {
home: 'Home',
title: 'Menu List',
id: 'ID',
parentId: 'Parent ID',
menuType: 'Menu Type',
menuName: 'Menu Name',
routeName: 'Route Name',
routePath: 'Route Path',
routeParams: 'Route Params',
layout: 'Layout Component',
page: 'Page Component',
i18nKey: 'I18n Key',
icon: 'Icon',
localIcon: 'Local Icon',
iconTypeTitle: 'Icon Type',
order: 'Order',
keepAlive: 'Keep Alive',
href: 'Href',
hideInMenu: 'Hide In Menu',
activeMenu: 'Active Menu',
multiTab: 'Multi Tab',
fixedIndexInTab: 'Fixed Index In Tab',
button: 'Button',
buttonCode: 'Button Code',
buttonDesc: 'Button Desc',
menuStatus: 'Menu Status',
form: {
home: 'Please select home',
menuType: 'Please select menu type',
menuName: 'Please enter menu name',
routeName: 'Please enter route name',
routePath: 'Please enter route path',
page: 'Please select page component',
layout: 'Please select layout component',
i18nKey: 'Please enter i18n key',
icon: 'Please enter iconify name',
localIcon: 'Please enter local icon name',
order: 'Please enter order',
keepAlive: 'Please select whether to cache route',
href: 'Please enter href',
hideInMenu: 'Please select whether to hide menu',
activeMenu: 'Please enter the route name of the highlighted menu',
multiTab: 'Please select whether to support multiple tabs',
fixedInTab: 'Please select whether to fix in the tab',
fixedIndexInTab: 'Please enter the index fixed in the tab',
button: 'Please select whether it is a button',
buttonCode: 'Please enter button code',
buttonDesc: 'Please enter button description',
menuStatus: 'Please select menu status'
},
addMenu: 'Add Menu',
editMenu: 'Edit Menu',
addChildMenu: 'Add Child Menu',
type: {
directory: 'Directory',
menu: 'Menu'
},
iconType: {
iconify: 'Iconify Icon',
local: 'Local Icon'
}
}
}
},
Expand All @@ -270,7 +412,7 @@ const local: App.I18n.Schema = {
},
pwd: {
required: 'Please enter password',
invalid: 'Password format is incorrect'
invalid: '6-18 characters, including letters, numbers, and underscores'
},
confirmPwd: {
required: 'Please enter password again',
Expand Down
Loading

0 comments on commit 886ea57

Please sign in to comment.