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

投标-标签标题,加载页面

cyy 10 месяцев назад
Родитель
Сommit
6c47f48ef9
3 измененных файлов с 70 добавлено и 58 удалено
  1. 11 1
      public/index.html
  2. 4 3
      src/router/index.js
  3. 55 54
      src/utils/i18n.js

+ 11 - 1
public/index.html

@@ -77,7 +77,17 @@
      <!-- built files will be auto injected -->
     <script>
         const currentYear = new Date().getFullYear();
-        document.getElementById('copyright').textContent = '2020-' + currentYear + '©深圳市金源信通科技有限公司©版权所有'
+        
+        var url = window.location.href
+        let queryString = url ? url.split('?')[1] : window.location.search.slice(1)
+        let queryStringArr = url ? url.split('=') : []
+        if(queryStringArr.length>0&&queryStringArr[0]=='directionality'&&queryStringArr[1]=='sc'){
+          document.getElementById('copyright').textContent = '2020-' + currentYear + '©深圳市金源信通科技有限公司©版权所有'
+          document.title = VUE_APP_TITLE
+        }else{
+          document.getElementById('copyright').textContent = '2020-' + currentYear + '©四川沃文特生物技术有限公司©版权所有'
+          document.title = '实验室管理平台-四川沃文特生物技术有限公司'
+        }
     </script>
   </body>
 </html>

+ 4 - 3
src/router/index.js

@@ -95,7 +95,7 @@ router.beforeEach(async (to, from, next) => {
                                     })
                                     next({ ...to, replace: true }) // hack方法 确保addRoutes已完成
                                 } else {
-                                    next({ path: '/403', replace: true, query: { noGoBack: true } })
+                                    next({ path: '/403', replace: true, query: { noGoBack: true }})
                                 }
                             }
                         }).catch((e) => {
@@ -113,7 +113,7 @@ router.beforeEach(async (to, from, next) => {
                     })
                 } else { // 动态改变权限,判断是否有菜单权限,或者刷新页面
                     if (to.matched.length === 0) { // 不能匹配的路由
-                        return next({ path: '401', replace: true, query: { noGoBack: true } })
+                        return next({ path: '401', replace: true, query: { noGoBack: true }})
                     } else {
                         next()
                     }
@@ -156,7 +156,8 @@ router.afterEach(to => {
     // 多页控制 打开新的页面
     /* store.dispatch('ibps/page/open', to) */
     // 更改标题
-    i18n.setTitle(to.meta.name || to.name, to.meta.title)
+    // i18n.setTitle(to.meta.name || to.name, to.meta.title)
+    i18n.setTitle(to.meta.name || to.name, to.meta.title, !(to.query.directionality === 'sc'))
 })
 
 export default router

+ 55 - 54
src/utils/i18n.js

@@ -10,81 +10,82 @@
 import lang from '@/i18n' // Internationalization 国际化
 
 const i18n = {
-  /**
+    /**
    * 设置标题
    */
-  setTitle: (name, title) => {
-    title = i18n.generateTitle(name, title)
-    i18n.setBrowserTitle((title ? title + '-' : '') + i18n.t('common.platform') + '-' + i18n.t('common.company'))
-  },
+    setTitle: (name, title, judge) => {
+        title = i18n.generateTitle(name, title)
+        i18n.setBrowserTitle((title ? title + '-' : '') + i18n.t('common.platform') + '-' + (judge ? i18n.t('common.company') : '四川沃文特生物技术有限公司'))
+        // i18n.setBrowserTitle((title ? title + '-' : '') + i18n.t('common.platform') + '-' + i18n.t('common.company'))
+    },
 
-  /**
+    /**
    * 设置标题
    * 单页应用在iOS系统下部分APP的webview中 标题不能通过 document.title = xxx 的方式修改 该插件只为解决该问题而生(兼容安卓)
    * @param {*} title
    * @param {*} img
    */
-  setBrowserTitle: (title, img) => {
-    if (title === undefined || window.document.title === title) {
-      return
-    }
-    document.title = title
-    const userAgent = navigator.userAgent.toLowerCase()
-    if (/iphone|ipad|ipod/.test(userAgent)) {
-      const iframe = document.createElement('iframe')
-      iframe.style.display = 'none'
-      // 替换成站标favicon路径或者任意存在的较小的图片即可
-      iframe.setAttribute('src', img || '/favicon.ico')
-      const iframeCallback = function() {
-        setTimeout(function() {
-          iframe.removeEventListener('load', iframeCallback)
-          document.body.removeChild(iframe)
-        }, 0)
-      }
-      iframe.addEventListener('load', iframeCallback)
-      document.body.appendChild(iframe)
-    }
-  },
-  /**
+    setBrowserTitle: (title, img) => {
+        if (title === undefined || window.document.title === title) {
+            return
+        }
+        document.title = title
+        const userAgent = navigator.userAgent.toLowerCase()
+        if (/iphone|ipad|ipod/.test(userAgent)) {
+            const iframe = document.createElement('iframe')
+            iframe.style.display = 'none'
+            // 替换成站标favicon路径或者任意存在的较小的图片即可
+            iframe.setAttribute('src', img || '/favicon.ico')
+            const iframeCallback = function () {
+                setTimeout(function () {
+                    iframe.removeEventListener('load', iframeCallback)
+                    document.body.removeChild(iframe)
+                }, 0)
+            }
+            iframe.addEventListener('load', iframeCallback)
+            document.body.appendChild(iframe)
+        }
+    },
+    /**
  * 翻译router.meta.title,用于面包屑(breadcrumb)、侧边栏(sidebar)、tagsview
  * @param {*} path
  * @param {*} title
  */
-  generateTitle: (name, title, ...values) => {
-    if (!name && !title) return
-    const hasKey = lang.te('route.' + name)
-    if (hasKey) {
-      return lang.t('route.' + name, ...values) // $t :this method from vue-i18n, inject in @/lang/index.js
-    }
-    if (title) { return title }
-    name = name.substring(name.lastIndexOf('.') + 1, name.length)
-    return name
-  },
-  /**
+    generateTitle: (name, title, ...values) => {
+        if (!name && !title) return
+        const hasKey = lang.te('route.' + name)
+        if (hasKey) {
+            return lang.t('route.' + name, ...values) // $t :this method from vue-i18n, inject in @/lang/index.js
+        }
+        if (title) { return title }
+        name = name.substring(name.lastIndexOf('.') + 1, name.length)
+        return name
+    },
+    /**
  * 跟vue-i8n的 t  类似
  * 如果不存在则取最后一个 值
  * @param {*} path
  * @param {*} values
  */
-  t: (path, ...values) => {
-    const hasKey = lang.te(path)
-    if (hasKey) {
-      return lang.t(path, ...values)
-    }
-    path = path.substring(path.lastIndexOf('.') + 1, path.length)
-    return path
-  },
+    t: (path, ...values) => {
+        const hasKey = lang.te(path)
+        if (hasKey) {
+            return lang.t(path, ...values)
+        }
+        path = path.substring(path.lastIndexOf('.') + 1, path.length)
+        return path
+    },
 
-  /**
+    /**
  * 跟vue-i8n的 te 一致
  * @param {*} path
  */
-  te: (path) => {
-    return lang.te(path)
-  },
-  getLanguage: () => {
-    return lang.locale || 'zh-CN'
-  }
+    te: (path) => {
+        return lang.te(path)
+    },
+    getLanguage: () => {
+        return lang.locale || 'zh-CN'
+    }
 }
 
 export default i18n