Commit 66fd0527 by vince

fix: fix known issues. fixed #59,fixed #61, fixed #67, fixed #68 [deploy]

1 parent b98f9f9b
...@@ -8,7 +8,7 @@ on: ...@@ -8,7 +8,7 @@ on:
jobs: jobs:
deploy-push-ftp: deploy-push-ftp:
name: Deploy Push Ftp name: Deploy Push Ftp
if: github.actor != 'dependabot[bot]' && !contains(github.event.head_commit.message, '[skip ci]') if: github.actor != 'dependabot[bot]' && !contains(github.event.head_commit.message, '[skip ci]') && contains(github.event.head_commit.message, '[deploy]')
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
......
# 应用标题 # 应用标题
VITE_GLOB_APP_TITLE=Vben Admin VITE_APP_TITLE=Vben Admin
# 应用命名空间,用于缓存、store等功能的前缀,确保隔离 # 应用命名空间,用于缓存、store等功能的前缀,确保隔离
VITE_APP_NAMESPACE=vben-web-antd VITE_APP_NAMESPACE=vben-web-antd
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
name="viewport" name="viewport"
content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=0" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=0"
/> />
<!-- 由 vite 注入 VITE_GLOB_APP_TITLE 变量,在 .env 文件内配置 --> <!-- 由 vite 注入 VITE_APP_TITLE 变量,在 .env 文件内配置 -->
<title><%= VITE_GLOB_APP_TITLE %></title> <title><%= VITE_APP_TITLE %></title>
<link rel="icon" href="/favicon.ico" /> <link rel="icon" href="/favicon.ico" />
<script> <script>
// 生产环境下注入百度统计 // 生产环境下注入百度统计
......
import { useAppConfig } from '@vben/hooks';
import { defineOverridesPreferences } from '@vben/preferences'; import { defineOverridesPreferences } from '@vben/preferences';
const { appTitle } = useAppConfig(import.meta.env, import.meta.env.PROD);
/** /**
* @description 项目配置文件 * @description 项目配置文件
* 只需要覆盖项目中的一部分配置,不需要的配置不用覆盖,会自动使用默认配置 * 只需要覆盖项目中的一部分配置,不需要的配置不用覆盖,会自动使用默认配置
*/ */
export const overridesPreferences = defineOverridesPreferences({ export const overridesPreferences = defineOverridesPreferences({
// overrides // overrides
app: {
name: appTitle,
},
}); });
import { import { defineConfig } from '@vben/vite-config';
defaultImportmapOptions,
defineConfig,
getDefaultPwaOptions,
loadAndConvertEnv,
} from '@vben/vite-config';
export default defineConfig(async () => { export default defineConfig(async () => {
const { appTitle, base, port, ...envConfig } = await loadAndConvertEnv();
return { return {
application: { application: {},
...envConfig,
importmap: false,
importmapOptions: defaultImportmapOptions,
pwa: false,
pwaOptions: getDefaultPwaOptions(appTitle),
},
vite: { vite: {
base,
server: { server: {
port,
proxy: { proxy: {
'/api': { '/api': {
changeOrigin: true, changeOrigin: true,
......
...@@ -8,11 +8,14 @@ import { findMonorepoRoot } from '@vben/node-utils'; ...@@ -8,11 +8,14 @@ import { findMonorepoRoot } from '@vben/node-utils';
import { defineConfig, loadEnv, mergeConfig } from 'vite'; import { defineConfig, loadEnv, mergeConfig } from 'vite';
import { getDefaultPwaOptions } from '../options';
import { loadApplicationPlugins } from '../plugins'; import { loadApplicationPlugins } from '../plugins';
import { loadAndConvertEnv } from '../utils/env';
import { getCommonConfig } from './common'; import { getCommonConfig } from './common';
function defineApplicationConfig(userConfigPromise: DefineApplicationOptions) { function defineApplicationConfig(userConfigPromise: DefineApplicationOptions) {
return defineConfig(async (config) => { return defineConfig(async (config) => {
const { appTitle, base, port, ...envConfig } = await loadAndConvertEnv();
const options = await userConfigPromise?.(config); const options = await userConfigPromise?.(config);
const { command, mode } = config; const { command, mode } = config;
const { application = {}, vite = {} } = options || {}; const { application = {}, vite = {} } = options || {};
...@@ -40,12 +43,15 @@ function defineApplicationConfig(userConfigPromise: DefineApplicationOptions) { ...@@ -40,12 +43,15 @@ function defineApplicationConfig(userConfigPromise: DefineApplicationOptions) {
'Vben Admin Docs': 'https://docs.vben.pro', 'Vben Admin Docs': 'https://docs.vben.pro',
}, },
pwa: true, pwa: true,
pwaOptions: getDefaultPwaOptions(appTitle),
...envConfig,
...application, ...application,
}); });
const { injectGlobalScss = true } = application; const { injectGlobalScss = true } = application;
const applicationConfig: UserConfig = { const applicationConfig: UserConfig = {
base,
build: { build: {
rollupOptions: { rollupOptions: {
output: { output: {
...@@ -69,6 +75,7 @@ function defineApplicationConfig(userConfigPromise: DefineApplicationOptions) { ...@@ -69,6 +75,7 @@ function defineApplicationConfig(userConfigPromise: DefineApplicationOptions) {
plugins, plugins,
server: { server: {
host: true, host: true,
port,
warmup: { warmup: {
// 预热文件 // 预热文件
clientFiles: ['./index.html', './src/{views,layouts}/*'], clientFiles: ['./index.html', './src/{views,layouts}/*'],
......
...@@ -28,7 +28,7 @@ const getDefaultPwaOptions = (name: string): Partial<PwaPluginOptions> => ({ ...@@ -28,7 +28,7 @@ const getDefaultPwaOptions = (name: string): Partial<PwaPluginOptions> => ({
const defaultImportmapOptions: ImportmapPluginOptions = { const defaultImportmapOptions: ImportmapPluginOptions = {
// 通过 Importmap CDN 方式引入, // 通过 Importmap CDN 方式引入,
// 目前只有esm.sh源兼容性好一点,jspm.io对于 esm 入口要求高 // 目前只有esm.sh源兼容性好一点,jspm.io对于 esm 入口要求高
defaultProvider: 'esm.sh', defaultProvider: 'jspm.io',
importmap: [ importmap: [
{ name: 'vue' }, { name: 'vue' },
{ name: 'pinia' }, { name: 'pinia' },
......
...@@ -110,5 +110,5 @@ ...@@ -110,5 +110,5 @@
</style> </style>
<div class="loading" id="__app-loading__"> <div class="loading" id="__app-loading__">
<span class="dot dot-spin"><i></i><i></i><i></i><i></i></span> <span class="dot dot-spin"><i></i><i></i><i></i><i></i></span>
<div class="title"><%= VITE_GLOB_APP_TITLE %></div> <div class="title"><%= VITE_APP_TITLE %></div>
</div> </div>
...@@ -109,5 +109,5 @@ ...@@ -109,5 +109,5 @@
</style> </style>
<div class="loading" id="__app-loading__"> <div class="loading" id="__app-loading__">
<div class="loader"></div> <div class="loader"></div>
<div class="title"><%= VITE_GLOB_APP_TITLE %></div> <div class="title"><%= VITE_APP_TITLE %></div>
</div> </div>
...@@ -64,10 +64,10 @@ async function loadAndConvertEnv( ...@@ -64,10 +64,10 @@ async function loadAndConvertEnv(
> { > {
const envConfig = await loadEnv(match, confFiles); const envConfig = await loadEnv(match, confFiles);
const { const {
VITE_APP_TITLE,
VITE_BASE, VITE_BASE,
VITE_COMPRESS, VITE_COMPRESS,
VITE_DEVTOOLS, VITE_DEVTOOLS,
VITE_GLOB_APP_TITLE,
VITE_INJECT_APP_LOADING, VITE_INJECT_APP_LOADING,
VITE_NITRO_MOCK, VITE_NITRO_MOCK,
VITE_PORT, VITE_PORT,
...@@ -80,7 +80,7 @@ async function loadAndConvertEnv( ...@@ -80,7 +80,7 @@ async function loadAndConvertEnv(
.filter((item) => item === 'brotli' || item === 'gzip'); .filter((item) => item === 'brotli' || item === 'gzip');
return { return {
appTitle: VITE_GLOB_APP_TITLE ?? 'Vben Admin', appTitle: VITE_APP_TITLE ?? 'Vben Admin',
base: VITE_BASE || '/', base: VITE_BASE || '/',
compress: !!compress, compress: !!compress,
compressTypes: compressTypes as ('brotli' | 'gzip')[], compressTypes: compressTypes as ('brotli' | 'gzip')[],
......
...@@ -31,14 +31,13 @@ ...@@ -31,14 +31,13 @@
"build:analyze": "turbo build:analyze", "build:analyze": "turbo build:analyze",
"build:docker": "./build-local-docker-image.sh", "build:docker": "./build-local-docker-image.sh",
"changeset": "pnpm exec changeset", "changeset": "pnpm exec changeset",
"check": "pnpm run check:dep && pnpm run check:circular && pnpm run check:type && pnpm run check:cspell", "check": "pnpm run check:circular && pnpm run check:dep && pnpm run check:type",
"check:circular": "vsh check-circular", "check:circular": "vsh check-circular",
"check:cspell": "cspell lint \"**/*.ts\" \"**/README.md\" \".changeset/*.md\" --no-progress",
"check:dep": "vsh check-dep", "check:dep": "vsh check-dep",
"check:type": "turbo run typecheck", "check:type": "turbo run typecheck",
"clean": "vsh clean", "clean": "vsh clean",
"commit": "czg", "commit": "czg",
"dev": "cross-env TURBO_UI=1 turbo run dev", "dev": "cross-env turbo run dev",
"dev:docs": "pnpm -F @vben/website run docs:dev", "dev:docs": "pnpm -F @vben/website run docs:dev",
"format": "vsh lint --format", "format": "vsh lint --format",
"lint": "vsh lint", "lint": "vsh lint",
...@@ -56,7 +55,7 @@ ...@@ -56,7 +55,7 @@
"@changesets/cli": "^2.27.7", "@changesets/cli": "^2.27.7",
"@ls-lint/ls-lint": "^2.2.3", "@ls-lint/ls-lint": "^2.2.3",
"@types/jsdom": "^21.1.7", "@types/jsdom": "^21.1.7",
"@types/node": "^20.14.12", "@types/node": "^22.0.0",
"@vben/commitlint-config": "workspace:*", "@vben/commitlint-config": "workspace:*",
"@vben/eslint-config": "workspace:*", "@vben/eslint-config": "workspace:*",
"@vben/lint-staged-config": "workspace:*", "@vben/lint-staged-config": "workspace:*",
...@@ -95,11 +94,6 @@ ...@@ -95,11 +94,6 @@
"canvas", "canvas",
"node-gyp", "node-gyp",
"playwright" "playwright"
], ]
"updateConfig": {
"ignoreDependencies": [
"zx"
]
}
} }
} }
...@@ -31,7 +31,7 @@ function handleClick(path?: string) { ...@@ -31,7 +31,7 @@ function handleClick(path?: string) {
> >
<li> <li>
<a href="javascript:void 0" @click.stop="handleClick(item.path)"> <a href="javascript:void 0" @click.stop="handleClick(item.path)">
<span class="flex-center h-full"> <span class="flex-center z-10 h-full">
<VbenIcon <VbenIcon
v-if="item.icon && showIcon" v-if="item.icon && showIcon"
:icon="item.icon" :icon="item.icon"
......
...@@ -11,6 +11,7 @@ import { cn } from '@vben-core/toolkit'; ...@@ -11,6 +11,7 @@ import { cn } from '@vben-core/toolkit';
interface Props { interface Props {
class?: HTMLAttributes['class']; class?: HTMLAttributes['class'];
horizontal?: boolean; horizontal?: boolean;
scrollBarClass?: HTMLAttributes['class'];
shadow?: boolean; shadow?: boolean;
shadowBorder?: boolean; shadowBorder?: boolean;
} }
...@@ -58,7 +59,11 @@ function handleScroll(event: Event) { ...@@ -58,7 +59,11 @@ function handleScroll(event: Event) {
}" }"
class="scrollbar-bottom-shadow pointer-events-none absolute bottom-0 z-10 h-12 w-full opacity-0 transition-opacity duration-300 ease-in-out will-change-[opacity]" class="scrollbar-bottom-shadow pointer-events-none absolute bottom-0 z-10 h-12 w-full opacity-0 transition-opacity duration-300 ease-in-out will-change-[opacity]"
></div> ></div>
<ScrollBar v-if="horizontal" orientation="horizontal" /> <ScrollBar
v-if="horizontal"
:class="scrollBarClass"
orientation="horizontal"
/>
</ScrollArea> </ScrollArea>
</template> </template>
......
...@@ -71,7 +71,11 @@ function scrollIntoView() { ...@@ -71,7 +71,11 @@ function scrollIntoView() {
<template> <template>
<div :style="style" class="tabs-chrome size-full flex-1 overflow-hidden pt-1"> <div :style="style" class="tabs-chrome size-full flex-1 overflow-hidden pt-1">
<VbenScrollbar class="tabs-chrome__scrollbar h-full" horizontal> <VbenScrollbar
class="tabs-chrome__scrollbar h-full"
horizontal
scroll-bar-class="z-10"
>
<!-- footer -> 4px --> <!-- footer -> 4px -->
<div <div
ref="contentRef" ref="contentRef"
......
...@@ -72,7 +72,11 @@ function scrollIntoView() { ...@@ -72,7 +72,11 @@ function scrollIntoView() {
<template> <template>
<div class="h-full flex-1 overflow-hidden"> <div class="h-full flex-1 overflow-hidden">
<VbenScrollbar class="tabs-scrollbar h-full" horizontal> <VbenScrollbar
class="tabs-scrollbar h-full"
horizontal
scroll-bar-class="z-10"
>
<div <div
:class="contentClass" :class="contentClass"
class="relative !flex h-full w-max items-center" class="relative !flex h-full w-max items-center"
......
...@@ -45,6 +45,11 @@ async function initTabsSortable() { ...@@ -45,6 +45,11 @@ async function initTabsSortable() {
const el = document.querySelectorAll(`.${contentClass}`)?.[0] as HTMLElement; const el = document.querySelectorAll(`.${contentClass}`)?.[0] as HTMLElement;
const resetElState = () => {
el.style.cursor = 'default';
el.classList.remove('dragging');
};
const { initializeSortable } = useSortable(el, { const { initializeSortable } = useSortable(el, {
filter: (_evt, target: HTMLElement) => { filter: (_evt, target: HTMLElement) => {
const parent = findParentElement(target); const parent = findParentElement(target);
...@@ -57,16 +62,20 @@ async function initTabsSortable() { ...@@ -57,16 +62,20 @@ async function initTabsSortable() {
const { srcElement } = (evt as any).originalEvent; const { srcElement } = (evt as any).originalEvent;
if (!srcElement) { if (!srcElement) {
resetElState();
return; return;
} }
const srcParent = findParentElement(srcElement); const srcParent = findParentElement(srcElement);
if (!srcParent) { if (!srcParent) {
resetElState();
return; return;
} }
if (!srcParent.classList.contains('dragable')) { if (!srcParent.classList.contains('dragable')) {
resetElState();
return; return;
} }
...@@ -79,8 +88,7 @@ async function initTabsSortable() { ...@@ -79,8 +88,7 @@ async function initTabsSortable() {
) { ) {
emit('sortTabs', oldIndex, newIndex); emit('sortTabs', oldIndex, newIndex);
} }
el.classList.remove('dragging'); resetElState();
el.style.cursor = 'default';
}, },
onMove(evt) { onMove(evt) {
const parent = findParentElement(evt.related); const parent = findParentElement(evt.related);
......
...@@ -15,10 +15,9 @@ export function useAppConfig( ...@@ -15,10 +15,9 @@ export function useAppConfig(
? window._VBEN_ADMIN_PRO_APP_CONF_ ? window._VBEN_ADMIN_PRO_APP_CONF_
: (env as VbenAdminProAppConfigRaw); : (env as VbenAdminProAppConfigRaw);
const { VITE_GLOB_API_URL, VITE_GLOB_APP_TITLE } = config; const { VITE_GLOB_API_URL } = config;
return { return {
apiURL: VITE_GLOB_API_URL, apiURL: VITE_GLOB_API_URL,
appTitle: VITE_GLOB_APP_TITLE,
}; };
} }
...@@ -121,7 +121,10 @@ export const useCoreTabbarStore = defineStore('core-tabbar', { ...@@ -121,7 +121,10 @@ export const useCoreTabbarStore = defineStore('core-tabbar', {
} else { } else {
// 页面已经存在,不重复添加选项卡,只更新选项卡参数 // 页面已经存在,不重复添加选项卡,只更新选项卡参数
const currentTab = toRaw(this.tabs)[tabIndex]; const currentTab = toRaw(this.tabs)[tabIndex];
this.tabs.splice(tabIndex, 1, { ...currentTab, ...tab }); if (!currentTab.meta.affixTab) {
const mergedTab = { ...currentTab, ...tab };
this.tabs.splice(tabIndex, 1, mergedTab);
}
} }
this.updateCacheTab(); this.updateCacheTab();
}, },
...@@ -269,7 +272,8 @@ export const useCoreTabbarStore = defineStore('core-tabbar', { ...@@ -269,7 +272,8 @@ export const useCoreTabbarStore = defineStore('core-tabbar', {
); );
if (index !== -1) { if (index !== -1) {
tab.meta.affixTab = true; tab.meta.affixTab = true;
this.addTab(tab); // this.addTab(tab);
this.tabs.splice(index, 1, tab);
} }
}, },
...@@ -369,7 +373,8 @@ export const useCoreTabbarStore = defineStore('core-tabbar', { ...@@ -369,7 +373,8 @@ export const useCoreTabbarStore = defineStore('core-tabbar', {
if (index !== -1) { if (index !== -1) {
tab.meta.affixTab = false; tab.meta.affixTab = false;
this.addTab(tab); // this.addTab(tab);
this.tabs.splice(index, 1, tab);
} }
}, },
......
...@@ -8,12 +8,10 @@ declare module 'vue-router' { ...@@ -8,12 +8,10 @@ declare module 'vue-router' {
export interface VbenAdminProAppConfigRaw { export interface VbenAdminProAppConfigRaw {
VITE_GLOB_API_URL: string; VITE_GLOB_API_URL: string;
VITE_GLOB_APP_TITLE: string;
} }
export interface ApplicationConfig { export interface ApplicationConfig {
apiURL: string; apiURL: string;
appTitle: string;
} }
declare global { declare global {
......
...@@ -20,6 +20,7 @@ async function runLint({ format }: LintCommandOptions) { ...@@ -20,6 +20,7 @@ async function runLint({ format }: LintCommandOptions) {
} }
$.verbose = true; $.verbose = true;
await Promise.all([ await Promise.all([
$`cspell lint "**/*.ts" "**/README.md" ".changeset/*.md" --no-progress`,
$`eslint . --cache`, $`eslint . --cache`,
// $`ls-lint`, // $`ls-lint`,
$`prettier . --ignore-unknown --check --cache`, $`prettier . --ignore-unknown --check --cache`,
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
::: tip ::: tip
因为微信群人数有限制,加微信群前,你可以通过[赞助](../sponsor/personal.md)任意金额,并备注 `加入微信群`,作者会将你拉入微信群。也可以主动发送截图给作者。 因为微信群人数有限制,加微信群前,你可以通过[赞助](../sponsor/personal.md)任意金额,以主动发送截图给作者,备注`加入微信群`即可。
::: :::
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
在 `package.json` 中引入包: 在 `package.json` 中引入包:
```json ```json {3}
{ {
"dependencies": { "dependencies": {
"@vben/utils": "workspace:*" "@vben/utils": "workspace:*"
...@@ -46,7 +46,7 @@ import { isString } from '@vben/utils'; ...@@ -46,7 +46,7 @@ import { isString } from '@vben/utils';
在项目中,你可以看到一些 `#` 开头的路径,例如: `#/api`、`#/views`, 这些路径都是别名,用于快速定位到某个目录。它不是通过 `vite` 的 `alias` 实现的,而是通过 `Node.js` 本身的 [subpath imports](https://nodejs.org/api/packages.html#subpath-imports) 原理。只需要在 `package.json` 中配置 `imports` 字段即可。 在项目中,你可以看到一些 `#` 开头的路径,例如: `#/api`、`#/views`, 这些路径都是别名,用于快速定位到某个目录。它不是通过 `vite` 的 `alias` 实现的,而是通过 `Node.js` 本身的 [subpath imports](https://nodejs.org/api/packages.html#subpath-imports) 原理。只需要在 `package.json` 中配置 `imports` 字段即可。
```json ```json {3}
{ {
"imports": { "imports": {
"#/*": "./src/*" "#/*": "./src/*"
...@@ -56,7 +56,7 @@ import { isString } from '@vben/utils'; ...@@ -56,7 +56,7 @@ import { isString } from '@vben/utils';
为了 IDE 能够识别这些别名,我们还需要在`tsconfig.json`内配置: 为了 IDE 能够识别这些别名,我们还需要在`tsconfig.json`内配置:
```json ```json {5}
{ {
"compilerOptions": { "compilerOptions": {
"baseUrl": ".", "baseUrl": ".",
......
...@@ -55,11 +55,9 @@ npm 脚本是项目常见的配置,用于执行一些常见的任务,比如 ...@@ -55,11 +55,9 @@ npm 脚本是项目常见的配置,用于执行一些常见的任务,比如
// changeset 版本管理 // changeset 版本管理
"changeset": "pnpm exec changeset", "changeset": "pnpm exec changeset",
// 检查项目各种问题 // 检查项目各种问题
"check": "pnpm run check:dep && pnpm run check:circular && pnpm run check:type && pnpm run check:cspell", "check": "pnpm run check:circular && pnpm run check:dep && pnpm run check:type",,
// 检查循环引用 // 检查循环引用
"check:circular": "vsh check-circular", "check:circular": "vsh check-circular",
// 检查拼写
"check:cspell": "cspell lint \"**/*.ts\" \"**/README.md\" \".changeset/*.md\" --no-progress",
// 检查依赖 // 检查依赖
"check:dep": "vsh check-dep", "check:dep": "vsh check-dep",
// 检查类型 // 检查类型
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
```bash [.env] ```bash [.env]
# 应用标题 # 应用标题
VITE_GLOB_APP_TITLE=Vben Admin VITE_APP_TITLE=Vben Admin
# 应用命名空间,用于缓存、store等功能的前缀,确保隔离 # 应用命名空间,用于缓存、store等功能的前缀,确保隔离
VITE_APP_NAMESPACE=vben-web-antd VITE_APP_NAMESPACE=vben-web-antd
...@@ -88,7 +88,6 @@ VITE_INJECT_APP_LOADING=true ...@@ -88,7 +88,6 @@ VITE_INJECT_APP_LOADING=true
```ts ```ts
window._VBEN_ADMIN_PRO_APP_CONF_ = { window._VBEN_ADMIN_PRO_APP_CONF_ = {
VITE_GLOB_API_URL: 'https://mock-napi.vben.pro/api', VITE_GLOB_API_URL: 'https://mock-napi.vben.pro/api',
VITE_GLOB_APP_TITLE: 'Vben Admin',
}; };
Object.freeze(window._VBEN_ADMIN_PRO_APP_CONF_); Object.freeze(window._VBEN_ADMIN_PRO_APP_CONF_);
Object.defineProperty(window, '_VBEN_ADMIN_PRO_APP_CONF_', { Object.defineProperty(window, '_VBEN_ADMIN_PRO_APP_CONF_', {
...@@ -124,13 +123,11 @@ const { apiURL } = useAppConfig(import.meta.env, import.meta.env.PROD); ...@@ -124,13 +123,11 @@ const { apiURL } = useAppConfig(import.meta.env, import.meta.env.PROD);
```ts ```ts
export interface VbenAdminProAppConfigRaw { export interface VbenAdminProAppConfigRaw {
VITE_GLOB_API_URL: string; VITE_GLOB_API_URL: string;
VITE_GLOB_APP_TITLE: string;
VITE_GLOB_OTHER_API_URL: string; // [!code ++] VITE_GLOB_OTHER_API_URL: string; // [!code ++]
} }
export interface ApplicationConfig { export interface ApplicationConfig {
apiURL: string; apiURL: string;
appTitle: string;
otherApiURL: string; // [!code ++] otherApiURL: string; // [!code ++]
} }
``` ```
...@@ -159,17 +156,12 @@ const { otherApiURL } = useAppConfig(import.meta.env, import.meta.env.PROD); ...@@ -159,17 +156,12 @@ const { otherApiURL } = useAppConfig(import.meta.env, import.meta.env.PROD);
import { useAppConfig } from '@vben/hooks'; import { useAppConfig } from '@vben/hooks';
import { defineOverridesPreferences } from '@vben/preferences'; import { defineOverridesPreferences } from '@vben/preferences';
const { appTitle } = useAppConfig(import.meta.env, import.meta.env.PROD);
/** /**
* @description 项目配置文件 * @description 项目配置文件
* 只需要覆盖项目中的一部分配置,不需要的配置不用覆盖,会自动使用默认配置 * 只需要覆盖项目中的一部分配置,不需要的配置不用覆盖,会自动使用默认配置
*/ */
export const overridesPreferences = defineOverridesPreferences({ export const overridesPreferences = defineOverridesPreferences({
// overrides // overrides
app: {
name: appTitle,
},
}); });
``` ```
......
...@@ -22,7 +22,7 @@ VITE_INJECT_APP_LOADING=false ...@@ -22,7 +22,7 @@ VITE_INJECT_APP_LOADING=false
::: tip ::: tip
- 你可以使用跟`index.html`一样的语法,比如`VITE_GLOB_APP_TITLE`变量,来获取应用的标题。 - 你可以使用跟`index.html`一样的语法,比如`VITE_APP_TITLE`变量,来获取应用的标题。
- 必须保证有一个`id="__app-loading__"`的元素。 - 必须保证有一个`id="__app-loading__"`的元素。
- 必须保证有一个`style[data-app-loading="inject-css"]`的元素。 - 必须保证有一个`style[data-app-loading="inject-css"]`的元素。
...@@ -32,6 +32,6 @@ VITE_INJECT_APP_LOADING=false ...@@ -32,6 +32,6 @@ VITE_INJECT_APP_LOADING=false
</style> </style>
<div id="__app-loading__"> <div id="__app-loading__">
<!-- ... --> <!-- ... -->
<div class="title"><%= VITE_GLOB_APP_TITLE %></div> <div class="title"><%= VITE_APP_TITLE %></div>
</div> </div>
``` ```
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!