Skip to content

Commit c501322

Browse files
committed
chore: improve env
1 parent 59c06b0 commit c501322

22 files changed

+170
-100
lines changed

.env

+36-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,38 @@
1-
VITE_APP_TITLE = Vexip Admin
1+
# The base path of application.
2+
BASE_PATH = /
23

3-
VITE_BASE_LANGUAGE = zh-CN
4+
# Should drop `console.log` and `debugger` when building.
5+
DROP_CONSOLE = false
46

5-
VITE_SUPPORT_DARK_MODE = true
7+
# The title of application.
8+
PUBLIC_APP_TITLE = Vexip Admin
9+
10+
# Specify the base language of application.
11+
PUBLIC_BASE_LANGUAGE = zh-CN
12+
13+
# Whether to support dark mode.
14+
PUBLIC_SUPPORT_DARK_MODE = true
15+
16+
# Whether to use mock data.
17+
PUBLIC_USE_MOCK = false
18+
19+
# The api server address.
20+
PUBLIC_API_SERVER = /
21+
22+
# The base path of api server.
23+
PUBLIC_API_BASE_PATH = /api
24+
25+
# The resource server address.
26+
PUBLIC_RESOURCE_SERVER = /
27+
28+
# The base path of resource server.
29+
PUBLIC_RESOURCE_BASE_PATH = /resource
30+
31+
# Specify oauth log in address if needed.
32+
PUBLIC_OAUTH_LOGIN_URL =
33+
34+
# Whether to use settings drawer.
35+
PUBLIC_USE_SETTINGS_DRAWER = true
36+
37+
# Whether to use nav tab.
38+
PUBLIC_USE_NAV_TAB = true

.env.development

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
VITE_USE_MOCK = true
1+
PUBLIC_USE_MOCK = true
22

3-
VITE_BASE_PATH = /
3+
PUBLIC_BASE_SERVER = http://127.0.0.1
44

5-
VITE_DROP_CONSOLE = false
6-
7-
VITE_BASE_SERVER = http://127.0.0.1
8-
9-
VITE_RESOURCE_SERVER = http://127.0.0.1
5+
PUBLIC_RESOURCE_SERVER = http://127.0.0.1

.env.production

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
VITE_USE_MOCK = true
1+
PUBLIC_USE_MOCK = true
22

3-
VITE_BASE_PATH = /
4-
5-
VITE_DROP_CONSOLE = true
3+
PUBLIC_DROP_CONSOLE = true

.eslintrc.cjs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
module.exports = {
1+
const { defineConfig } = require('eslint-define-config');
2+
3+
module.exports = defineConfig({
24
extends: ['@vexip-ui/eslint-config'],
35
root: true
4-
}
6+
})

package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"precommit": "lint-staged -c ./.husky/.lintstagedrc -q --allow-empty",
1717
"prepare": "is-ci || husky install",
1818
"prettier": "prettier --write \"**/*.{js,cjs,mjs,ts,json,css,scss,vue,html,md}\"",
19-
"preview": "vite preview"
19+
"preview": "vite preview",
20+
"schema2ts": "json2ts -i src/config/schema/app-settings.schema.json -o types/schema.d.ts --style.singleQuote --no-style.semi"
2021
},
2122
"dependencies": {
2223
"@vexip-ui/hooks": "^2.7.0",
@@ -55,10 +56,12 @@
5556
"@vue/runtime-core": "^3.5.13",
5657
"dotenv": "^16.4.7",
5758
"eslint": "^8.57.0",
59+
"eslint-define-config": "^2.1.0",
5860
"fast-glob": "^3.3.3",
5961
"fs-extra": "^11.2.0",
6062
"husky": "^9.1.7",
6163
"is-ci": "^4.1.0",
64+
"json-schema-to-typescript": "^15.0.4",
6265
"kolorist": "^1.8.0",
6366
"lint-staged": "^15.3.0",
6467
"minimist": "^1.2.8",

pnpm-lock.yaml

+43-16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/global-config.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
window.GLOBAL_CONFIG = {
2-
serverUrls: {
3-
base: '/api',
4-
resource: '/resource'
5-
}
6-
}
1+
/**
2+
* @type {import('../types/global').GlobalConfig}
3+
*/
4+
window.GLOBAL_CONFIG = {}

src/app.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { isClient } from '@vexip-ui/utils'
44
const route = useRoute()
55
const { locale, t } = useI18n()
66
7-
const baseTitle = import.meta.env.VITE_APP_TITLE || ''
7+
const baseTitle = import.meta.env.PUBLIC_APP_TITLE || ''
88
99
watch([() => route.fullPath, () => locale.value], () => {
1010
if (!isClient) return

src/layouts/view/view-layout.vue

+10-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import RightMessage from './header-right/right-message.vue'
88
import RightSearch from './header-right/right-search.vue'
99
import ThemeSwitch from './header-right/theme-switch.vue'
1010
11-
import type { LayoutHeaderAction } from 'vexip-ui'
11+
import type { LayoutExposed, LayoutHeaderAction } from 'vexip-ui'
1212
1313
const { t } = useI18n()
1414
@@ -19,6 +19,8 @@ const accessStore = useAccessStore()
1919
const userStore = useUserStore()
2020
const navTabStore = useNavTabStore()
2121
22+
const layoutRef = useTemplateRef<LayoutExposed>('layout')
23+
2224
const activeTab = ref('')
2325
const activeMenu = ref('')
2426
@@ -69,6 +71,9 @@ watch(
6971
},
7072
{ immediate: true }
7173
)
74+
watch(activeMenu, value => {
75+
layoutRef.value?.expandMenuByLabel(value)
76+
})
7277
7378
function handleMenuSelect(label: string) {
7479
router.push(label)
@@ -178,6 +183,7 @@ async function handleSignOut() {
178183

179184
<template>
180185
<VLayout
186+
ref="layout"
181187
class="vp-layout"
182188
logo="https://www.vexipui.com/vexip-ui.svg"
183189
sign-name="Vexip Admin"
@@ -343,7 +349,9 @@ async function handleSignOut() {
343349
.fade-move {
344350
&-leave-active,
345351
&-enter-active {
346-
transition: opacity 250ms, transform 250ms;
352+
transition:
353+
opacity 250ms,
354+
transform 250ms;
347355
}
348356
349357
&-enter-from {

src/locale/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type { LocaleOptions } from 'vexip-ui'
66
import type { LanguageConfig } from './types'
77
import type { LanguageType } from './helper'
88

9-
const baseLanguage = import.meta.env.VITE_BASE_LANGUAGE
9+
const baseLanguage = import.meta.env.PUBLIC_BASE_LANGUAGE
1010
const localLanguage = typeof navigator !== 'undefined' ? navigator.language : undefined
1111

1212
export const defaultLanguage = localLanguage

0 commit comments

Comments
 (0)