Răsfoiți Sursa

feat: 增加gzip配置,优化概览页面报图形报警级别颜色等

yanglzh 1 an în urmă
părinte
comite
b66f4aabea

+ 1 - 0
package.json

@@ -73,6 +73,7 @@
     "sass-loader": "^12.6.0",
     "typescript": "^4.6.2",
     "vite": "^2.9.16",
+    "vite-plugin-compression": "^0.5.1",
     "vue-eslint-parser": "^8.3.0"
   },
   "browserslist": [

+ 15 - 10
src/views/iot/iotmanager/dashboard.vue

@@ -10,14 +10,18 @@
 
 							<span class="font30">{{ v.allnum }}</span>
 						</div>
-						<div class="home-card-item-icon flex" >
-							<img :src="'/imgs/'+v.icoimg" class="icoimg">
+						<div class="home-card-item-icon flex">
+							<img :src="'/imgs/' + v.icoimg" class="icoimg">
 
 						</div>
 					</div>
 					<div class="flex" style="font-weight: bold;">
-						<div class="flex font14"><div class="title_status"  :style="{ backgroundColor: v.title1_bgcolor }"></div> {{ v.title1 }} {{ v.num1 }}</div>
-						<div class="flex ml20 font14"><div class="title_status"  :style="{  backgroundColor: v.title2_bgcolor}"></div>{{ v.title2 }} {{ v.num2 }}</div>
+						<div class="flex font14">
+							<div class="title_status" :style="{ backgroundColor: v.title1_bgcolor }"></div> {{ v.title1 }} {{ v.num1 }}
+						</div>
+						<div class="flex ml20 font14">
+							<div class="title_status" :style="{ backgroundColor: v.title2_bgcolor }"></div>{{ v.title2 }} {{ v.num2 }}
+						</div>
 					</div>
 				</div>
 			</el-col>
@@ -301,7 +305,7 @@ export default defineComponent({
 			for (var i = 0; i < getname.length; i++) {
 				data.push({ name: getname[i], value: getvalue[i] });
 			}
-			const colorList = ['#51A3FC', '#36C78B', '#FEC279', '#968AF5', '#FF0000'];
+			const colorList = ['#FF0000', '#FEC279', '#968AF5', '#51A3FC', '#36C78B',];
 			const option = {
 				backgroundColor: state.charts.bgColor,
 				title: {
@@ -399,7 +403,7 @@ export default defineComponent({
 				state.homeOne[0].num1 = `${overview.productActivation}`;
 				state.homeOne[0].num2 = `${overview.productDeactivation}`;
 				state.homeOne[1].allnum = overview.deviceTotal;
-				state.homeOne[1].num1 = `${overview.deviceTotal-overview.deviceOffline}`;
+				state.homeOne[1].num1 = `${overview.deviceTotal - overview.deviceOffline}`;
 				state.homeOne[1].num2 = `${overview.deviceOffline}`;
 				state.homeOne[2].allnum = overview.msgTotal;
 				state.homeOne[2].num1 = overview.msgTotal;
@@ -513,17 +517,19 @@ $homeNavLengh: 8;
 	.home-card-one,
 	.home-card-two,
 	.home-card-three {
-		.icoimg{
+		.icoimg {
 			width: 50px;
 			height: 50px;
 		}
-		.title_status{
+
+		.title_status {
 			width: 7px;
 			height: 7px;
 			background: #c1bbbb;
 			border-radius: 50px;
 			margin-right: 5px;
 		}
+
 		.home-card-item,
 		.home-card-top {
 			width: 100%;
@@ -687,5 +693,4 @@ $homeNavLengh: 8;
 	.box-card.xx {
 		margin-top: 20px;
 	}
-}
-</style>
+}</style>

+ 3 - 3
src/views/system/monitor/plugin/index.vue

@@ -47,13 +47,13 @@
 				</el-table-column>
 				<el-table-column label="操作" width="180" align="center" fixed="right" v-col="'handle'">
 					<template #default="scope">
-						<el-button :disabled="scope.row.status == 0" type="warning" size="small" link @click="changeStatus(scope.row, 0)" v-auth="'stop'"
+						<el-button v-if="scope.row.status == 1" type="warning" size="small" link @click="changeStatus(scope.row, 0)" v-auth="'stop'"
 							>停用</el-button
 						>
-						<el-button :disabled="scope.row.status == 1" size="small" type="success" link @click="changeStatus(scope.row, 1)" v-auth="'start'"
+						<el-button v-if="scope.row.status == 0" size="small" type="success" link @click="changeStatus(scope.row, 1)" v-auth="'start'"
 							>启用</el-button
 						>
-						<el-button :disabled="scope.row.status == 1" size="small" type="info" link @click="onDel(scope.row)" v-auth="'del'">删除</el-button>
+						<el-button v-if="scope.row.status == 0" size="small" type="info" link @click="onDel(scope.row)" v-auth="'del'">删除</el-button>
 						<el-button size="small" type="plain" link @click="addOrEdit(scope.row)">编辑</el-button>
 					</template>
 				</el-table-column>

+ 11 - 1
vite.config.ts

@@ -1,4 +1,5 @@
 import vue from '@vitejs/plugin-vue';
+import viteCompression from 'vite-plugin-compression'
 import { resolve } from 'path';
 import { defineConfig, loadEnv, ConfigEnv } from 'vite';
 
@@ -14,7 +15,16 @@ const alias: Record<string, string> = {
 const viteConfig = defineConfig((mode: ConfigEnv) => {
 	const env = loadEnv(mode.mode, process.cwd());
 	return {
-		plugins: [vue()],
+		plugins: [
+			vue(),
+			viteCompression({
+				threshold: 1024 * 20, // 对大于 20k 的文件进行压缩
+	      // filter: /\.(js|css|json|txt|html|ico|svg)(\?.*)?$/i, // 需要压缩的文件
+				algorithm: 'gzip', // 压缩方式
+				ext: 'gz', // 后缀名
+				deleteOriginFile: false, // 压缩后是否删除压缩源文件
+			})
+		],
 		root: process.cwd(),
 		resolve: { alias },
 		base: mode.command === 'serve' ? './' : env.VITE_PUBLIC_PATH,

+ 43 - 6
yarn.lock

@@ -996,7 +996,7 @@ chalk@^1.1.1:
     strip-ansi "^3.0.0"
     supports-color "^2.0.0"
 
-chalk@^4.0.0:
+chalk@^4.0.0, chalk@^4.1.2:
   version "4.1.2"
   resolved "https://registry.npmmirror.com/chalk/-/chalk-4.1.2.tgz"
   integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==
@@ -1173,7 +1173,7 @@ dayjs@1.x, dayjs@^1.11.3, dayjs@^1.11.8:
   resolved "https://registry.npmjs.org/dayjs/-/dayjs-1.11.8.tgz"
   integrity sha512-LcgxzFoWMEPO7ggRv1Y2N31hUf2R0Vj7fuy/m+Bg1K8rr+KAs1AEy4y9jd5DXe8pbHgX+srkHNS7TH6Q6ZhYeQ==
 
-debug@^4.1.1, debug@^4.3.2, debug@^4.3.4:
+debug@^4.1.1, debug@^4.3.2, debug@^4.3.3, debug@^4.3.4:
   version "4.3.4"
   resolved "https://registry.npmmirror.com/debug/-/debug-4.3.4.tgz"
   integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==
@@ -1749,6 +1749,15 @@ frac@~1.1.2:
   resolved "https://registry.npmmirror.com/frac/-/frac-1.1.2.tgz"
   integrity sha512-w/XBfkibaTl3YDqASwfDUqkna4Z2p9cFSr1aHDt0WoMTECnRfBOv2WArlZILlqgWlmdIlALXGpM2AOhEk5W3IA==
 
+fs-extra@^10.0.0:
+  version "10.1.0"
+  resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-10.1.0.tgz#02873cfbc4084dde127eaa5f9905eef2325d1abf"
+  integrity sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==
+  dependencies:
+    graceful-fs "^4.2.0"
+    jsonfile "^6.0.1"
+    universalify "^2.0.0"
+
 fs.realpath@^1.0.0:
   version "1.0.0"
   resolved "https://registry.npmmirror.com/fs.realpath/-/fs.realpath-1.0.0.tgz"
@@ -1858,6 +1867,11 @@ good-listener@^1.2.2:
   dependencies:
     delegate "^3.1.2"
 
+graceful-fs@^4.1.6, graceful-fs@^4.2.0:
+  version "4.2.11"
+  resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.11.tgz#4183e4e8bf08bb6e05bbb2f7d2e0c8f712ca40e3"
+  integrity sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==
+
 grapheme-splitter@^1.0.4:
   version "1.0.4"
   resolved "https://registry.npmmirror.com/grapheme-splitter/-/grapheme-splitter-1.0.4.tgz"
@@ -2099,6 +2113,15 @@ json2module@^0.0.3:
   dependencies:
     rw "^1.3.2"
 
+jsonfile@^6.0.1:
+  version "6.1.0"
+  resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-6.1.0.tgz#bc55b2634793c679ec6403094eb13698a6ec0aae"
+  integrity sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==
+  dependencies:
+    universalify "^2.0.0"
+  optionalDependencies:
+    graceful-fs "^4.1.6"
+
 jsplumb@^2.15.6:
   version "2.15.6"
   resolved "https://registry.npmmirror.com/jsplumb/-/jsplumb-2.15.6.tgz"
@@ -2831,6 +2854,11 @@ unbox-primitive@^1.0.2:
     has-symbols "^1.0.3"
     which-boxed-primitive "^1.0.2"
 
+universalify@^2.0.0:
+  version "2.0.1"
+  resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.1.tgz#168efc2180964e6386d061e094df61afe239b18d"
+  integrity sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==
+
 uri-js@^4.2.2:
   version "4.4.1"
   resolved "https://registry.npmmirror.com/uri-js/-/uri-js-4.4.1.tgz"
@@ -2858,10 +2886,19 @@ vform3-builds@^3.0.8:
   resolved "https://registry.npmjs.org/vform3-builds/-/vform3-builds-3.0.8.tgz"
   integrity sha512-ipfwAlFcZ87/asYmeYBqAtwXlq7pB4WRpwGsF2dW310GUmy8RrIm5sRklntTi4m6xuZCXwhkOFXkHokTOCkCpg==
 
-vite@^2.8.6:
-  version "2.9.15"
-  resolved "https://registry.npmmirror.com/vite/-/vite-2.9.15.tgz"
-  integrity sha512-fzMt2jK4vQ3yK56te3Kqpkaeq9DkcZfBbzHwYpobasvgYmP2SoAr6Aic05CsB4CzCZbsDv4sujX3pkEGhLabVQ==
+vite-plugin-compression@^0.5.1:
+  version "0.5.1"
+  resolved "https://registry.yarnpkg.com/vite-plugin-compression/-/vite-plugin-compression-0.5.1.tgz#a75b0d8f48357ebb377b65016da9f20885ef39b6"
+  integrity sha512-5QJKBDc+gNYVqL/skgFAP81Yuzo9R+EAf19d+EtsMF/i8kFUpNi3J/H01QD3Oo8zBQn+NzoCIFkpPLynoOzaJg==
+  dependencies:
+    chalk "^4.1.2"
+    debug "^4.3.3"
+    fs-extra "^10.0.0"
+
+vite@^2.9.16:
+  version "2.9.16"
+  resolved "https://registry.yarnpkg.com/vite/-/vite-2.9.16.tgz#daf7ba50f5cc37a7bf51b118ba06bc36e97898e9"
+  integrity sha512-X+6q8KPyeuBvTQV8AVSnKDvXoBMnTx8zxh54sOwmmuOdxkjMmEJXH2UEchA+vTMps1xw9vL64uwJOWryULg7nA==
   dependencies:
     esbuild "^0.14.27"
     postcss "^8.4.13"