This commit is contained in:
YunaiV 2024-02-17 16:44:59 +08:00
commit 6e9e9e88a8
8 changed files with 53 additions and 8 deletions

3
.env
View File

@ -13,5 +13,8 @@ VITE_APP_TENANT_ENABLE=true
# 验证码的开关 # 验证码的开关
VITE_APP_CAPTCHA_ENABLE=true VITE_APP_CAPTCHA_ENABLE=true
# 文档地址的开关
VITE_APP_DOCALERT_ENABLE=true
# 百度统计 # 百度统计
VITE_APP_BAIDU_CODE = a1ff8825baa73c3a78eb96aa40325abc VITE_APP_BAIDU_CODE = a1ff8825baa73c3a78eb96aa40325abc

View File

@ -1,6 +1,6 @@
{ {
"name": "yudao-ui-admin-vue3", "name": "yudao-ui-admin-vue3",
"version": "1.8.3-snapshot", "version": "2.0.0-snapshot",
"description": "基于vue3、vite4、element-plus、typesScript", "description": "基于vue3、vite4、element-plus、typesScript",
"author": "xingyu", "author": "xingyu",
"private": false, "private": false,

View File

@ -129,7 +129,11 @@ const toggleClick = () => {
<slot v-else-if="item.dictType"> <slot v-else-if="item.dictType">
<DictTag :type="item.dictType" :value="data[item.field] + ''" /> <DictTag :type="item.dictType" :value="data[item.field] + ''" />
</slot> </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> </template>
</ElDescriptionsItem> </ElDescriptionsItem>
</ElDescriptions> </ElDescriptions>

View File

@ -22,7 +22,7 @@ const goToUrl = () => {
/** 是否开启 */ /** 是否开启 */
const getEnable = () => { const getEnable = () => {
return import.meta.env.VITE_APP_TENANT_ENABLE === 'true' return import.meta.env.VITE_APP_DOCALERT_ENABLE !== 'false'
} }
</script> </script>
<style scoped> <style scoped>

View File

@ -12,6 +12,40 @@ import { usePermissionStoreWithOut } from '@/store/modules/permission'
const { start, done } = useNProgress() const { start, done } = useNProgress()
const { loadStart, loadDone } = usePageLoading() 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 = [ const whiteList = [
'/login', '/login',
@ -47,8 +81,10 @@ router.beforeEach(async (to, from, next) => {
router.addRoute(route as unknown as RouteRecordRaw) // 动态添加可访问路由表 router.addRoute(route as unknown as RouteRecordRaw) // 动态添加可访问路由表
}) })
const redirectPath = from.query.redirect || to.path const redirectPath = from.query.redirect || to.path
// 修复跳转时不带参数的问题
const redirect = decodeURIComponent(redirectPath as string) 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) next(nextData)
} else { } else {
next() next()

View File

@ -2,6 +2,7 @@ export interface DescriptionsSchema {
span?: number // 占多少分 span?: number // 占多少分
field: string // 字段名 field: string // 字段名
label?: string // label名 label?: string // label名
mappedField?: string // 字段映射
width?: string | number width?: string | number
minWidth?: string | number minWidth?: string | number
align?: 'left' | 'center' | 'right' align?: 'left' | 'center' | 'right'

View File

@ -193,8 +193,8 @@ const LoginRules = {
} }
const loginData = reactive({ const loginData = reactive({
isShowPassword: false, isShowPassword: false,
captchaEnable: import.meta.env.VITE_APP_CAPTCHA_ENABLE, captchaEnable: import.meta.env.VITE_APP_CAPTCHA_ENABLE !== 'false',
tenantEnable: import.meta.env.VITE_APP_TENANT_ENABLE, tenantEnable: import.meta.env.VITE_APP_TENANT_ENABLE !== 'false',
loginForm: { loginForm: {
tenantName: '芋道源码', tenantName: '芋道源码',
username: 'admin', username: 'admin',
@ -207,7 +207,7 @@ const loginData = reactive({
// //
const getCode = async () => { const getCode = async () => {
// //
if (loginData.captchaEnable === 'false') { if (loginData.captchaEnable) {
await handleLogin({}) await handleLogin({})
} else { } else {
// //
@ -217,7 +217,7 @@ const getCode = async () => {
} }
//ID //ID
const getTenantId = async () => { const getTenantId = async () => {
if (loginData.tenantEnable === 'true') { if (loginData.tenantEnable) {
const res = await LoginApi.getTenantIdByName(loginData.loginForm.tenantName) const res = await LoginApi.getTenantIdByName(loginData.loginForm.tenantName)
authUtil.setTenantId(res) authUtil.setTenantId(res)
} }

1
types/env.d.ts vendored
View File

@ -14,6 +14,7 @@ interface ImportMetaEnv {
readonly VITE_DEV: string readonly VITE_DEV: string
readonly VITE_APP_CAPTCHA_ENABLE: string readonly VITE_APP_CAPTCHA_ENABLE: string
readonly VITE_APP_TENANT_ENABLE: string readonly VITE_APP_TENANT_ENABLE: string
readonly VITE_APP_DOCALERT_ENABLE: string
readonly VITE_BASE_URL: string readonly VITE_BASE_URL: string
readonly VITE_UPLOAD_URL: string readonly VITE_UPLOAD_URL: string
readonly VITE_API_BASEPATH: string readonly VITE_API_BASEPATH: string