Skip to content

Commit 66fd052

Browse files
committed
fix: fix known issues. fixed #59,fixed #61, fixed #67, fixed #68 [deploy]
1 parent b98f9f9 commit 66fd052

26 files changed

Lines changed: 163 additions & 155 deletions

File tree

‎.github/workflows/deploy.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
jobs:
99
deploy-push-ftp:
1010
name: Deploy Push Ftp
11-
if: github.actor != 'dependabot[bot]' && !contains(github.event.head_commit.message, '[skip ci]')
11+
if: github.actor != 'dependabot[bot]' && !contains(github.event.head_commit.message, '[skip ci]') && contains(github.event.head_commit.message, '[deploy]')
1212
runs-on: ubuntu-latest
1313
strategy:
1414
matrix:

‎apps/web-antd/.env‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# 应用标题
2-
VITE_GLOB_APP_TITLE=Vben Admin
2+
VITE_APP_TITLE=Vben Admin
33

44
# 应用命名空间,用于缓存、store等功能的前缀,确保隔离
55
VITE_APP_NAMESPACE=vben-web-antd

‎apps/web-antd/index.html‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
name="viewport"
1212
content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=0"
1313
/>
14-
<!-- 由 vite 注入 VITE_GLOB_APP_TITLE 变量,在 .env 文件内配置 -->
15-
<title><%= VITE_GLOB_APP_TITLE %></title>
14+
<!-- 由 vite 注入 VITE_APP_TITLE 变量,在 .env 文件内配置 -->
15+
<title><%= VITE_APP_TITLE %></title>
1616
<link rel="icon" href="/favicon.ico" />
1717
<script>
1818
// 生产环境下注入百度统计

‎apps/web-antd/src/preferences.ts‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
1-
import { useAppConfig } from '@vben/hooks';
21
import { defineOverridesPreferences } from '@vben/preferences';
32

4-
const { appTitle } = useAppConfig(import.meta.env, import.meta.env.PROD);
5-
63
/**
74
* @description 项目配置文件
85
* 只需要覆盖项目中的一部分配置,不需要的配置不用覆盖,会自动使用默认配置
96
*/
107
export const overridesPreferences = defineOverridesPreferences({
118
// overrides
12-
app: {
13-
name: appTitle,
14-
},
159
});

‎apps/web-antd/vite.config.mts‎

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,10 @@
1-
import {
2-
defaultImportmapOptions,
3-
defineConfig,
4-
getDefaultPwaOptions,
5-
loadAndConvertEnv,
6-
} from '@vben/vite-config';
1+
import { defineConfig } from '@vben/vite-config';
72

83
export default defineConfig(async () => {
9-
const { appTitle, base, port, ...envConfig } = await loadAndConvertEnv();
104
return {
11-
application: {
12-
...envConfig,
13-
importmap: false,
14-
importmapOptions: defaultImportmapOptions,
15-
pwa: false,
16-
pwaOptions: getDefaultPwaOptions(appTitle),
17-
},
5+
application: {},
186
vite: {
19-
base,
207
server: {
21-
port,
228
proxy: {
239
'/api': {
2410
changeOrigin: true,

‎internal/vite-config/src/config/application.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,14 @@ import { findMonorepoRoot } from '@vben/node-utils';
88

99
import { defineConfig, loadEnv, mergeConfig } from 'vite';
1010

11+
import { getDefaultPwaOptions } from '../options';
1112
import { loadApplicationPlugins } from '../plugins';
13+
import { loadAndConvertEnv } from '../utils/env';
1214
import { getCommonConfig } from './common';
1315

1416
function defineApplicationConfig(userConfigPromise: DefineApplicationOptions) {
1517
return defineConfig(async (config) => {
18+
const { appTitle, base, port, ...envConfig } = await loadAndConvertEnv();
1619
const options = await userConfigPromise?.(config);
1720
const { command, mode } = config;
1821
const { application = {}, vite = {} } = options || {};
@@ -40,12 +43,15 @@ function defineApplicationConfig(userConfigPromise: DefineApplicationOptions) {
4043
'Vben Admin Docs': 'https://docs.vben.pro',
4144
},
4245
pwa: true,
46+
pwaOptions: getDefaultPwaOptions(appTitle),
47+
...envConfig,
4348
...application,
4449
});
4550

4651
const { injectGlobalScss = true } = application;
4752

4853
const applicationConfig: UserConfig = {
54+
base,
4955
build: {
5056
rollupOptions: {
5157
output: {
@@ -69,6 +75,7 @@ function defineApplicationConfig(userConfigPromise: DefineApplicationOptions) {
6975
plugins,
7076
server: {
7177
host: true,
78+
port,
7279
warmup: {
7380
// 预热文件
7481
clientFiles: ['./index.html', './src/{views,layouts}/*'],

‎internal/vite-config/src/options.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const getDefaultPwaOptions = (name: string): Partial<PwaPluginOptions> => ({
2828
const defaultImportmapOptions: ImportmapPluginOptions = {
2929
// 通过 Importmap CDN 方式引入,
3030
// 目前只有esm.sh源兼容性好一点,jspm.io对于 esm 入口要求高
31-
defaultProvider: 'esm.sh',
31+
defaultProvider: 'jspm.io',
3232
importmap: [
3333
{ name: 'vue' },
3434
{ name: 'pinia' },

‎internal/vite-config/src/plugins/inject-app-loading/default-loading-antd.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,5 +110,5 @@
110110
</style>
111111
<div class="loading" id="__app-loading__">
112112
<span class="dot dot-spin"><i></i><i></i><i></i><i></i></span>
113-
<div class="title"><%= VITE_GLOB_APP_TITLE %></div>
113+
<div class="title"><%= VITE_APP_TITLE %></div>
114114
</div>

‎internal/vite-config/src/plugins/inject-app-loading/default-loading.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,5 +109,5 @@
109109
</style>
110110
<div class="loading" id="__app-loading__">
111111
<div class="loader"></div>
112-
<div class="title"><%= VITE_GLOB_APP_TITLE %></div>
112+
<div class="title"><%= VITE_APP_TITLE %></div>
113113
</div>

‎internal/vite-config/src/utils/env.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ async function loadAndConvertEnv(
6464
> {
6565
const envConfig = await loadEnv(match, confFiles);
6666
const {
67+
VITE_APP_TITLE,
6768
VITE_BASE,
6869
VITE_COMPRESS,
6970
VITE_DEVTOOLS,
70-
VITE_GLOB_APP_TITLE,
7171
VITE_INJECT_APP_LOADING,
7272
VITE_NITRO_MOCK,
7373
VITE_PORT,
@@ -80,7 +80,7 @@ async function loadAndConvertEnv(
8080
.filter((item) => item === 'brotli' || item === 'gzip');
8181

8282
return {
83-
appTitle: VITE_GLOB_APP_TITLE ?? 'Vben Admin',
83+
appTitle: VITE_APP_TITLE ?? 'Vben Admin',
8484
base: VITE_BASE || '/',
8585
compress: !!compress,
8686
compressTypes: compressTypes as ('brotli' | 'gzip')[],

0 commit comments

Comments
 (0)