FrontendSlimming:打包报错AI梳理修改瘦身

This commit is contained in:
zhugongping 2026-09-23 21:29:01 +08:00
parent 7fd5da85d1
commit f446ee15e6
14 changed files with 10 additions and 1232 deletions

View File

@ -66,8 +66,6 @@
"lodash": "^4.17.21", "lodash": "^4.17.21",
"minimatch": "^3.1.2", "minimatch": "^3.1.2",
"moment": "^2.29.4", "moment": "^2.29.4",
"monaco-editor": "0.27.0",
"monaco-editor-webpack-plugin": "4.2.0",
"mqtt": "^4.3.3", "mqtt": "^4.3.3",
"nprogress": "0.2.0", "nprogress": "0.2.0",
"photo-sphere-viewer": "^4.8.1", "photo-sphere-viewer": "^4.8.1",

View File

@ -1,63 +0,0 @@
<template>
<div ref="main" :style="`width: 100%; height: ${height}`"></div>
</template>
<script>
import * as monaco from 'monaco-editor';
export default {
props: {
height: {
type: String,
default: '300px',
},
language: {
type: String,
default: 'javascript',
},
value: String,
},
data() {
return {
monacoEditor: null,
};
},
mounted() {
this.init();
},
methods: {
init() {
// 使用 - 创建 monacoEditor 对象
this.monacoEditor = monaco.editor.create(this.$refs.main, {
theme: 'vs-dark', // 主题
value: this.value ? this.value : '', // 默认显示的值
language: this.language,
folding: true, // 是否折叠
foldingHighlight: true, // 折叠等高线
foldingStrategy: 'indentation', // 折叠方式 auto | indentation
showFoldingControls: 'always', // 是否一直显示折叠 always | mouseover
disableLayerHinting: true, // 等宽优化
emptySelectionClipboard: false, // 空选择剪切板
selectionClipboard: false, // 选择剪切板
automaticLayout: true, // 自动布局
codeLens: false, // 代码镜头
scrollBeyondLastLine: false, // 滚动完最后一行后再滚动一屏幕
colorDecorators: true, // 颜色装饰器
accessibilitySupport: 'off', // 辅助功能支持 "auto" | "off" | "on"
lineNumbers: 'on', // 行号 取值: "on" | "off" | "relative" | "interval" | function
lineNumbersMinChars: 5, // 行号最小字符 number
enableSplitViewResizing: false,
readOnly: false, //是否只读 取值 true | false
});
// 编辑器内容发生改变时触发
this.monacoEditor.onDidChangeModelContent(() => {
this.$emit('change', this.monacoEditor.getValue());
});
},
setValue(val) {
this.monacoEditor.setValue(val);
},
},
};
</script>

View File

@ -32,7 +32,6 @@ import ImageUpload from '@/components/ImageUpload'; // 图片上传组件
import ImagePreview from '@/components/ImagePreview'; // 图片预览组件 import ImagePreview from '@/components/ImagePreview'; // 图片预览组件
import DictTag from '@/components/DictTag'; // 字典标签组件 import DictTag from '@/components/DictTag'; // 字典标签组件
import DictData from '@/components/DictData'; // 字典数据组件 import DictData from '@/components/DictData'; // 字典数据组件
import MonacoEditor from '@/components/MonacoEditor'; //代码编辑器
import Element from 'element-ui'; import Element from 'element-ui';
import './assets/styles/element-variables.scss'; import './assets/styles/element-variables.scss';
@ -81,7 +80,6 @@ Vue.component('FileUpload', FileUpload);
Vue.component('ImageUpload', ImageUpload); Vue.component('ImageUpload', ImageUpload);
Vue.component('ImagePreview', ImagePreview); Vue.component('ImagePreview', ImagePreview);
Vue.component('DictTag', DictTag); Vue.component('DictTag', DictTag);
Vue.component('MonacoEditor', MonacoEditor);
Vue.use(plugins); Vue.use(plugins);
Vue.use(directive); Vue.use(directive);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -6,7 +6,6 @@ function resolve(dir) {
} }
const CompressionPlugin = require('compression-webpack-plugin'); const CompressionPlugin = require('compression-webpack-plugin');
const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
const name = process.env.VUE_APP_TITLE || '岩安测控数据平台'; // 网页标题 const name = process.env.VUE_APP_TITLE || '岩安测控数据平台'; // 网页标题
@ -56,6 +55,16 @@ module.exports = {
}, },
configureWebpack: { configureWebpack: {
name: name, name: name,
// 打包体积提示阈值校准(webpack 默认 244KiB 会导致每次构建必报 2 条 warning,丧失告警意义)
// 本项目是功能密集的 IoT 管理平台,产物中含 H.265 播放器 wasm 解码器、ECharts、
// Three.js、Excel 导出、可视化大屏等重型依赖,244KiB 的建议值并不适用于此类应用。
// 这里按实际基线设阈值,保留告警能力:一旦某资源异常膨胀(例如误引入大依赖)仍会提示。
// 基线(生产构建实测):单资源最大 chunk-libs.js ≈ 2.55MiB,入口 app 合计 ≈ 4.53MiB
performance: {
hints: 'warning',
maxAssetSize: 3 * 1024 * 1024, // 单个资源 3MiB
maxEntrypointSize: 5 * 1024 * 1024, // 入口合计 5MiB
},
resolve: { resolve: {
alias: { alias: {
'@': resolve('src'), '@': resolve('src'),
@ -70,7 +79,6 @@ module.exports = {
algorithm: 'gzip', // 使用gzip压缩 algorithm: 'gzip', // 使用gzip压缩
minRatio: 0.8, // 压缩率小于1才会压缩 minRatio: 0.8, // 压缩率小于1才会压缩
}), }),
new MonacoWebpackPlugin(),
], ],
}, },
chainWebpack(config) { chainWebpack(config) {