Skip to content

Commit 6e9e9e8

Browse files
committed
Merge branch 'master' of https://gitee.com/yudaocode/yudao-ui-admin-vue3 into dev
2 parents bb6d6da + 8d532df commit 6e9e9e8

File tree

8 files changed

+53
-8
lines changed

8 files changed

+53
-8
lines changed

.env

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,8 @@ VITE_APP_TENANT_ENABLE=true
1313
# 验证码的开关
1414
VITE_APP_CAPTCHA_ENABLE=true
1515

16+
# 文档地址的开关
17+
VITE_APP_DOCALERT_ENABLE=true
18+
1619
# 百度统计
1720
VITE_APP_BAIDU_CODE = a1ff8825baa73c3a78eb96aa40325abc

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "yudao-ui-admin-vue3",
3-
"version": "1.8.3-snapshot",
3+
"version": "2.0.0-snapshot",
44
"description": "基于vue3、vite4、element-plus、typesScript",
55
"author": "xingyu",
66
"private": false,

src/components/Descriptions/src/Descriptions.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,11 @@ const toggleClick = () => {
129129
<slot v-else-if="item.dictType">
130130
<DictTag :type="item.dictType" :value="data[item.field] + ''" />
131131
</slot>
132-
<slot v-else :name="item.field" :row="data">{{ data[item.field] }}</slot>
132+
<slot v-else :name="item.field" :row="data">
133+
{{
134+
item.mappedField ? data[item.mappedField] : data[item.field]
135+
}}
136+
</slot>
133137
</template>
134138
</ElDescriptionsItem>
135139
</ElDescriptions>

src/components/DocAlert/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const goToUrl = () => {
2222
2323
/** 是否开启 */
2424
const getEnable = () => {
25-
return import.meta.env.VITE_APP_TENANT_ENABLE === 'true'
25+
return import.meta.env.VITE_APP_DOCALERT_ENABLE !== 'false'
2626
}
2727
</script>
2828
<style scoped>

src/permission.ts

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,40 @@ import { usePermissionStoreWithOut } from '@/store/modules/permission'
1212
const { start, done } = useNProgress()
1313

1414
const { loadStart, loadDone } = usePageLoading()
15+
16+
const parseURL = (
17+
url: string | null | undefined
18+
): { basePath: string; paramsObject: { [key: string]: string } } => {
19+
// 如果输入为 null 或 undefined,返回空字符串和空对象
20+
if (url == null) {
21+
return { basePath: '', paramsObject: {} }
22+
}
23+
24+
// 找到问号 (?) 的位置,它之前是基础路径,之后是查询参数
25+
const questionMarkIndex = url.indexOf('?')
26+
let basePath = url
27+
const paramsObject: { [key: string]: string } = {}
28+
29+
// 如果找到了问号,说明有查询参数
30+
if (questionMarkIndex !== -1) {
31+
// 获取 basePath
32+
basePath = url.substring(0, questionMarkIndex)
33+
34+
// 从 URL 中获取查询字符串部分
35+
const queryString = url.substring(questionMarkIndex + 1)
36+
37+
// 使用 URLSearchParams 遍历参数
38+
const searchParams = new URLSearchParams(queryString)
39+
searchParams.forEach((value, key) => {
40+
// 封装进 paramsObject 对象
41+
paramsObject[key] = value
42+
})
43+
}
44+
45+
// 返回 basePath 和 paramsObject
46+
return { basePath, paramsObject }
47+
}
48+
1549
// 路由不重定向白名单
1650
const whiteList = [
1751
'/login',
@@ -47,8 +81,10 @@ router.beforeEach(async (to, from, next) => {
4781
router.addRoute(route as unknown as RouteRecordRaw) // 动态添加可访问路由表
4882
})
4983
const redirectPath = from.query.redirect || to.path
84+
// 修复跳转时不带参数的问题
5085
const redirect = decodeURIComponent(redirectPath as string)
51-
const nextData = to.path === redirect ? { ...to, replace: true } : { path: redirect }
86+
const { basePath, paramsObject: query } = parseURL(redirect)
87+
const nextData = to.path === redirect ? { ...to, replace: true } : { path: redirect, query }
5288
next(nextData)
5389
} else {
5490
next()

src/types/descriptions.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ export interface DescriptionsSchema {
22
span?: number // 占多少分
33
field: string // 字段名
44
label?: string // label名
5+
mappedField?: string // 字段映射
56
width?: string | number
67
minWidth?: string | number
78
align?: 'left' | 'center' | 'right'

src/views/Login/SocialLogin.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,8 @@ const LoginRules = {
193193
}
194194
const loginData = reactive({
195195
isShowPassword: false,
196-
captchaEnable: import.meta.env.VITE_APP_CAPTCHA_ENABLE,
197-
tenantEnable: import.meta.env.VITE_APP_TENANT_ENABLE,
196+
captchaEnable: import.meta.env.VITE_APP_CAPTCHA_ENABLE !== 'false',
197+
tenantEnable: import.meta.env.VITE_APP_TENANT_ENABLE !== 'false',
198198
loginForm: {
199199
tenantName: '芋道源码',
200200
username: 'admin',
@@ -207,7 +207,7 @@ const loginData = reactive({
207207
// 获取验证码
208208
const getCode = async () => {
209209
// 情况一,未开启:则直接登录
210-
if (loginData.captchaEnable === 'false') {
210+
if (loginData.captchaEnable) {
211211
await handleLogin({})
212212
} else {
213213
// 情况二,已开启:则展示验证码;只有完成验证码的情况,才进行登录
@@ -217,7 +217,7 @@ const getCode = async () => {
217217
}
218218
//获取租户ID
219219
const getTenantId = async () => {
220-
if (loginData.tenantEnable === 'true') {
220+
if (loginData.tenantEnable) {
221221
const res = await LoginApi.getTenantIdByName(loginData.loginForm.tenantName)
222222
authUtil.setTenantId(res)
223223
}

types/env.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ interface ImportMetaEnv {
1414
readonly VITE_DEV: string
1515
readonly VITE_APP_CAPTCHA_ENABLE: string
1616
readonly VITE_APP_TENANT_ENABLE: string
17+
readonly VITE_APP_DOCALERT_ENABLE: string
1718
readonly VITE_BASE_URL: string
1819
readonly VITE_UPLOAD_URL: string
1920
readonly VITE_API_BASEPATH: string

0 commit comments

Comments
 (0)