Просмотр исходного кода

👍!1017 前端优化
Merge pull request !1017 from Hans/RefreshNotification

zuohuaijun 2 лет назад
Родитель
Сommit
b0a4a89f91

+ 2 - 0
Web/package.json

@@ -36,6 +36,7 @@
 		"nprogress": "^0.2.0",
 		"pinia": "^2.1.7",
 		"print-js": "^1.6.0",
+		"push.js": "^1.0.12",
 		"qrcodejs2-fixes": "^0.0.2",
 		"qs": "^6.12.0",
 		"relation-graph": "^2.1.38",
@@ -58,6 +59,7 @@
 		"xlsx-js-style": "^1.2.0"
 	},
 	"devDependencies": {
+		"@plugin-web-update-notification/vite": "^1.7.1",
 		"@types/lodash-es": "^4.17.12",
 		"@types/node": "^20.12.2",
 		"@types/nprogress": "^0.2.3",

+ 20 - 2
Web/src/layout/navBars/topBar/user.vue

@@ -99,7 +99,7 @@ import { Local } from '/@/utils/storage';
 
 import { clearAccessTokens, getAPI } from '/@/utils/axios-utils';
 import { SysAuthApi, SysNoticeApi } from '/@/api-services/api';
-
+import Push from 'push.js';
 import { signalR } from '/@/views/system/onlineUser/signalR';
 
 // 引入组件
@@ -221,7 +221,19 @@ onMounted(async () => {
 		initI18nOrSize('globalComponentSize', 'disabledSize');
 		initI18nOrSize('globalI18n', 'disabledI18n');
 	}
-
+	// 手动获取用户桌面通知权限
+	if (Push.Permission.GRANTED) {
+		// 判断当前是否有权限,没有则手动获取
+		Push.Permission.request();
+	}
+	// 监听浏览器 当前系统是否在当前页
+	document.addEventListener('visibilitychange', () => {
+		if (!document.hidden) {
+			// 处于当前页面
+			// 关闭之前的消息通知,清空
+			Push.clear();
+		}
+	});
 	// 加载未读的站内信
 	var res = await getAPI(SysNoticeApi).apiSysNoticeUnReadListGet();
 	state.noticeList = res.data.result ?? [];
@@ -252,6 +264,12 @@ const receiveNotice = (msg: any) => {
 		type: 'info',
 		position: 'bottom-right',
 	});
+	Push.create('提示', {
+		body: '你有一条新的消息',
+		icon: 'logo.png', //public目录下的
+		timeout: 4500, // 通知显示时间,单位为毫秒
+
+	});
 };
 </script>
 

+ 9 - 0
Web/src/views/system/print/component/hiprint/index.vue

@@ -200,6 +200,15 @@ const changeMode = () => {
 		template: template,
 		settingContainer: '#PrintElementOptionSetting',
 		paginationContainer: '.hiprint-printPagination',
+		fontList: [
+			{ title: '微软雅黑', value: 'Microsoft YaHei' },
+			{ title: '黑体', value: 'STHeitiSC-Light' },
+			{ title: 'Arial', value: 'Arial' },
+			{ title: '宋体', value: 'SimSun' },
+			{ title: '华为楷体', value: 'STKaiti' },
+			{ title: 'cursive', value: 'cursive' },
+			{ title: 'Vector', value: 'Vector' },
+		],
 	});
 	hiprintTemplate.value.design('#hiprint-printTemplate');
 	// 获取当前放大比例, 当zoom时传true才会有

+ 7 - 0
Web/src/views/system/print/component/hiprint/providers.ts

@@ -354,6 +354,13 @@ export const bProvider = function () {
 					columnTitleEditable: true, //列标题是否能编辑
 					columnResizable: true, //列宽是否能调整
 					columnAlignEditable: true, //列对齐是否调整
+					isEnableEditField: true, //编辑字段
+					isEnableContextMenu: true, //开启右键菜单 默认true
+					isEnableInsertRow: true, //插入行
+					isEnableDeleteRow: true, //删除行
+					isEnableInsertColumn: true, //插入列
+					isEnableDeleteColumn: true, //删除列
+					isEnableMergeCell: true, //合并单元格
 					columns: [
 						[
 							{ title: '名称', align: 'center', field: 'NAME', width: 100 },

+ 12 - 1
Web/vite.config.ts

@@ -8,7 +8,7 @@ import vueJsx from '@vitejs/plugin-vue-jsx';
 import { CodeInspectorPlugin } from 'code-inspector-plugin';
 import fs from 'fs';
 import { visualizer } from 'rollup-plugin-visualizer';
-
+import { webUpdateNotice } from '@plugin-web-update-notification/vite';
 const pathResolve = (dir: string) => {
 	return resolve(__dirname, '.', dir);
 };
@@ -30,6 +30,17 @@ const viteConfig = defineConfig((mode: ConfigEnv) => {
 			}),
 			vue(),
 			vueJsx(),
+			webUpdateNotice({
+				notificationConfig: {
+					placement: 'topLeft',
+				},
+				notificationProps: {
+					title: '📢 系统更新',
+					description: '系统更新啦!请刷新页面',
+					buttonText: '刷新',
+					dismissButtonText: '忽略',
+				},
+			}),
 			vueSetupExtend(),
 			viteCompression({
 				verbose: true, // 是否在控制台中输出压缩结果

+ 4 - 0
docker/nginx/conf/nginx.conf

@@ -32,6 +32,10 @@ http {
             root   /usr/share/nginx/html;
             try_files $uri $uri/ /index.html;
             index  index.html index.htm;
+            # 如果缓存了 index.html ,刷新后可能仍会出现更新通知,因此需要禁用 index.html 的缓存。这也是部署 SPA 应用程序的最佳做法。
+			if ( $uri = '/index.html' ) { # disabled index.html cache
+			    add_header Cache-Control "no-cache, no-store, must-revalidate";
+			}
         }