This commit is contained in:
AN
2025-06-18 23:09:07 +08:00
9 changed files with 72 additions and 32 deletions

View File

@ -240,6 +240,12 @@ const local: App.I18n.Schema = {
'workflow_process-instance': 'Process Instance',
workflow_leave: 'Leave Apply'
},
menu: {
system_tenant: 'Tenant Management',
system_log: 'Log Management',
'monitor_snail-job': 'Job Management',
monitor_admin: 'Admin Monitor'
},
dict: {
sys_user_sex: {
male: 'Male',

View File

@ -221,7 +221,7 @@ const local: App.I18n.Schema = {
system_notice: '通知公告',
'social-callback': '单点登录回调',
system_oss: '文件管理',
'system_oss-config': 'OSS配置',
'system_oss-config': 'OSS 配置',
monitor_cache: '缓存监控',
monitor_online: '在线用户',
'user-center': '个人中心',
@ -240,6 +240,12 @@ const local: App.I18n.Schema = {
'workflow_process-instance': '流程实例',
workflow_leave: '请假申请'
},
menu: {
system_tenant: '租户管理',
system_log: '日志管理',
'monitor_snail-job': '任务调度中心',
monitor_admin: 'Admin 监控'
},
dict: {
sys_user_sex: {
male: '男',

View File

@ -1,3 +1,4 @@
import { useRoute } from 'vue-router';
import type { AxiosResponse, InternalAxiosRequestConfig } from 'axios';
import { BACKEND_ERROR_CODE, REQUEST_CANCELED_CODE, createFlatRequest } from '@sa/axios';
import { useAuthStore } from '@/store/modules/auth';
@ -51,6 +52,7 @@ export const request = createFlatRequest<App.Service.Response, RequestInstanceSt
return String(response.data.code) === import.meta.env.VITE_SERVICE_SUCCESS_CODE;
},
async onBackendFail(response, instance) {
const route = useRoute();
const authStore = useAuthStore();
const responseCode = String(response.data.code);
@ -66,6 +68,10 @@ export const request = createFlatRequest<App.Service.Response, RequestInstanceSt
}
// when the backend response code is in `logoutCodes`, it means the user will be logged out and redirected to login page
if (route.name === 'login') {
handleLogout();
return null;
}
// const logoutCodes = import.meta.env.VITE_SERVICE_LOGOUT_CODES?.split(',') || [];
// if (logoutCodes.includes(responseCode)) {
// handleLogout();

View File

@ -94,7 +94,7 @@ export const useRouteStore = defineStore(SetupStoreId.Route, () => {
// eslint-disable-next-line complexity
function parseRouter(route: ElegantConstRoute, parent?: ElegantConstRoute) {
route.meta = route.meta ? route.meta : { title: route.name };
if (route.meta.title.startsWith('route.')) {
if (route.meta.title.startsWith('route.') || route.meta.title.startsWith('menu.')) {
route.meta.i18nKey = route.meta.title as App.I18n.I18nKey;
}
const isLayout = route.component === 'Layout';

View File

@ -467,6 +467,7 @@ declare namespace App {
};
};
route: Record<I18nRouteKey, string>;
menu: Record<string, string>;
dict: Record<string, Record<string, string>>;
page: {
common: {

View File

@ -61,6 +61,7 @@ const callbackByCode = async (data: Api.Auth.SocialLoginForm) => {
const loginByCode = async (data: Api.Auth.SocialLoginForm) => {
try {
await authStore.logout();
await authStore.login(data);
await processResponse();
} catch {

View File

@ -108,6 +108,14 @@ async function handleDeleteMenu(id?: CommonType.IdType) {
getMeunTree();
}
function renderLabel({ option }: { option: TreeOption }) {
let label = String(option.menuName);
if (label?.startsWith('route.') || label?.startsWith('menu.')) {
label = $t(label as App.I18n.I18nKey);
}
return <div>{label}</div>;
}
function renderPrefix({ option }: { option: TreeOption }) {
const renderLocalIcon = String(option.icon).startsWith('local-icon-');
const icon = renderLocalIcon ? undefined : String(option.icon);
@ -347,6 +355,7 @@ const btnColumns: DataTableColumns<Api.System.Menu> = [
label-field="menuName"
virtual-scroll
checkable
:render-label="renderLabel"
:render-prefix="renderPrefix"
:render-suffix="renderSuffix"
@update:selected-keys="(_: Array<string & number>, option: Array<TreeOption | null>) => handleClickTree(option)"
@ -420,7 +429,11 @@ const btnColumns: DataTableColumns<Api.System.Menu> = [
<DictTag size="small" :value="currentMenu.status" dict-code="sys_normal_disable" />
</NDescriptionsItem>
<NDescriptionsItem :label="$t('page.system.menu.menuName')">
{{ currentMenu.menuName }}
{{
currentMenu.menuName?.startsWith('route.') || currentMenu.menuName?.startsWith('menu.')
? $t(currentMenu.menuName)
: currentMenu.menuName
}}
</NDescriptionsItem>
<NDescriptionsItem v-if="isMenu" :label="$t('page.system.menu.component')">
{{ currentMenu.component }}