cmy 2 vuotta sitten
vanhempi
commit
c11291bdda
4 muutettua tiedostoa jossa 252 lisäystä ja 227 poistoa
  1. 81 63
      public/index.html
  2. 2 1
      src/components/copyright/index.vue
  3. 69 62
      src/router/index.js
  4. 100 101
      src/setting.js

+ 81 - 63
public/index.html

@@ -1,70 +1,88 @@
 <!DOCTYPE html>
 <html>
 
-<head>
-    <meta charset="utf-8">
-    <meta http-equiv="X-UA-Compatible" content="IE=edge">
-    <meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no">
-    <link rel="shortcut icon" href="<%= BASE_URL %>favicon.ico">
-    <title>
-        <%= VUE_APP_TITLE %>
-    </title>
-</head>
+	<head>
+		<meta charset="utf-8">
+		<meta http-equiv="X-UA-Compatible" content="IE=edge">
+		<meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no">
+		<link rel="shortcut icon" href="<%= BASE_URL %>favicon.ico">
+		<title>
+			<%= VUE_APP_TITLE %>
+		</title>
+	</head>
 
-<body>
-    <noscript>
-        <strong>
-            请开启 JavaScript 功能来使用 <%= VUE_APP_TITLE %>
-        </strong>
-    </noscript>
-    <iframe id='IEIframe' style='display: none;' width="100%" height="100%" src="/static/ie.html"
-        frameborder="0"></iframe>
-    <div id="app">
+	<body>
+		<noscript>
+			<strong>
+				请开启 JavaScript 功能来使用 <%= VUE_APP_TITLE %>
+			</strong>
+		</noscript>
+		<iframe id='IEIframe' style='display: none;' width="100%" height="100%" src="/static/ie.html"
+			frameborder="0"></iframe>
+		<div id="app">
 
-    </div>
-</body>
-<script>
-    function IEVersion() {
-        var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
-        var isIE =
-            userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1; //判断是否IE<11浏览器
-        if (isIE) {
-            return true;
-        } else {
-            return false; //不是ie浏览器
-        }
-    }
-    /* 如果是ie浏览器 */
-    if (IEVersion()) {
-        document.querySelector('#IEIframe').style.display = 'block'
-        document.querySelector('#app').style.display = 'none'
+		</div>
+	</body>
+	<script>
+		var $tar = document.querySelector('title')
 
-    }
-    // dataset 方法兼容 IE 浏览器。ie10及以下不支持dataset
-    if (window.HTMLElement) {
-        if (Object.getOwnPropertyNames(HTMLElement.prototype).indexOf('dataset') === -1) {
-            Object.defineProperty(HTMLElement.prototype, 'dataset', {
-                get: function () {
-                    var attributes = this.attributes // 获取节点的所有属性
-                    var name = []
-                    var value = [] // 定义两个数组保存属性名和属性值
-                    var obj = {} // 定义一个空对象
-                    for (var i = 0; i < attributes.length; i++) { // 遍历节点的所有属性
-                        if (attributes[i].nodeName.slice(0, 5) === 'data-') { // 如果属性名的前面5个字符符合"data-"
-                            // 取出属性名的"data-"的后面的字符串放入name数组中
-                            name.push(attributes[i].nodeName.slice(5));
-                            // 取出对应的属性值放入value数组中
-                            value.push(attributes[i].nodeValue);
-                        }
-                    }
-                    for (var j = 0; j < name.length; j++) { // 遍历namevalue数组
-                        obj[name[j]] = value[j]; // 将属性名和属性值保存到obj中
-                    }
-                    return obj // 返回对象
-                }
-            })
-        }
-    }
-</script>
+		var MutationObserver =	window.MutationObserver ||window.webkitMutationObserver ||window.MozMutationObserver;
 
