Skip to content

Commit 89dbb8c

Browse files
committed
perf: 优化.env配置
1 parent 4f2f4f7 commit 89dbb8c

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
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=false
18+
1619
# 百度统计
1720
VITE_APP_BAIDU_CODE = a1ff8825baa73c3a78eb96aa40325abc

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/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)