Skip to content

Commit bdfb823

Browse files
committed
fix: The system default roles are not internationalized
1 parent 304b5f5 commit bdfb823

File tree

6 files changed

+181
-136
lines changed

6 files changed

+181
-136
lines changed

ui/src/components/tag-group/index.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<div class="tag-group" v-if="props.tags.length">
33
<el-tag :size="props.size" class="default-tag tag-ellipsis" :title="props.tags[0]">
4-
{{ props.tags[0] }}
4+
{{ i18n_name(props.tags[0]) }}
55
</el-tag>
66
<el-tooltip effect="light" :disabled="tooltipDisabled">
77
<el-tag :size="props.size" class="info-tag ml-4 cursor" v-if="props.tags?.length > 1">
@@ -21,6 +21,8 @@
2121
</div>
2222
</template>
2323
<script setup lang="ts">
24+
import { i18n_name } from '@/utils/common'
25+
2426
const props = defineProps<{
2527
tags: string[]
2628
size?: 'large' | 'default' | 'small'

ui/src/layout/layout-header/avatar/index.vue

Lines changed: 36 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<el-dropdown trigger="click" type="primary">
33
<div class="flex-center cursor">
44
<el-avatar :size="30">
5-
<img src="@/assets/user-icon.svg" style="width: 54%" alt=""/>
5+
<img src="@/assets/user-icon.svg" style="width: 54%" alt="" />
66
</el-avatar>
77
<!-- <span class="ml-8 color-text-primary ellipsis"
88
:title="user.userInfo?.nick_name">{{ user.userInfo?.nick_name }}</span>
@@ -16,12 +16,14 @@
1616
<div class="userInfo flex align-center">
1717
<div class="mr-12 flex align-center">
1818
<el-avatar :size="30">
19-
<img src="@/assets/user-icon.svg" style="width: 54%" alt=""/>
19+
<img src="@/assets/user-icon.svg" style="width: 54%" alt="" />
2020
</el-avatar>
2121
</div>
2222
<div style="width: 90%">
23-
<p class="bold mb-4" style="font-size: 14px">{{ user.userInfo?.nick_name }} <span
24-
class="color-secondary lighter">({{ user.userInfo?.username }})</span></p>
23+
<p class="bold mb-4" style="font-size: 14px">
24+
{{ i18n_name(user.userInfo?.nick_name as string) }}
25+
<span class="color-secondary lighter">({{ user.userInfo?.username }})</span>
26+
</p>
2527
<template v-if="user.userInfo?.role_name && user.userInfo.role_name.length > 0">
2628
<TagGroup
2729
size="small"
@@ -73,7 +75,7 @@
7375
v-if="
7476
hasPermission(
7577
new ComplexPermission(
76-
[RoleConst.ADMIN,RoleConst.ADMIN, RoleConst.WORKSPACE_MANAGE, RoleConst.USER],
78+
[RoleConst.ADMIN, RoleConst.ADMIN, RoleConst.WORKSPACE_MANAGE, RoleConst.USER],
7779
[PermissionConst.SYSTEM_API_KEY_EDIT],
7880
[EditionConst.IS_EE, EditionConst.IS_PE],
7981
'OR',
@@ -104,7 +106,7 @@
104106
<div class="flex-between w-full" style="line-height: 22px; padding: 12px 11px">
105107
<span> {{ $t('layout.language') }}</span>
106108
<el-icon>
107-
<ArrowRight/>
109+
<ArrowRight />
108110
</el-icon>
109111
</div>
110112

@@ -118,14 +120,14 @@
118120
class="flex-between"
119121
>
120122
<span :class="lang.value === user.userInfo?.language ? 'primary' : ''">{{
121-
lang.label
122-
}}</span>
123+
lang.label
124+
}}</span>
123125

124126
<el-icon
125127
:class="lang.value === user.userInfo?.language ? 'primary' : ''"
126128
v-if="lang.value === user.userInfo?.language"
127129
>
128-
<Check/>
130+
<Check />
129131
</el-icon>
130132
</el-dropdown-item>
131133
</el-dropdown-menu>
@@ -135,16 +137,16 @@
135137
<el-dropdown-item
136138
@click="openAbout"
137139
v-if="
138-
hasPermission(
139-
new ComplexPermission(
140-
[RoleConst.ADMIN, RoleConst.USER, RoleConst.WORKSPACE_MANAGE],
141-
[PermissionConst.ABOUT_READ],
142-
[],
143-
'OR',
144-
),
140+
hasPermission(
141+
new ComplexPermission(
142+
[RoleConst.ADMIN, RoleConst.USER, RoleConst.WORKSPACE_MANAGE],
143+
[PermissionConst.ABOUT_READ],
144+
[],
145145
'OR',
146-
)
147-
"
146+
),
147+
'OR',
148+
)
149+
"
148150
>
149151
{{ $t('layout.about.title') }}
150152
</el-dropdown-item>
@@ -155,27 +157,28 @@
155157
</el-dropdown-menu>
156158
</template>
157159
</el-dropdown>
158-
<APIKeyDialog :user-id="user.userInfo?.id" ref="APIKeyDialogRef"/>
160+
<APIKeyDialog :user-id="user.userInfo?.id" ref="APIKeyDialogRef" />
159161
<ResetPassword ref="resetPasswordRef"></ResetPassword>
160162
<AboutDialog ref="AboutDialogRef"></AboutDialog>
161163

162164
<!-- <UserPwdDialog ref="UserPwdDialogRef" /> -->
163165
</template>
164166
<script setup lang="ts">
165-
import {ref, onMounted, computed} from 'vue'
167+
import { ref, onMounted, computed } from 'vue'
166168
import useStore from '@/stores'
167-
import {useRouter} from 'vue-router'
168-
import {t} from "@/locales"
169+
import { useRouter } from 'vue-router'
170+
import { t } from '@/locales'
169171
import ResetPassword from './ResetPassword.vue'
170172
import AboutDialog from './AboutDialog.vue'
171173
// import UserPwdDialog from '@/views/user-manage/component/UserPwdDialog.vue'
172174
import APIKeyDialog from './APIKeyDialog.vue'
173-
import {ComplexPermission} from '@/utils/permission/type'
174-
import {langList} from '@/locales/index'
175-
import {hasPermission} from '@/utils/permission'
176-
import {PermissionConst, RoleConst, EditionConst} from '@/utils/permission/data'
175+
import { ComplexPermission } from '@/utils/permission/type'
176+
import { langList } from '@/locales/index'
177+
import { hasPermission } from '@/utils/permission'
178+
import { PermissionConst, RoleConst, EditionConst } from '@/utils/permission/data'
179+
import { i18n_name } from '@/utils/common'
177180
178-
const {user, login} = useStore()
181+
const { user, login } = useStore()
179182
const router = useRouter()
180183
181184
const AboutDialogRef = ref()
@@ -199,15 +202,15 @@ const openResetPassword = () => {
199202
resetPasswordRef.value?.open()
200203
}
201204
const m: any = {
202-
"系统管理员": 'layout.about.inner_admin',
203-
"工作空间管理员": 'layout.about.inner_wsm',
204-
"普通用户": 'layout.about.inner_user'
205+
系统管理员: 'layout.about.inner_admin',
206+
工作空间管理员: 'layout.about.inner_wsm',
207+
普通用户: 'layout.about.inner_user',
205208
}
206209
const role_list = computed(() => {
207210
if (!user.userInfo) {
208211
return []
209212
}
210-
return user.userInfo?.role_name?.map(name => {
213+
return user.userInfo?.role_name?.map((name) => {
211214
const inner = m[name]
212215
if (inner) {
213216
return t(inner)
@@ -218,9 +221,9 @@ const role_list = computed(() => {
218221
const logout = () => {
219222
login.logout().then(() => {
220223
if (user?.userInfo?.source && ['CAS', 'OIDC', 'OAuth2'].includes(user.userInfo.source)) {
221-
router.push({name: 'login', query: {login_mode: 'manual'}})
224+
router.push({ name: 'login', query: { login_mode: 'manual' } })
222225
} else {
223-
router.push({name: 'login'})
226+
router.push({ name: 'login' })
224227
}
225228
})
226229
}

ui/src/views/system/resource-authorization/index.vue

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,15 @@
4646
<div class="flex-between">
4747
<div class="flex">
4848
<span class="mr-8 ellipsis-1" :title="row.nick_name">{{
49-
row.nick_name
49+
i18n_name(row.nick_name)
5050
}}</span>
5151
<el-text
5252
class="color-input-placeholder ellipsis-1"
5353
:title="row.roles.join(',')"
5454
v-if="hasPermission([EditionConst.IS_EE, EditionConst.IS_PE], 'OR')"
55-
>({{ row.roles?.join(',') }})</el-text
55+
>({{
56+
row.roles.map((item: any) => i18n_name(item))?.join(',')
57+
}})</el-text
5658
>
5759
</div>
5860
</div>
@@ -88,6 +90,7 @@ import type { WorkspaceItem } from '@/api/type/workspace'
8890
import { loadPermissionApi } from '@/utils/dynamics-api/permission-api.ts'
8991
9092
import useStore from '@/stores'
93+
import { i18n_name } from '@/utils/common'
9194
9295
const route = useRoute()
9396
const { user } = useStore()
@@ -168,11 +171,13 @@ const getPermissionList = () => {
168171
if (resourceType === 'MODEL') {
169172
permissionData.value = res.data || []
170173
} else {
171-
permissionData.value = res.data.map((item: any) => {
172-
if (!item.folder_id && item.permission === 'NOT_AUTH') {
173-
return {...item, permission: 'VIEW'}
174-
}
175-
return item}) || []
174+
permissionData.value =
175+
res.data.map((item: any) => {
176+
if (!item.folder_id && item.permission === 'NOT_AUTH') {
177+
return { ...item, permission: 'VIEW' }
178+
}
179+
return item
180+
}) || []
176181
}
177182
})
178183
}
@@ -188,15 +193,15 @@ const toTree = (nodeList: any, pField: any) => {
188193
const nodeMap = Object.fromEntries(list.map((item: any) => [item.id, item]))
189194
190195
for (let index = 0; index < nodeList.length; index++) {
191-
const element = list[index];
196+
const element = list[index]
192197
if (!element.children) {
193198
element.children = []
194199
}
195200
if (element[pField]) {
196201
const pNode = nodeMap[element[pField]]
197202
if (pNode) {
198203
if (!pNode.children) {
199-
pNode.children = []
204+
pNode.children = []
200205
}
201206
pNode.children.push(element)
202207
}

ui/src/views/system/user-manage/index.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ import { t } from '@/locales'
292292
import useStore from '@/stores'
293293
import { PermissionConst, RoleConst } from '@/utils/permission/data'
294294
import { hasPermission } from '@/utils/permission/index'
295+
import { i18n_name } from '@/utils/common'
295296
296297
const { user, common } = useStore()
297298
const search_type = ref('username')
@@ -338,10 +339,13 @@ function getList() {
338339
return userManageApi.getUserManage(paginationConfig, params, loading).then((res) => {
339340
userTableData.value = res.data.records.map((item: any) => ({
340341
...item,
342+
nick_name: i18n_name(item.nick_name),
341343
role_workspace: Object.entries(item.role_workspace ?? {}).map(([role, workspaces]) => ({
342-
role,
344+
role: i18n_name(role),
343345
workspace:
344-
(workspaces as string[])?.[0] === 'None' ? '-' : (workspaces as string[])?.join(', '),
346+
(workspaces as string[])?.[0] === 'None'
347+
? '-'
348+
: (workspaces as string[])?.map((ws) => i18n_name(ws)).join(', '),
345349
})),
346350
}))
347351
paginationConfig.total = res.data.total

0 commit comments

Comments
 (0)