-</html>
+		var mutationObserver = new MutationObserver((mutations) => {
+			console.log(mutations,'标题变动')
+		})
+
+		mutationObserver.observe($tar, {
+			childList: true, // 子节点的变动(新增、删除或者更改)
+			attributes: true, // 属性的变动
+			characterData: true, // 节点内容或节点文本的变动
+			subtree: true, // 是否将观察器应用于该节点的所有后代节点
+			attributeFilter: ['class', 'style'], // 观察特定属性
+			attributeOldValue: true, // 观察 attributes 变动时,是否需要记录变动前的属性值
+			characterDataOldValue: true // 观察 characterData 变动,是否需要记录变动前的值
+		})
+
+		function IEVersion() {
+			var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
+			var isIE =
+				userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1; //判断是否IE<11浏览器
+			if (isIE) {
+				return true;
+			} else {
+				return false; //不是ie浏览器
+			}
+		}
+		/* 如果是ie浏览器 */
+		if (IEVersion()) {
+			document.querySelector('#IEIframe').style.display = 'block'
+			document.querySelector('#app').style.display = 'none'
+
+		}
+		// dataset 方法兼容 IE 浏览器。ie10及以下不支持dataset
+		if (window.HTMLElement) {
+			if (Object.getOwnPropertyNames(HTMLElement.prototype).indexOf('dataset') === -1) {
+				Object.defineProperty(HTMLElement.prototype, 'dataset', {
+					get: function() {
+						var attributes = this.attributes // 获取节点的所有属性
+						var name = []
+						var value = [] // 定义两个数组保存属性名和属性值
+						var obj = {} // 定义一个空对象
+						for (var i = 0; i < attributes.length; i++) { // 遍历节点的所有属性
+							if (attributes[i].nodeName.slice(0, 5) === 'data-') { // 如果属性名的前面5个字符符合"data-"
+								// 取出属性名的"data-"的后面的字符串放入name数组中
+								name.push(attributes[i].nodeName.slice(5));
+								// 取出对应的属性值放入value数组中
+								value.push(attributes[i].nodeValue);
+							}
+						}
+						for (var j = 0; j < name.length; j++) { // 遍历namevalue数组
+							obj[name[j]] = value[j]; // 将属性名和属性值保存到obj中
+						}
+						return obj // 返回对象
+					}
+				})
+			}
+		}
+	</script>
+
+</html>

+ 2 - 1
src/components/copyright/index.vue

