123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- import {
- computed,
- defineComponent,
- onMounted,
- ref,
- onBeforeUnmount
- } from 'vue';
- import { NConfigProvider, zhCN, dateZhCN, NModal } from 'naive-ui';
- import { AppProvider } from './components/Application';
- import { RouterView } from 'vue-router';
- import setting from './settings/designSetting';
- import { lighten } from './utils';
- import RouterError from './components/RouterError';
- import { tryOnUnmounted } from '@vueuse/core';
- export default defineComponent({
- name: 'App',
- setup() {
- const isIOSChrome = ref();
- const getThemeOverrides = computed(() => {
- const appTheme = setting.appTheme;
- const lightenStr = lighten(setting.appTheme, 6);
- return {
- common: {
- primaryColor: appTheme,
- primaryColorHover: lightenStr,
- primaryColorPressed: lightenStr
- },
- LoadingBar: {
- colorLoading: appTheme
- }
- };
- });
- // const showModal = ref(false);
- const showModalMsg = ref('');
- // 判断浏览器
- // 是否是360
- const check360 = () => {
- const result = false;
- for (const key in navigator.plugins) {
- // np-mswmp.dll只在360浏览器下存在
- if (navigator.plugins[key].filename == 'internal-nacl-plugin') {
- return !result;
- }
- }
- return result;
- };
- //
- const isChrome = () => {
- const isChromium = window.chrome,
- winNav = window.navigator,
- vendorName = winNav.vendor,
- isOpera = winNav.userAgent.indexOf('OPR') > -1,
- isIEedge = winNav.userAgent.indexOf('Edge') > -1,
- isIOSChrome = winNav.userAgent.match('CriOS'),
- // QQ
- isQQBriwser =
- winNav.userAgent.indexOf('QQBrowser') > -1 ||
- winNav.userAgent.indexOf('QQ') > -1,
- // 搜狗
- isSouggou =
- winNav.userAgent.indexOf('se 2.x') > -1 ||
- winNav.userAgent.indexOf('MetaSr') > -1,
- // 360
- is360 = check360() && winNav.userAgent.indexOf('Safari') > -1,
- // 遨游
- isMaxthon = winNav.userAgent.indexOf('Maxthon') > -1,
- // 是否为2345浏览器
- is2345Explorer = winNav.userAgent.includes('2345Explorer'),
- // 世界之窗
- isTheWorld = winNav.userAgent.indexOf('TheWorld') > -1,
- // 猎豹
- isLiebao = winNav.userAgent.indexOf('LBBROWSER') > -1;
- console.log(isQQBriwser, isSouggou, is360, isMaxthon, is2345Explorer, isTheWorld, isLiebao)
- if (isIOSChrome) {
- return true;
- } else if (
- isChromium !== null &&
- typeof isChromium !== 'undefined' &&
- vendorName === 'Google Inc.' &&
- isOpera === false &&
- isIEedge === false &&
- isQQBriwser === false &&
- isSouggou === false &&
- is360 === false &&
- isMaxthon === false &&
- is2345Explorer === false &&
- isTheWorld === false &&
- isLiebao === false
- ) {
- return true;
- } else {
- return false;
- }
- };
- // 获取谷歌版本
- const getChromeVersion = () => {
- const arr = navigator.userAgent.split(' ');
- let chromeVersion = '' as any;
- for (let i = 0; i < arr.length; i++) {
- if (/chrome/i.test(arr[i])) chromeVersion = arr[i];
- }
- if (chromeVersion) {
- return Number(chromeVersion.split('/')[1].split('.')[0]);
- } else {
- return false;
- }
- };
- const isChromeFlag = isChrome();
- console.log('isChromeFlag', isChromeFlag);
- if (isChromeFlag) {
- const chromeVersion = getChromeVersion();
- if (!chromeVersion || (chromeVersion && chromeVersion < 100)) {
- showModalMsg.value =
- '您当前的chrome版本过低,为了保证您的用户体验请升级后使用';
- // showModal.value = true;
- }
- // if (chromeVersion) {
- // return Number(chromeVersion.split('/')[1].split('.')[0]);
- // } else {
- // return false;
- // }
- } else {
- showModalMsg.value = '为了保证您的用户体验,请使用chrome打开,点击确定下载';
- // showModal.value = true;
- console.log('---');
- }
- const submitCallback = () => {
- window.open('https://www.google.cn/intl/zh-CN/chrome/');
- };
- return () => (
- <>
- <NConfigProvider
- locale={zhCN}
- themeOverrides={getThemeOverrides.value}
- // :theme="getDarkTheme"
- // :theme-overrides="getThemeOverrides"
- dateLocale={dateZhCN}>
- <AppProvider>
- <RouterView />
- <RouterError />
- </AppProvider>
- </NConfigProvider>
- {/* <NModal
- show={showModal.value}
- closeOnEsc={false}
- closable={false}
- maskClosable={false}
- preset="dialog"
- title="确认"
- content={showModalMsg.value}
- positive-text="确认"
- onPositiveClick={submitCallback}></NModal> */}
- </>
- );
- }
- });
|