mirror of
https://github.com/jeecgboot/JeecgBoot.git
synced 2025-12-08 17:12:28 +08:00
v3.9.0 里程碑版本发布
This commit is contained in:
@ -1,9 +1,9 @@
|
||||
import { generate } from '@ant-design/colors';
|
||||
import setting from '/@/settings/projectSetting';
|
||||
|
||||
export const primaryColor = '#1890FF';
|
||||
|
||||
export const darkMode = 'light';
|
||||
|
||||
// 代码逻辑说明: 【JHHB-579】去掉写死的主题色,根据导航栏模式确定主题色
|
||||
export const primaryColor = setting.themeColor;
|
||||
export const darkMode = setting.themeMode;
|
||||
type Fn = (...arg: any) => any;
|
||||
|
||||
type GenerateTheme = 'default' | 'dark';
|
||||
|
||||
@ -36,14 +36,12 @@ function createConfig(params: CreateConfigParams) {
|
||||
console.log(colors.cyan(`✨ [${pkg.name}]`) + ` - configuration file is build successfully:`);
|
||||
console.log(colors.gray(OUTPUT_DIR + '/' + colors.green(configFileName)) + '\n');
|
||||
|
||||
// update-begin--author:sunjianlei---date:20250423---for:【QQYUN-9685】构建 electron 桌面应用
|
||||
// 如果是 Electron 环境,还需要将配置文件写入到 JSON 文件中
|
||||
if (config.VITE_GLOB_RUN_PLATFORM === 'electron') {
|
||||
writeFileSync(getRootPath(`${OUTPUT_DIR}/electron/env.json`), JSON.stringify(config));
|
||||
console.log(colors.cyan(`✨ [${pkg.name}]`) + ` - electron env file is build successfully:`);
|
||||
console.log(colors.gray(OUTPUT_DIR + '/' + colors.green('electron/env.json')) + '\n');
|
||||
}
|
||||
// update-end----author:sunjianlei---date:20250423---for:【QQYUN-9685】构建 electron 桌面应用
|
||||
|
||||
} catch (error) {
|
||||
console.log(colors.red('configuration file configuration file failed to package:\n' + error));
|
||||
|
||||
@ -51,17 +51,15 @@ export function wrapperEnv(envConf: Recordable): ViteEnv {
|
||||
*/
|
||||
function getConfFiles() {
|
||||
|
||||
// update-begin--author:sunjianlei---date:20250411---for:【QQYUN-9685】构建 electron 桌面应用
|
||||
// 代码逻辑说明: 【QQYUN-9685】构建 electron 桌面应用
|
||||
const {VITE_GLOB_RUN_PLATFORM} = process.env
|
||||
if (VITE_GLOB_RUN_PLATFORM === 'electron') {
|
||||
return ['.env', '.env.prod_electron'];
|
||||
}
|
||||
// update-end----author:sunjianlei---date:20250411---for:【QQYUN-9685】构建 electron 桌面应用
|
||||
|
||||
const script = process.env.npm_lifecycle_script;
|
||||
// update-begin--author:liaozhiyang---date:20240326---for:【QQYUN-8690】修正获取当前环境下的文件名
|
||||
// 代码逻辑说明: 【QQYUN-8690】修正获取当前环境下的文件名
|
||||
const reg = new RegExp('NODE_ENV=([a-z_\\d]+)');
|
||||
// update-end--author:liaozhiyang---date:20240326---for:【QQYUN-8690】修正获取当前环境下的文件名
|
||||
const result = reg.exec(script as string) as any;
|
||||
if (result) {
|
||||
const mode = result[1] as string;
|
||||
|
||||
@ -72,7 +72,7 @@ export function createVitePlugins(viteEnv: ViteEnv, isBuild: boolean, isQiankunM
|
||||
}
|
||||
|
||||
// // electron plugin
|
||||
// const isElectron = viteEnv.VITE_GLOB_RUN_PLATFORM === 'electron';
|
||||
const isElectron = viteEnv.VITE_GLOB_RUN_PLATFORM === 'electron';
|
||||
// if (isElectron) {
|
||||
// vitePlugins.push(configElectronPlugin(viteEnv, isBuild))
|
||||
// }
|
||||
@ -82,8 +82,11 @@ export function createVitePlugins(viteEnv: ViteEnv, isBuild: boolean, isQiankunM
|
||||
|
||||
// rollup-plugin-gzip
|
||||
vitePlugins.push(configCompressPlugin(VITE_BUILD_COMPRESS, VITE_BUILD_COMPRESS_DELETE_ORIGIN_FILE));
|
||||
|
||||
// vite-plugin-pwa (PWA 插件注册)
|
||||
vitePlugins.push(configPwaPlugin(isBuild));
|
||||
if (!isElectron) {
|
||||
vitePlugins.push(configPwaPlugin(isBuild));
|
||||
}
|
||||
}
|
||||
|
||||
// //vite-plugin-theme【预编译加载插件,解决vite首次打开界面加载慢问题】
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
/**
|
||||
* PWA 插件配置
|
||||
* 适配按需加载:只预缓存关键资源,按需加载的 chunk 使用运行时缓存
|
||||
* PWA 插件配置 - 适配按需加载
|
||||
*/
|
||||
import { VitePWA } from 'vite-plugin-pwa';
|
||||
import type { VitePWAOptions } from 'vite-plugin-pwa';
|
||||
@ -34,27 +33,25 @@ export function configPwaPlugin(isBuild: boolean): PluginOption | PluginOption[]
|
||||
],
|
||||
},
|
||||
workbox: {
|
||||
// 增加文件大小限制到 10MB
|
||||
maximumFileSizeToCacheInBytes: 10 * 1024 * 1024, // 10 MB
|
||||
maximumFileSizeToCacheInBytes: 10 * 1024 * 1024, // 10MB
|
||||
cleanupOutdatedCaches: true,
|
||||
|
||||
// 预缓存策略:只缓存关键资源,按需加载的 chunk 通过运行时缓存
|
||||
// 预缓存入口文件、CSS 和静态资源,以及核心 JS(入口和 vendor)
|
||||
// 预缓存:只缓存关键资源,不预缓存路由组件 CSS/JS(避免登录页加载全部资源)
|
||||
globPatterns: [
|
||||
'index.html',
|
||||
'index.html', // 必须预缓存(避免 non-precached-url 错误)
|
||||
'manifest.webmanifest',
|
||||
'**/*.css',
|
||||
'**/*.{ico,png,svg,woff2}',
|
||||
// 预缓存入口 JS 和核心 vendor chunk
|
||||
'assets/index-*.css', // 仅入口 CSS
|
||||
'favicon.ico',
|
||||
'logo.png',
|
||||
'js/index-*.js',
|
||||
'js/*-vendor-*.js',
|
||||
],
|
||||
// 注意:不预缓存按需加载的路由组件 chunk
|
||||
// 这些 chunk 将通过运行时缓存策略按需加载和缓存
|
||||
|
||||
// 运行时缓存策略:处理按需加载的资源
|
||||
// 不使用导航回退功能
|
||||
navigateFallback: undefined,
|
||||
|
||||
// 运行时缓存:按需加载的资源
|
||||
runtimeCaching: [
|
||||
// 按需加载的 JS chunk:优先网络,失败后使用缓存
|
||||
{
|
||||
urlPattern: /\/js\/.*\.js$/i,
|
||||
handler: 'NetworkFirst',
|
||||
@ -70,9 +67,8 @@ export function configPwaPlugin(isBuild: boolean): PluginOption | PluginOption[]
|
||||
},
|
||||
},
|
||||
},
|
||||
// CSS 文件:优先缓存
|
||||
{
|
||||
urlPattern: /\/css\/.*\.css$/i,
|
||||
urlPattern: /\/assets\/.*\.css$/i,
|
||||
handler: 'CacheFirst',
|
||||
options: {
|
||||
cacheName: 'css-cache',
|
||||
@ -129,8 +125,9 @@ export function configPwaPlugin(isBuild: boolean): PluginOption | PluginOption[]
|
||||
},
|
||||
},
|
||||
],
|
||||
skipWaiting: false,
|
||||
clientsClaim: false,
|
||||
// 启用立即更新:新 SW 立即激活并接管页面
|
||||
skipWaiting: true,
|
||||
clientsClaim: true,
|
||||
},
|
||||
devOptions: {
|
||||
enabled: false,
|
||||
|
||||
Reference in New Issue
Block a user