@@ -36,7 +36,8 @@
         methods: {
             getCopyright () {
                 copyright().then(res=>{
-                    this.copyright += res.data.copyrightContext?res.data.copyrightContext:'Copyright © 2022 西安众邦网络科技有限公司';
+                    // this.copyright += res.data.copyrightContext?res.data.copyrightContext:'Copyright © 2022 浙江六牛科技有限公司';
+                    this.copyright += 'Copyright © 2022 浙江六牛科技有限公司';
                     this.getVersion();
                 }).catch(err=>{
                     this.$Message.error(err.msg)

+ 69 - 62
src/router/index.js

@@ -20,7 +20,9 @@ import store from "@/store/index";
 // 路由数据
 import routes from "./routes";
 
-import { includeArray } from "@/libs/system";
+import {
+	includeArray
+} from "@/libs/system";
 
 Vue.use(VueRouter);
 
@@ -29,13 +31,13 @@ Vue.use(VueRouter);
  */
 const routerPush = VueRouter.prototype.push;
 VueRouter.prototype.push = function push(location) {
-  return routerPush.call(this, location).catch((error) => error);
+	return routerPush.call(this, location).catch((error) => error);
 };
 
 // 导出路由 在 main.js 里使用
 const router = new VueRouter({
-  routes,
-  mode: Setting.routerMode,
+	routes,
+	mode: Setting.routerMode,
 });
 /**
  * 路由拦截
@@ -43,67 +45,72 @@ const router = new VueRouter({
  */
 
 router.beforeEach(async (to, from, next) => {
-  if (to.fullPath.indexOf("kefu") != -1) {
-    return next();
-  }
-  // if (Setting.showProgressBar) iView.LoadingBar.start();
-  // // 判断是否需要登录才可以进入
-  if (to.matched.some((_) => _.meta.auth)) {
-    // 这里依据 token 判断是否登录,可视情况修改
-    const db = await store.dispatch("store/db/database", {
-      user: true,
-    });
-    const token = util.cookies.get("token");
-    if (token && token !== "undefined") {
-      const access = db.get("unique_auth").value();
-      let accessAuth = "";
-      if (access == undefined) {
-        let storage = window.localStorage;
-        let value = storage.getItem("uniqueAuthStore");
-        accessAuth = JSON.parse(value);
-      } else {
-        accessAuth = db.get("unique_auth").value();
-      }
-      const isPermission = includeArray(to.meta.auth, accessAuth);
-      if (isPermission) {
-        next();
-      } else {
-        next({
-          name: "403",
-        });
-      }
-      // next();
-    } else {
-      store.dispatch("store/db/databaseClear", {
-        user: true,
-      });
-      // 没有登录的时候跳转到登录界面
-      // 携带上登陆成功之后需要跳转的页面完整路径
-      next({
-        name: "login",
-        query: {
-          redirect: to.fullPath,
-        },
-      });
-    }
-  } else {
-    // 不需要身份校验 直接通过
-    next();
-  }
-  // next();
+	if (to.fullPath.indexOf("kefu") != -1) {
+		return next();
+	}
+	// if (Setting.showProgressBar) iView.LoadingBar.start();
+	// // 判断是否需要登录才可以进入
+	if (to.matched.some((_) => _.meta.auth)) {
+		// 这里依据 token 判断是否登录,可视情况修改
+		const db = await store.dispatch("store/db/database", {
+			user: true,
+		});
+		const token = util.cookies.get("token");
+		if (token && token !== "undefined") {
+			const access = db.get("unique_auth").value();
+			let accessAuth = "";
+			if (access == undefined) {
+				let storage = window.localStorage;
+				let value = storage.getItem("uniqueAuthStore");
+				accessAuth = JSON.parse(value);
+			} else {
+				accessAuth = db.get("unique_auth").value();
+			}
+			const isPermission = includeArray(to.meta.auth, accessAuth);
+			if (isPermission) {
+				next();
+			} else {
+				next({
+					name: "403",
+				});
+			}
+			// next();
+		} else {
+			store.dispatch("store/db/databaseClear", {
+				user: true,
+			});
+			// 没有登录的时候跳转到登录界面
+			// 携带上登陆成功之后需要跳转的页面完整路径
+			next({
+				name: "login",
+				query: {
+					redirect: to.fullPath,
+				},
+			});
+		}
+	} else {
+		// 不需要身份校验 直接通过
+		next();
+	}
+	// next();
 });
 
 router.afterEach((to) => {
-  // if (Setting.showProgressBar) iView.LoadingBar.finish();
-  // 多页控制 打开新的页面
-  store.dispatch("store/page/open", to);
-
-  // 更改标题
-  util.title({
-    title: to.meta.title,
-  });
-  // 返回页面顶端
-  window.scrollTo(0, 0);
+	// if (Setting.showProgressBar) iView.LoadingBar.finish();
+	// 多页控制 打开新的页面
+	const ss = window.document.title;
+console.log(ss)
+	store.dispatch("store/page/open", to);
+	console.log('标题', to, to.meta.title)
+	// 更改标题
+	util.title({
+		title: to.meta.title,
+	});
+	let a = window.$t(to.meta.title.split('$t:')[1])
+	const aa = window.document.title;
+	console.log(window.$t)
+	// 返回页面顶端
+	window.scrollTo(0, 0);
 });
 
 export default router;

+ 100 - 101
src/setting.js

@@ -19,107 +19,106 @@ const VUE_APP_WS_ADMIN_URL = process.env.VUE_APP_WS_ADMIN_URL || `ws:${location.
 import util from '@/libs/util';
 
 const Setting = {
-    /**
-     * 基础配置
-     * */
-    // 网页标题的后缀
-    titleSuffix: util.cookies.get('pageTitle') || 'CRMEB',
-		// 后台配置目录
-		
-    // 路由模式,可选值为 history 或 hash
-    routerMode: 'history',
-    // 页面切换时,是否显示模拟的进度条
-    showProgressBar: false,
-    // 接口请求地址
-    apiBaseURL: VUE_APP_API_URL,
-    // adminsocket连接
-    wsAdminSocketUrl: VUE_APP_WS_ADMIN_URL,
-    modalDuration: 3,
-    // 接口请求返回错误时,弹窗的类型,可选值为 Message 或 Notice
-    errorModalType: 'Message',
-    // Cookies 默认保存时间,单位:天
-    cookiesExpires: 1,
-    /**
-     * 多语言配置
-     * */
-    i18n: {
-        // 默认语言
-        default: 'zh-CN',
-        // 是否根据用户电脑配置自动设置语言(仅第一次有效)
-        auto: false
-    },
-    /**
-     * 布局配置
-     * */
-    // 侧边菜单宽度,单位 px,不可动态修改,需与 setting.less 的 @menuSideWidth 保持一致
-    menuSideWidth: 200,
-    layout: {
-        // 侧边栏风格,可选值为 dark 或 light
-        siderTheme: 'light',
-        // 顶栏风格,可选值为 light、dark 或 primary
-        headerTheme: 'light',
-        // 顶栏是否置顶,开启后会覆盖侧边栏,需开启 headerFix
-        headerStick: true,
-        // 是否开启多 Tabs 页签
-        tabs: false,
-        // 多 Tabs 页签是否显示图标,开启 tabs 时有效
-        showTabsIcon: true,
-        // 是否固定多 Tabs 多页签
-        tabsFix: true,
-        // 是否固定侧边栏
-        siderFix: true,
-        // 是否固定顶栏
-        headerFix: true,
-        // 是否在下滑时隐藏顶栏,需开启 headerFix,如果开启了 tabsFix,Tabs 也会被隐藏
-        headerHide: false,
-        // 是否显示顶部菜单栏
-        // 一般来说,侧边的菜单栏足以满足大部分业务,如需动态切换侧边栏,可开启此选项启用顶部一级菜单,此时侧边栏将作为二级菜单
-        headerMenu: false,
-        // 侧边菜单栏是否开启手风琴模式
-        menuAccordion: true,
-        // 是否显示折叠侧边栏按钮,移动端下会自动强制开启
-        showSiderCollapse: true,
-        // 侧边菜单栏是否默认折起
-        menuCollapse: false,
-        // 侧边菜单折起时,是否在子菜单前显示父级菜单名称
-        showCollapseMenuTitle: false,
-        // 是否显示重载按钮
-        showReload: true,
-        // 是否显示搜索
-        showSearch: true,
-        // 是否显示通知
-        showNotice: true,
-        // 是否显示全屏
-        showFullscreen: true,
-        // 在手机访问时,是否在顶部显示小尺寸 logo
-        showMobileLogo: true,
-        // 是否显示全局面包屑,开启 headerMenu 时不可用
-        showBreadcrumb: true,
-        // 全局面包屑是否显示图标,开启 showBreadcrumb 时有效
-        showBreadcrumbIcon: true,
-        // 是否显示日志入口,开启与否,不影响日志记录,如不希望用户看到可关闭
-        showLog: true,
-        // 是否显示多语言
-        showI18n: false,
-        // 是否支持动态修改布局配置,移动端下会自动强制关闭
-        enableSetting: true,
-        // 退出登录时,是否二次确认
-        logoutConfirm: true
-    },
-    /**
-     * 多页 Tabs
-     * */
-    page: {
-        // 默认打开的页签
-        opened: ['store/home']
-    },
-    /**
-     * 功能配置
-     * */
-    // 相同路由,不同参数间进行切换,是否强力更新
-    sameRouteForceUpdate: false,
-    // 是否使用动态侧边菜单
-    dynamicSiderMenu: true
+	/**
+	 * 基础配置
+	 * */
+	// 网页标题的后缀
+	titleSuffix: util.cookies.get('pageTitle') || '六牛科技',
+	// 后台配置目录
+	// 路由模式,可选值为 history 或 hash
+	routerMode: 'history',
+	// 页面切换时,是否显示模拟的进度条
+	showProgressBar: false,
+	// 接口请求地址
+	apiBaseURL: VUE_APP_API_URL,
+	// adminsocket连接
+	wsAdminSocketUrl: VUE_APP_WS_ADMIN_URL,
+	modalDuration: 3,
+	// 接口请求返回错误时,弹窗的类型,可选值为 Message 或 Notice
+	errorModalType: 'Message',
+	// Cookies 默认保存时间,单位:天
+	cookiesExpires: 1,
+	/**
+	 * 多语言配置
+	 * */
+	i18n: {
+		// 默认语言
+		default: 'zh-CN',
+		// 是否根据用户电脑配置自动设置语言(仅第一次有效)
+		auto: false
+	},
+	/**
+	 * 布局配置
+	 * */
+	// 侧边菜单宽度,单位 px,不可动态修改,需与 setting.less 的 @menuSideWidth 保持一致
+	menuSideWidth: 200,
+	layout: {
+		// 侧边栏风格,可选值为 dark 或 light
+		siderTheme: 'light',
+		// 顶栏风格,可选值为 light、dark 或 primary
+		headerTheme: 'light',
+		// 顶栏是否置顶,开启后会覆盖侧边栏,需开启 headerFix
+		headerStick: true,
+		// 是否开启多 Tabs 页签
+		tabs: false,
+		// 多 Tabs 页签是否显示图标,开启 tabs 时有效
+		showTabsIcon: true,
+		// 是否固定多 Tabs 多页签
+		tabsFix: true,
+		// 是否固定侧边栏
+		siderFix: true,
+		// 是否固定顶栏
+		headerFix: true,
+		// 是否在下滑时隐藏顶栏,需开启 headerFix,如果开启了 tabsFix,Tabs 也会被隐藏
+		headerHide: false,
+		// 是否显示顶部菜单栏
+		// 一般来说,侧边的菜单栏足以满足大部分业务,如需动态切换侧边栏,可开启此选项启用顶部一级菜单,此时侧边栏将作为二级菜单
+		headerMenu: false,
+		// 侧边菜单栏是否开启手风琴模式
+		menuAccordion: true,
+		// 是否显示折叠侧边栏按钮,移动端下会自动强制开启
+		showSiderCollapse: true,
+		// 侧边菜单栏是否默认折起
+		menuCollapse: false,
+		// 侧边菜单折起时,是否在子菜单前显示父级菜单名称
+		showCollapseMenuTitle: false,
+		// 是否显示重载按钮
+		showReload: true,
+		// 是否显示搜索
+		showSearch: true,
+		// 是否显示通知
+		showNotice: true,
+		// 是否显示全屏
+		showFullscreen: true,
+		// 在手机访问时,是否在顶部显示小尺寸 logo
+		showMobileLogo: true,
+		// 是否显示全局面包屑,开启 headerMenu 时不可用
+		showBreadcrumb: true,
+		// 全局面包屑是否显示图标,开启 showBreadcrumb 时有效
+		showBreadcrumbIcon: true,
+		// 是否显示日志入口,开启与否,不影响日志记录,如不希望用户看到可关闭
+		showLog: true,
+		// 是否显示多语言
+		showI18n: false,
+		// 是否支持动态修改布局配置,移动端下会自动强制关闭
+		enableSetting: true,
+		// 退出登录时,是否二次确认
+		logoutConfirm: true
+	},
+	/**
+	 * 多页 Tabs
+	 * */
+	page: {
+		// 默认打开的页签
+		opened: ['store/home']
+	},
+	/**
+	 * 功能配置
+	 * */
+	// 相同路由,不同参数间进行切换,是否强力更新
+	sameRouteForceUpdate: false,
+	// 是否使用动态侧边菜单
+	dynamicSiderMenu: true
 };
 
 export default Setting;