Merge branch 'master' of https://gitee.com/yudaocode/yudao-ui-admin-vue3 into dev
This commit is contained in:
commit
6e9e9e88a8
3
.env
3
.env
@ -13,5 +13,8 @@ VITE_APP_TENANT_ENABLE=true
|
||||
# 验证码的开关
|
||||
VITE_APP_CAPTCHA_ENABLE=true
|
||||
|
||||
# 文档地址的开关
|
||||
VITE_APP_DOCALERT_ENABLE=true
|
||||
|
||||
# 百度统计
|
||||
VITE_APP_BAIDU_CODE = a1ff8825baa73c3a78eb96aa40325abc
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "yudao-ui-admin-vue3",
|
||||
"version": "1.8.3-snapshot",
|
||||
"version": "2.0.0-snapshot",
|
||||
"description": "基于vue3、vite4、element-plus、typesScript",
|
||||
"author": "xingyu",
|
||||
"private": false,
|
||||
|
@ -129,7 +129,11 @@ const toggleClick = () => {
|
||||
<slot v-else-if="item.dictType">
|
||||
<DictTag :type="item.dictType" :value="data[item.field] + ''" />
|
||||
</slot>
|
||||
<slot v-else :name="item.field" :row="data">{{ data[item.field] }}</slot>
|
||||
<slot v-else :name="item.field" :row="data">
|
||||
{{
|
||||
item.mappedField ? data[item.mappedField] : data[item.field]
|
||||
}}
|
||||
</slot>
|
||||
</template>
|
||||
</ElDescriptionsItem>
|
||||
</ElDescriptions>
|
||||
|
@ -22,7 +22,7 @@ const goToUrl = () => {
|
||||
|
||||
/** 是否开启 */
|
||||
const getEnable = () => {
|
||||
return import.meta.env.VITE_APP_TENANT_ENABLE === 'true'
|
||||
return import.meta.env.VITE_APP_DOCALERT_ENABLE !== 'false'
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
|
@ -12,6 +12,40 @@ import { usePermissionStoreWithOut } from '@/store/modules/permission'
|
||||
const { start, done } = useNProgress()
|
||||
|
||||
const { loadStart, loadDone } = usePageLoading()
|
||||
|
||||
const parseURL = (
|
||||
url: string | null | undefined
|
||||
): { basePath: string; paramsObject: { [key: string]: string } } => {
|
||||
// 如果输入为 null 或 undefined,返回空字符串和空对象
|
||||
if (url == null) {
|
||||
return { basePath: '', paramsObject: {} }
|
||||
}
|
||||
|
||||
// 找到问号 (?) 的位置,它之前是基础路径,之后是查询参数
|
||||
const questionMarkIndex = url.indexOf('?')
|
||||
let basePath = url
|
||||
const paramsObject: { [key: string]: string } = {}
|
||||
|
||||
// 如果找到了问号,说明有查询参数
|
||||
if (questionMarkIndex !== -1) {
|
||||
// 获取 basePath
|
||||
basePath = url.substring(0, questionMarkIndex)
|
||||
|
||||
// 从 URL 中获取查询字符串部分
|
||||
const queryString = url.substring(questionMarkIndex + 1)
|
||||
|
||||
// 使用 URLSearchParams 遍历参数
|
||||
const searchParams = new URLSearchParams(queryString)
|
||||
searchParams.forEach((value, key) => {
|
||||
// 封装进 paramsObject 对象
|
||||
paramsObject[key] = value
|
||||
})
|
||||
}
|
||||
|
||||
// 返回 basePath 和 paramsObject
|
||||
return { basePath, paramsObject }
|
||||
}
|
||||
|
||||
// 路由不重定向白名单
|
||||
const whiteList = [
|
||||
'/login',
|
||||
@ -47,8 +81,10 @@ router.beforeEach(async (to, from, next) => {
|
||||
router.addRoute(route as unknown as RouteRecordRaw) // 动态添加可访问路由表
|
||||
})
|
||||
const redirectPath = from.query.redirect || to.path
|
||||
// 修复跳转时不带参数的问题
|
||||
const redirect = decodeURIComponent(redirectPath as string)
|
||||
const nextData = to.path === redirect ? { ...to, replace: true } : { path: redirect }
|
||||
const { basePath, paramsObject: query } = parseURL(redirect)
|
||||
const nextData = to.path === redirect ? { ...to, replace: true } : { path: redirect, query }
|
||||
next(nextData)
|
||||
} else {
|
||||
next()
|
||||
|
1
src/types/descriptions.d.ts
vendored
1
src/types/descriptions.d.ts
vendored
@ -2,6 +2,7 @@ export interface DescriptionsSchema {
|
||||
span?: number // 占多少分
|
||||
field: string // 字段名
|
||||
label?: string // label名
|
||||
mappedField?: string // 字段映射
|
||||
width?: string | number
|
||||
minWidth?: string | number
|
||||
align?: 'left' | 'center' | 'right'
|
||||
|
@ -193,8 +193,8 @@ const LoginRules = {
|
||||
}
|
||||
const loginData = reactive({
|
||||
isShowPassword: false,
|
||||
captchaEnable: import.meta.env.VITE_APP_CAPTCHA_ENABLE,
|
||||
tenantEnable: import.meta.env.VITE_APP_TENANT_ENABLE,
|
||||
captchaEnable: import.meta.env.VITE_APP_CAPTCHA_ENABLE !== 'false',
|
||||
tenantEnable: import.meta.env.VITE_APP_TENANT_ENABLE !== 'false',
|
||||
loginForm: {
|
||||
tenantName: '芋道源码',
|
||||
username: 'admin',
|
||||
@ -207,7 +207,7 @@ const loginData = reactive({
|
||||
// 获取验证码
|
||||
const getCode = async () => {
|
||||
// 情况一,未开启:则直接登录
|
||||
if (loginData.captchaEnable === 'false') {
|
||||
if (loginData.captchaEnable) {
|
||||
await handleLogin({})
|
||||
} else {
|
||||
// 情况二,已开启:则展示验证码;只有完成验证码的情况,才进行登录
|
||||
@ -217,7 +217,7 @@ const getCode = async () => {
|
||||
}
|
||||
//获取租户ID
|
||||
const getTenantId = async () => {
|
||||
if (loginData.tenantEnable === 'true') {
|
||||
if (loginData.tenantEnable) {
|
||||
const res = await LoginApi.getTenantIdByName(loginData.loginForm.tenantName)
|
||||
authUtil.setTenantId(res)
|
||||
}
|
||||
|
1
types/env.d.ts
vendored
1
types/env.d.ts
vendored
@ -14,6 +14,7 @@ interface ImportMetaEnv {
|
||||
readonly VITE_DEV: string
|
||||
readonly VITE_APP_CAPTCHA_ENABLE: string
|
||||
readonly VITE_APP_TENANT_ENABLE: string
|
||||
readonly VITE_APP_DOCALERT_ENABLE: string
|
||||
readonly VITE_BASE_URL: string
|
||||
readonly VITE_UPLOAD_URL: string
|
||||
readonly VITE_API_BASEPATH: string
|
||||
|
Loading…
Reference in New Issue
Block a user