├── .nvmrc ├── .gitignore ├── .npmrc ├── src ├── css │ ├── index.css │ ├── scrollbar.css │ ├── loading.css │ ├── theme_light.css │ └── theme_dark.css ├── index.js ├── index.html └── device.js ├── .github └── ISSUE_TEMPLATE │ ├── custom.md │ ├── feature_request.md │ └── bug_report.md ├── babel.config.json ├── LICENSE ├── package.json ├── rollup.config.js ├── README.md └── dist ├── device.es.js └── device.js /.nvmrc: -------------------------------------------------------------------------------- 1 | 18.20.8 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | .DS_Store 3 | node_modules 4 | package-lock.json 5 | yarn.lock 6 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | shell-emulator=true 2 | strict-peer-dependencies=false 3 | legacy-peer-deps=true 4 | engine-strict=false 5 | -------------------------------------------------------------------------------- /src/css/index.css: -------------------------------------------------------------------------------- 1 | @import "./scrollbar.css"; 2 | @import "./loading.css"; 3 | @import "./theme_light.css"; 4 | @import "./theme_dark.css"; 5 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/custom.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Custom issue template 3 | about: Describe this issue template's purpose here. 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | 11 | -------------------------------------------------------------------------------- /babel.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | [ 4 | "@babel/preset-env" 5 | ] 6 | ], 7 | "plugins": [ 8 | [ 9 | "@babel/plugin-transform-runtime" 10 | ] 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019-present, skillnull 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@skillnull/device-js", 3 | "version": "2.2.0", 4 | "description": "Get device information by javascript.", 5 | "main": "dist/device", 6 | "author": "skillnull", 7 | "keywords": [ 8 | "DeviceJS", 9 | "Device", 10 | "device-js", 11 | "skillnull", 12 | "SKILL.NULL" 13 | ], 14 | "scripts": { 15 | "build": "rollup --config rollup.config.js --bundleConfigAsCjs" 16 | }, 17 | "homepage": "https://github.com/skillnull/DeviceJs", 18 | "repository": { 19 | "type": "git", 20 | "url": "git+https://github.com/skillnull/DeviceJs.git" 21 | }, 22 | "bugs": { 23 | "url": "https://github.com/skillnull/DeviceJs/issues" 24 | }, 25 | "license": "MIT", 26 | "devDependencies": { 27 | "@babel/cli": "^7.24.7", 28 | "@babel/core": "^7.24.7", 29 | "@babel/plugin-transform-runtime": "^7.24.7", 30 | "@babel/polyfill": "^7.12.1", 31 | "@babel/preset-env": "^7.24.7", 32 | "@babel/runtime": "^7.24.7", 33 | "@rollup/plugin-babel": "^6.0.4", 34 | "@rollup/plugin-commonjs": "^26.0.1", 35 | "@rollup/plugin-node-resolve": "^15.3.1", 36 | "@rollup/plugin-terser": "^0.4.4", 37 | "rollup": "^4.18.0" 38 | }, 39 | "dependencies": { 40 | "@rollup/plugin-json": "^6.1.0", 41 | "@rollup/rollup-darwin-arm64": "^4.50.2", 42 | "jsdom": "^26.0.0", 43 | "rollup-plugin-polyfill-node": "^0.13.0" 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/css/scrollbar.css: -------------------------------------------------------------------------------- 1 | ::-webkit-scrollbar { 2 | width: 2px !important; 3 | height: 2px !important; 4 | } 5 | 6 | ::-webkit-scrollbar-corner { 7 | display: none !important; 8 | } 9 | 10 | ::-webkit-scrollbar-button { 11 | display: none !important; 12 | } 13 | 14 | @media (prefers-color-scheme: dark) { 15 | ::-webkit-scrollbar-track { 16 | background-color: #000000 !important; 17 | border-radius: 2px !important; 18 | } 19 | 20 | ::-webkit-scrollbar-track-piece { 21 | background-color: #000000 !important; 22 | border-radius: 2px !important; 23 | } 24 | 25 | ::-webkit-scrollbar-thumb { 26 | background: #3d8dbc61 !important; 27 | border-radius: 2px !important; 28 | } 29 | 30 | ::-webkit-scrollbar-thumb:hover { 31 | background: #3d8dbc61 !important; 32 | width: 2px !important; 33 | } 34 | } 35 | 36 | @media (prefers-color-scheme: light) { 37 | ::-webkit-scrollbar-track { 38 | background-color: white !important; 39 | border-radius: 2px !important; 40 | } 41 | 42 | ::-webkit-scrollbar-track-piece { 43 | background-color: white !important; 44 | border-radius: 2px !important; 45 | } 46 | 47 | ::-webkit-scrollbar-thumb { 48 | background: black !important; 49 | border-radius: 2px !important; 50 | } 51 | 52 | ::-webkit-scrollbar-thumb:hover { 53 | background: black !important; 54 | width: 2px !important; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/css/loading.css: -------------------------------------------------------------------------------- 1 | .ball-pulse { 2 | transform: scale(1); 3 | } 4 | 5 | .ball-pulse > div:nth-child(1) { 6 | -webkit-animation: ball-pulse-scale 0.75s -0.24s infinite cubic-bezier(0.2, 0.68, 0.18, 1.08); 7 | animation: ball-pulse-scale 0.75s -0.24s infinite cubic-bezier(0.2, 0.68, 0.18, 1.08); 8 | } 9 | 10 | .ball-pulse > div:nth-child(2) { 11 | -webkit-animation: ball-pulse-scale 0.75s -0.12s infinite cubic-bezier(0.2, 0.68, 0.18, 1.08); 12 | animation: ball-pulse-scale 0.75s -0.12s infinite cubic-bezier(0.2, 0.68, 0.18, 1.08); 13 | } 14 | 15 | .ball-pulse > div:nth-child(3) { 16 | -webkit-animation: ball-pulse-scale 0.75s 0s infinite cubic-bezier(0.2, 0.68, 0.18, 1.08); 17 | animation: ball-pulse-scale 0.75s 0s infinite cubic-bezier(0.2, 0.68, 0.18, 1.08); 18 | } 19 | 20 | .ball-pulse > div { 21 | background-color: #0FB560; 22 | width: 15px; 23 | height: 15px; 24 | border-radius: 100%; 25 | margin: 2px; 26 | -webkit-animation-fill-mode: both; 27 | animation-fill-mode: both; 28 | display: inline-block; 29 | } 30 | 31 | @keyframes ball-pulse-scale { 32 | 0% { 33 | -webkit-transform: scale(1); 34 | transform: scale(1); 35 | opacity: 1; 36 | } 37 | 45% { 38 | -webkit-transform: scale(0.1); 39 | transform: scale(0.1); 40 | opacity: 0.7; 41 | } 42 | 80% { 43 | -webkit-transform: scale(1); 44 | transform: scale(1); 45 | opacity: 1; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /rollup.config.js: -------------------------------------------------------------------------------- 1 | import { babel } from "@rollup/plugin-babel" 2 | import terser from "@rollup/plugin-terser" 3 | import commonjs from "@rollup/plugin-commonjs" 4 | import nodePolyfills from 'rollup-plugin-polyfill-node' 5 | import { nodeResolve } from '@rollup/plugin-node-resolve' 6 | import json from '@rollup/plugin-json' 7 | 8 | const globals = { 9 | "dayjs": "dayjs", 10 | "md5": "md5", 11 | "qs": "qs", 12 | "crypto-js": "crypto" 13 | } 14 | 15 | /** 16 | * amd - 异步模块加载,适用于 RequireJS 等模块加载器 17 | * cjs - CommonJS,适用于 Node 环境和其他打包工具(别名:commonjs) 18 | * es - 将 bundle 保留为 ES 模块文件,适用于其他打包工具,以及支持 14 | # or 15 | 16 | 17 | 18 | 使用 ES 格式 19 | 20 | # or 21 | 22 | ``` 23 | 24 | > #### 安装 25 | 26 | ```shell 27 | # NPM or YARN 28 | 29 | yarn add @skillnull/device-js 30 | 31 | # or with npm 32 | 33 | npm install @skillnull/device-js 34 | ``` 35 | 36 | > #### 调用 37 | 38 | ```js 39 | // 使用 CDN 引用时,无需 import 40 | import Device from '@skillnull/device-js' 41 | 42 | /** 43 | * @params:{ 44 | * domain: 生成浏览器指纹所需,不传默认使用window.location.host; 45 | * transferDateToLunar: 要被转化为农历的日期,需要同时开启info中的lunarDate选项才生效 46 | * info: 想要获取的信息,不传默认开启全部信息显示 47 | * } 48 | * 49 | * @return: 返回 Promise 对象 50 | */ 51 | 52 | Device.Info({ 53 | domain: 'your domain', 54 | transferDateToLunar: '需要转化为农历的日期。例如: 2023/01/01。', 55 | info: ['lunarDate'] 56 | }).then(data => { 57 | console.log(data) 58 | }) 59 | 60 | // 或 61 | 62 | Device.Info().then(data => { 63 | console.log(data) 64 | }) 65 | ``` 66 | 67 | > #### INFO 配置项 68 | > - deviceType: 设备类型 69 | > - OS: 操作系统 70 | > - OSVersion: 操作系统版本 71 | > - platform: 操作系统平台 72 | > - screenHeight: 屏幕高 73 | > - screenWidth: 屏幕宽 74 | > - language: 当前使用的语言-国家 75 | > - netWork: 联网类型 76 | > - orientation: 横竖屏 77 | > - browserInfo: 浏览器信息 78 | > - fingerprint: 浏览器指纹 79 | > - userAgent: 包含 appCodeName,appName,appVersion,language,platform 等 80 | > - geoPosition: 地理位置 81 | > - date: 阳历日期时间 82 | > - lunarDate: 阴历日期 83 | > - week: 周几 84 | > - UUID: 通用唯一标识 Universally Unique Identifier 85 | 86 | > #### 在线地址: [https://skillnull.com/others/DeviceJs/index.html](https://skillnull.com/others/DeviceJs/index.html) 87 | 88 | -------------------------------------------------------------------------------- /src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | 9 | 10 | 11 | 12 | Get Device Info Online 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |
输入以下想要获取信息的key,多个key用逗号相隔, 为空则显示全部
21 |
22 |
FORK
23 |
24 |
25 |
26 |
27 |
    28 |
  • deviceType // 设备类型
  • 29 |
  • OS // 操作系统
  • 30 |
  • OSVersion // 操作系统版本
  • 31 |
  • platform // 操作系统平台
  • 32 |
  • screenHeight // 屏幕高
  • 33 |
  • screenWidth // 屏幕宽
  • 34 |
  • language // 当前使用的语言-国家
  • 35 |
  • netWork // 联网类型
  • 36 |
  • orientation // 横竖屏
  • 37 |
  • browserInfo // 浏览器信息
  • 38 |
  • fingerprint // 浏览器指纹
  • 39 |
  • userAgent // 包含 appCodeName,appName,appVersion,language,platform 等
  • 40 |
  • geoPosition // 地理位置
  • 41 |
  • date // 阳历日期时间
  • 42 |
  • lunarDate // 阴历日期
  • 43 |
  • week // 周几
  • 44 |
  • UUID // 通用唯一标识 Universally Unique Identifier
  • 45 |
46 |
47 |
48 | 49 | 50 |
51 |
52 |
53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /src/css/theme_light.css: -------------------------------------------------------------------------------- 1 | @media (prefers-color-scheme: light) { 2 | html, body { 3 | font-weight: 300; 4 | margin: 0; 5 | padding: 0; 6 | background: white; 7 | color: #000000; 8 | } 9 | 10 | .title { 11 | text-align: center; 12 | color: white; 13 | margin: 0; 14 | width: calc(100% - 20px); 15 | padding: 10px 10px 20px 10px; 16 | position: fixed; 17 | top: 0; 18 | left: 0; 19 | overflow: hidden; 20 | backdrop-filter: saturate(50%) blur(4px); 21 | background-image: radial-gradient(transparent 1px, #ffffff 1px); 22 | background-size: 4px 4px; 23 | border-bottom: 1px solid #f7f7f7; 24 | } 25 | 26 | .title > .brand { 27 | height: 80px; 28 | width: auto; 29 | } 30 | 31 | .title > .tips { 32 | font-size: 18px; 33 | color: #212121; 34 | } 35 | 36 | .title > .fork { 37 | width: 40px; 38 | height: 40px; 39 | background-image: url("https://skillnull.com/wp-content/themes/basepress/assets/images/icon/github.png"); 40 | background-repeat: no-repeat; 41 | background-size: calc(100% - 5px) calc(100% - 5px); 42 | position: absolute; 43 | right: 0; 44 | top: 0; 45 | background-position: right 5px top 5px; 46 | cursor: pointer; 47 | } 48 | 49 | .title > .fork > .text { 50 | font-size: 12px; 51 | position: absolute; 52 | left: -50%; 53 | top: 40%; 54 | transform: rotate(45deg) translateY(-50%); 55 | background: #000000bf; 56 | width: 180%; 57 | color: white; 58 | text-shadow: 0px 0px 1px #ffffff; 59 | } 60 | 61 | .content { 62 | margin-bottom: 20px; 63 | } 64 | 65 | .keyTipBox { 66 | word-break: break-all; 67 | } 68 | 69 | .keyTipBox > ul > li > .comment { 70 | color: #3d8dbc; 71 | } 72 | 73 | .getInfoBox { 74 | display: flex; 75 | flex: 1; 76 | justify-content: flex-start; 77 | align-items: center; 78 | margin: 25px; 79 | } 80 | 81 | .getInfoBox textarea { 82 | display: flex; 83 | flex: 4; 84 | height: 35px; 85 | outline: none; 86 | border-radius: 3px; 87 | padding: 5px; 88 | box-shadow: 0 0 0 1px #3d8dbc61 inset; 89 | background: transparent; 90 | border: none; 91 | color: #3d8dbc; 92 | font-family: auto; 93 | } 94 | 95 | .getInfoBox button { 96 | margin: 0 10px; 97 | width: 60px; 98 | text-align: center; 99 | justify-content: center; 100 | align-items: center; 101 | height: 45px; 102 | border-radius: 3px; 103 | outline: none; 104 | border: 1px solid #3d8dbc61; 105 | font-size: 14px; 106 | cursor: pointer; 107 | background-color: transparent; 108 | color: #3d8dbc; 109 | font-weight: 400; 110 | } 111 | 112 | .getInfoBox button:hover { 113 | border-color: #3d8dbc; 114 | } 115 | 116 | #info_box { 117 | word-break: break-all; 118 | } 119 | 120 | textarea::placeholder { 121 | padding: 8px; 122 | font-weight: 300; 123 | color: #01121d; 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /src/css/theme_dark.css: -------------------------------------------------------------------------------- 1 | @media (prefers-color-scheme: dark) { 2 | html, body { 3 | font-weight: 300; 4 | margin: 0; 5 | padding: 0; 6 | background: #141414; 7 | color: #CFD3DC; 8 | } 9 | 10 | .title { 11 | text-align: center; 12 | color: white; 13 | margin: 0; 14 | width: calc(100% - 20px); 15 | padding: 10px 10px 20px 10px; 16 | position: fixed; 17 | top: 0; 18 | left: 0; 19 | overflow: hidden; 20 | backdrop-filter: saturate(50%) blur(4px); 21 | background-image: radial-gradient(transparent 1px, #141414 1px); 22 | background-size: 4px 4px; 23 | border-bottom: 1px solid #333; 24 | } 25 | 26 | .title > .brand { 27 | height: 80px; 28 | width: auto; 29 | filter: invert(100%) sepia(100%) saturate(10%) hue-rotate(221deg) brightness(100%) contrast(50%); 30 | } 31 | 32 | .title > .tips { 33 | font-size: 18px; 34 | color: #c6c6c6; 35 | } 36 | 37 | .title > .fork { 38 | width: 40px; 39 | height: 40px; 40 | background-image: url("https://skillnull.com/wp-content/themes/basepress/assets/images/icon/github.png"); 41 | background-repeat: no-repeat; 42 | background-size: calc(100% - 5px) calc(100% - 5px); 43 | position: absolute; 44 | right: 0; 45 | top: 0; 46 | background-position: right 5px top 5px; 47 | cursor: pointer; 48 | filter: invert(100%) sepia(100%) saturate(10%) hue-rotate(221deg) brightness(100%) contrast(50%); 49 | } 50 | 51 | .title > .fork > .text { 52 | font-size: 12px; 53 | position: absolute; 54 | left: -50%; 55 | top: 40%; 56 | transform: rotate(45deg) translateY(-50%); 57 | background: white; 58 | width: 180%; 59 | color: black; 60 | text-shadow: 0px 0px 1px #000000; 61 | } 62 | 63 | .content { 64 | margin-bottom: 20px; 65 | } 66 | 67 | .keyTipBox { 68 | word-break: break-all; 69 | } 70 | 71 | .keyTipBox > ul > li > .comment { 72 | color: #3d8dbc; 73 | } 74 | 75 | .getInfoBox { 76 | display: flex; 77 | flex: 1; 78 | justify-content: flex-start; 79 | align-items: center; 80 | margin: 25px; 81 | } 82 | 83 | .getInfoBox textarea { 84 | display: flex; 85 | flex: 4; 86 | height: 35px; 87 | outline: none; 88 | border-radius: 3px; 89 | padding: 5px; 90 | box-shadow: 0 0 0 1px #3d8dbc61 inset; 91 | background: transparent; 92 | border: none; 93 | color: #3d8dbc; 94 | font-family: auto; 95 | } 96 | 97 | .getInfoBox button { 98 | margin: 0 10px; 99 | width: 60px; 100 | text-align: center; 101 | justify-content: center; 102 | align-items: center; 103 | height: 45px; 104 | border-radius: 3px; 105 | outline: none; 106 | border: 1px solid #3d8dbc61; 107 | font-size: 14px; 108 | cursor: pointer; 109 | background-color: transparent; 110 | color: #3d8dbc; 111 | font-weight: 400; 112 | } 113 | 114 | .getInfoBox button:hover { 115 | border-color: #3d8dbc; 116 | } 117 | 118 | #info_box { 119 | word-break: break-all; 120 | } 121 | 122 | textarea::placeholder { 123 | padding: 8px; 124 | font-weight: 300; 125 | color: #3d8dbc61; 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /dist/device.es.js: -------------------------------------------------------------------------------- 1 | function n(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var e={exports:{}};!function(n){function e(i){return n.exports=e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(n){return typeof n}:function(n){return n&&"function"==typeof Symbol&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},n.exports.__esModule=!0,n.exports.default=n.exports,e(i)}n.exports=e,n.exports.__esModule=!0,n.exports.default=n.exports}(e);var i=n(e.exports),o=function(){var n="undefined"!=typeof self?self:this,e=n||{},i={navigator:void 0!==(null==n?void 0:n.navigator)?null==n?void 0:n.navigator:{},infoMap:{engine:["WebKit","Trident","Gecko","Presto"],browser:["Safari","Chrome","Edge","IE","Firefox","Firefox Focus","Chromium","Opera","Vivaldi","Yandex","Arora","Lunascape","QupZilla","Coc Coc","Kindle","Iceweasel","Konqueror","Iceape","SeaMonkey","Epiphany","360","360SE","360EE","UC","QQBrowser","QQ","Baidu","Maxthon","Sogou","LBBROWSER","2345Explorer","TheWorld","XiaoMi","Quark","Qiyu","Wechat",,"WechatWork","Taobao","Alipay","Weibo","Douban","Suning","iQiYi"],os:["Windows","Linux","Mac OS","Android","Ubuntu","FreeBSD","Debian","iOS","Windows Phone","BlackBerry","MeeGo","Symbian","Chrome OS","WebOS","HarmonyOS"],device:["Mobile","Tablet","iPad"]},lunarLib:{lunarMap:[19416,19168,42352,21717,53856,55632,91476,22176,39632,21970,19168,42422,42192,53840,119381,46400,54944,44450,38320,84343,18800,42160,46261,27216,27968,109396,11104,38256,21234,18800,25958,54432,59984,28309,23248,11104,100067,37600,116951,51536,54432,120998,46416,22176,107956,9680,37584,53938,43344,46423,27808,46416,86869,19872,42448,83315,21200,43432,59728,27296,44710,43856,19296,43748,42352,21088,62051,55632,23383,22176,38608,19925,19152,42192,54484,53840,54616,46400,46496,103846,38320,18864,43380,42160,45690,27216,27968,44870,43872,38256,19189,18800,25776,29859,59984,27480,21952,43872,38613,37600,51552,55636,54432,55888,30034,22176,43959,9680,37584,51893,43344,46240,47780,44368,21977,19360,42416,86390,21168,43312,31060,27296,44368,23378,19296,42726,42208,53856,60005,54576,23200,30371,38608,19415,19152,42192,118966,53840,54560,56645,46496,22224,21938,18864,42359,42160,43600,111189,27936,44448],solarMonthArr:[31,28,31,30,31,30,31,31,30,31,30,31],AnimalsArr:["鼠","牛","虎","兔","龙","蛇","马","羊","猴","鸡","狗","猪"],numberToHanzi_1:["日","一","二","三","四","五","六","七","八","九","十"],numberToHanzi_2:["初","十","廿","卅"],chineseMonth:["正","二","三","四","五","六","七","八","九","十","冬","腊"],chineseYear:["零","一","二","三","四","五","六","七","八","九"],monthPlusOne:""}},o={createLoading:function(n,e){var i,o,l=1,r="";e&&(r='
'+l+"s
");var u="";n&&(u='
'+n+"
");var d=null===(i=document)||void 0===i?void 0:i.createElement("div");if(d.id="create_loading",d.style="display: block; position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 9999999999; text-align: center; font-size: 14px; display: flex; flex: 1; justify-content: center; flex-direction: column; align-items: center; background: rgba(0, 0, 0, 0.09);",d.innerHTML=r+'
'+u,null===(o=document)||void 0===o||null===(o=o.body)||void 0===o||o.appendChild(d),e){var a,t=null===(a=document)||void 0===a?void 0:a.getElementById("count_box");setInterval((function(){l++,t&&(t.innerHTML="
"+l+"s
")}),1e3)}},removeLoading:function(){var n,e,i=null===(n=document)||void 0===n?void 0:n.getElementById("create_loading");null===(e=document)||void 0===e||null===(e=e.body)||void 0===e||e.removeChild(i)},createUUID:function(){for(var n=[],e="0123456789abcdef",i=0;i<36;i++)n[i]=e.substr(null===Math||void 0===Math?void 0:Math.floor(16*(null===Math||void 0===Math?void 0:Math.random())),1);return n[14]="4",n[19]=e.substr(3&n[19]|8,1),n[8]=n[13]=n[18]=n[23]="-",null==n?void 0:n.join("")},getDate:function(){var n=new Date,e=null==n?void 0:n.getFullYear(),i=(null==n?void 0:n.getMonth())+1,o=null==n?void 0:n.getDate(),l=null==n?void 0:n.getHours(),r=null==n?void 0:n.getMinutes(),u=null==n?void 0:n.getSeconds();return i=i>9?i:"0"+i,o=o>9?o:"0"+o,l=l>9?l:"0"+l,r=r>9?r:"0"+r,u=u>9?u:"0"+u,"".concat(e,"/").concat(i,"/").concat(o," ").concat(l,":").concat(r,":").concat(u)},getWeek:function(){var n=new Array("周日","周一","周二","周三","周四","周五","周六"),e=new Date;return n[null==e?void 0:e.getDay()]},getMatchMap:function(n){return{Trident:(null==n?void 0:n.indexOf("Trident"))>-1||(null==n?void 0:n.indexOf("NET CLR"))>-1,Presto:(null==n?void 0:n.indexOf("Presto"))>-1,WebKit:(null==n?void 0:n.indexOf("AppleWebKit"))>-1,Gecko:(null==n?void 0:n.indexOf("Gecko/"))>-1,Safari:(null==n?void 0:n.indexOf("Safari"))>-1,Chrome:(null==n?void 0:n.indexOf("Chrome"))>-1||(null==n?void 0:n.indexOf("CriOS"))>-1,IE:(null==n?void 0:n.indexOf("MSIE"))>-1||(null==n?void 0:n.indexOf("Trident"))>-1,Edge:(null==n?void 0:n.indexOf("Edge"))>-1,Firefox:(null==n?void 0:n.indexOf("Firefox"))>-1||(null==n?void 0:n.indexOf("FxiOS"))>-1,"Firefox Focus":(null==n?void 0:n.indexOf("Focus"))>-1,Chromium:(null==n?void 0:n.indexOf("Chromium"))>-1,Opera:(null==n?void 0:n.indexOf("Opera"))>-1||(null==n?void 0:n.indexOf("OPR"))>-1,Vivaldi:(null==n?void 0:n.indexOf("Vivaldi"))>-1,Yandex:(null==n?void 0:n.indexOf("YaBrowser"))>-1,Arora:(null==n?void 0:n.indexOf("Arora"))>-1,Lunascape:(null==n?void 0:n.indexOf("Lunascape"))>-1,QupZilla:(null==n?void 0:n.indexOf("QupZilla"))>-1,"Coc Coc":(null==n?void 0:n.indexOf("coc_coc_browser"))>-1,Kindle:(null==n?void 0:n.indexOf("Kindle"))>-1||(null==n?void 0:n.indexOf("Silk/"))>-1,Iceweasel:(null==n?void 0:n.indexOf("Iceweasel"))>-1,Konqueror:(null==n?void 0:n.indexOf("Konqueror"))>-1,Iceape:(null==n?void 0:n.indexOf("Iceape"))>-1,SeaMonkey:(null==n?void 0:n.indexOf("SeaMonkey"))>-1,Epiphany:(null==n?void 0:n.indexOf("Epiphany"))>-1,360:(null==n?void 0:n.indexOf("QihooBrowser"))>-1||(null==n?void 0:n.indexOf("QHBrowser"))>-1,"360EE":(null==n?void 0:n.indexOf("360EE"))>-1,"360SE":(null==n?void 0:n.indexOf("360SE"))>-1,UC:(null==n?void 0:n.indexOf("UC"))>-1||(null==n?void 0:n.indexOf(" UBrowser"))>-1,QQBrowser:(null==n?void 0:n.indexOf("QQBrowser"))>-1,QQ:(null==n?void 0:n.indexOf("QQ/"))>-1,Baidu:(null==n?void 0:n.indexOf("Baidu"))>-1||(null==n?void 0:n.indexOf("BIDUBrowser"))>-1,Maxthon:(null==n?void 0:n.indexOf("Maxthon"))>-1,Sogou:(null==n?void 0:n.indexOf("MetaSr"))>-1||(null==n?void 0:n.indexOf("Sogou"))>-1,LBBROWSER:(null==n?void 0:n.indexOf("LBBROWSER"))>-1||(null==n?void 0:n.indexOf("LieBaoFast"))>-1,"2345Explorer":(null==n?void 0:n.indexOf("2345Explorer"))>-1,TheWorld:(null==n?void 0:n.indexOf("TheWorld"))>-1,XiaoMi:(null==n?void 0:n.indexOf("MiuiBrowser"))>-1,Quark:(null==n?void 0:n.indexOf("Quark"))>-1,Qiyu:(null==n?void 0:n.indexOf("Qiyu"))>-1,Wechat:(null==n?void 0:n.indexOf("MicroMessenger"))>-1,WechatWork:(null==n?void 0:n.indexOf("wxwork/"))>-1,Taobao:(null==n?void 0:n.indexOf("AliApp(TB"))>-1,Alipay:(null==n?void 0:n.indexOf("AliApp(AP"))>-1,Weibo:(null==n?void 0:n.indexOf("Weibo"))>-1,Douban:(null==n?void 0:n.indexOf("com.douban.frodo"))>-1,Suning:(null==n?void 0:n.indexOf("SNEBUY-APP"))>-1,iQiYi:(null==n?void 0:n.indexOf("IqiyiApp"))>-1,DingTalk:(null==n?void 0:n.indexOf("DingTalk"))>-1,Vivo:(null==n?void 0:n.indexOf("VivoBrowser"))>-1,Huawei:(null==n?void 0:n.indexOf("HuaweiBrowser"))>-1||(null==n?void 0:n.indexOf("HUAWEI/"))>-1||(null==n?void 0:n.indexOf("HONOR"))>-1||(null==n?void 0:n.indexOf("HBPC/"))>-1,Windows:(null==n?void 0:n.indexOf("Windows"))>-1,Linux:(null==n?void 0:n.indexOf("Linux"))>-1||(null==n?void 0:n.indexOf("X11"))>-1,"Mac OS":(null==n?void 0:n.indexOf("Macintosh"))>-1,Android:(null==n?void 0:n.indexOf("Android"))>-1||(null==n?void 0:n.indexOf("Adr"))>-1,Ubuntu:(null==n?void 0:n.indexOf("Ubuntu"))>-1,FreeBSD:(null==n?void 0:n.indexOf("FreeBSD"))>-1,Debian:(null==n?void 0:n.indexOf("Debian"))>-1,"Windows Phone":(null==n?void 0:n.indexOf("IEMobile"))>-1||(null==n?void 0:n.indexOf("Windows Phone"))>-1,BlackBerry:(null==n?void 0:n.indexOf("BlackBerry"))>-1||(null==n?void 0:n.indexOf("RIM"))>-1,MeeGo:(null==n?void 0:n.indexOf("MeeGo"))>-1,Symbian:(null==n?void 0:n.indexOf("Symbian"))>-1,iOS:(null==n?void 0:n.indexOf("like Mac OS X"))>-1,"Chrome OS":(null==n?void 0:n.indexOf("CrOS"))>-1,WebOS:(null==n?void 0:n.indexOf("hpwOS"))>-1,HarmonyOS:(null==n?void 0:n.indexOf("HarmonyOS"))>-1,Mobile:(null==n?void 0:n.indexOf("Mobi"))>-1||(null==n?void 0:n.indexOf("iPh"))>-1||(null==n?void 0:n.indexOf("480"))>-1,Tablet:(null==n?void 0:n.indexOf("Tablet"))>-1||(null==n?void 0:n.indexOf("Nexus 7"))>-1,iPad:(null==n?void 0:n.indexOf("iPad"))>-1}},matchInfoMap:function(n){var e,l=(null==i||null===(e=i.navigator)||void 0===e?void 0:e.userAgent)||{},r=null==o?void 0:o.getMatchMap(l);for(var u in null==i?void 0:i.infoMap)for(var d=0;d<(null==i||null===(a=i.infoMap)||void 0===a||null===(a=a[u])||void 0===a?void 0:a.length);d++){var a,t,v=null==i||null===(t=i.infoMap)||void 0===t||null===(t=t[u])||void 0===t?void 0:t[d];r[v]&&(n[u]=v)}},getOS:function(){return null==o||o.matchInfoMap(this),this.os},getOSVersion:function(){var n,e=this,o=(null==i||null===(n=i.navigator)||void 0===n?void 0:n.userAgent)||{};e.osVersion="";var l,r={Windows:function(){var n=null==o?void 0:o.replace(/^.*Windows NT ([\d.]+);.*$/,"$1");return{10:"10 || 11",6.3:"8.1",6.2:"8",6.1:"7","6.0":"Vista",5.2:"XP 64-Bit",5.1:"XP","5.0":"2000","4.0":"NT 4.0","3.5.1":"NT 3.5.1",3.5:"NT 3.5",3.1:"NT 3.1"}[n]||n},Android:function(){return null==o?void 0:o.replace(/^.*Android ([\d.]+);.*$/,"$1")},iOS:function(){var n;return null==o||null===(n=o.replace(/^.*OS ([\d_]+) like.*$/,"$1"))||void 0===n?void 0:n.replace(/_/g,".")},Debian:function(){return null==o?void 0:o.replace(/^.*Debian\/([\d.]+).*$/,"$1")},"Windows Phone":function(){return null==o?void 0:o.replace(/^.*Windows Phone( OS)? ([\d.]+);.*$/,"$2")},"Mac OS":function(){var n;return null==o||null===(n=o.replace(/^.*Mac OS X ([\d_]+).*$/,"$1"))||void 0===n?void 0:n.replace(/_/g,".")},WebOS:function(){return null==o?void 0:o.replace(/^.*hpwOS\/([\d.]+);.*$/,"$1")}};return r[e.os]&&(e.osVersion=null==r||null===(l=r[e.os])||void 0===l?void 0:l.call(r),e.osVersion==o&&(e.osVersion="")),e.osVersion},getOrientationStatu:function(){var n,e=null===(n=window)||void 0===n?void 0:n.matchMedia("(orientation: portrait)");return null!=e&&e.matches?"竖屏":"横屏"},getDeviceType:function(){var n=this;return n.device="PC",null==o||o.matchInfoMap(n),n.device},getNetwork:function(){var n,e,i=null===(n=navigator)||void 0===n||null===(n=n.connection)||void 0===n?void 0:n.effectiveType;return(null===(e=navigator)||void 0===e?void 0:e.onLine)?i||"网络状态获取失败":"离线"},getLanguage:function(){return this.language=(l=(null==i||null===(n=i.navigator)||void 0===n?void 0:n.browserLanguage)||(null==i||null===(e=i.navigator)||void 0===e?void 0:e.language),(r=null==l?void 0:l.split("-"))[1]&&(r[1]=null==r||null===(o=r[1])||void 0===o?void 0:o.toUpperCase()),null==r?void 0:r.join("_")),this.language;var n,e,o,l,r},createFingerprint:function(n){var e,i,o,l=null===(e=document)||void 0===e?void 0:e.createElement("canvas"),r=null==l?void 0:l.getContext("2d"),u=n||(null===(i=window)||void 0===i||null===(i=i.location)||void 0===i?void 0:i.host);r.textBaseline="top",r.font="14px 'Arial'",r.textBaseline="tencent",r.fillStyle="#f60",r.fillRect(125,1,62,20),r.fillStyle="#069",r.fillText(u,2,15),r.fillStyle="rgba(102, 204, 0, 0.7)",r.fillText(u,4,17);var d=null==l||null===(o=l.toDataURL())||void 0===o?void 0:o.replace("data:image/png;base64,",""),a=atob(d);return function(n){var e,i,o,l="";for(e=0,i=(n+="").length;e36&&e.showModalDialog?v=!0:c>45&&(v=a("type","application/vnd.chromium.remoting-viewer"))}if(t.Baidu&&t.Opera&&(t.Baidu=!1),t.Mobile&&(t.Mobile=!((null==d?void 0:d.indexOf("iPad"))>-1)),v&&(a("type","application/gameplugin")||null!=i&&i.navigator&&void 0===(null==i?void 0:i.navigator.connection.saveData)?t["360SE"]=!0:t["360EE"]=!0),t.IE||t.Edge)switch((null===(r=window)||void 0===r?void 0:r.screenTop)-(null===(u=window)||void 0===u?void 0:u.screenY)){case 71:case 74:case 99:case 75:case 74:case 105:break;case 102:t["360EE"]=!0;break;case 104:t["360SE"]=!0}var f,s={Safari:function(){return null==d?void 0:d.replace(/^.*Version\/([\d.]+).*$/,"$1")},Chrome:function(){var n;return null==d||null===(n=d.replace(/^.*Chrome\/([\d.]+).*$/,"$1"))||void 0===n?void 0:n.replace(/^.*CriOS\/([\d.]+).*$/,"$1")},IE:function(){var n;return null==d||null===(n=d.replace(/^.*MSIE ([\d.]+).*$/,"$1"))||void 0===n?void 0:n.replace(/^.*rv:([\d.]+).*$/,"$1")},Edge:function(){return null==d?void 0:d.replace(/^.*Edge\/([\d.]+).*$/,"$1")},Firefox:function(){var n;return null==d||null===(n=d.replace(/^.*Firefox\/([\d.]+).*$/,"$1"))||void 0===n?void 0:n.replace(/^.*FxiOS\/([\d.]+).*$/,"$1")},"Firefox Focus":function(){return null==d?void 0:d.replace(/^.*Focus\/([\d.]+).*$/,"$1")},Chromium:function(){return null==d?void 0:d.replace(/^.*Chromium\/([\d.]+).*$/,"$1")},Opera:function(){var n;return null==d||null===(n=d.replace(/^.*Opera\/([\d.]+).*$/,"$1"))||void 0===n?void 0:n.replace(/^.*OPR\/([\d.]+).*$/,"$1")},Vivaldi:function(){return null==d?void 0:d.replace(/^.*Vivaldi\/([\d.]+).*$/,"$1")},Yandex:function(){return null==d?void 0:d.replace(/^.*YaBrowser\/([\d.]+).*$/,"$1")},Arora:function(){return null==d?void 0:d.replace(/^.*Arora\/([\d.]+).*$/,"$1")},Lunascape:function(){return null==d?void 0:d.replace(/^.*Lunascape[\/\s]([\d.]+).*$/,"$1")},QupZilla:function(){return null==d?void 0:d.replace(/^.*QupZilla[\/\s]([\d.]+).*$/,"$1")},"Coc Coc":function(){return null==d?void 0:d.replace(/^.*coc_coc_browser\/([\d.]+).*$/,"$1")},Kindle:function(){return null==d?void 0:d.replace(/^.*Version\/([\d.]+).*$/,"$1")},Iceweasel:function(){return null==d?void 0:d.replace(/^.*Iceweasel\/([\d.]+).*$/,"$1")},Konqueror:function(){return null==d?void 0:d.replace(/^.*Konqueror\/([\d.]+).*$/,"$1")},Iceape:function(){return null==d?void 0:d.replace(/^.*Iceape\/([\d.]+).*$/,"$1")},SeaMonkey:function(){return null==d?void 0:d.replace(/^.*SeaMonkey\/([\d.]+).*$/,"$1")},Epiphany:function(){return null==d?void 0:d.replace(/^.*Epiphany\/([\d.]+).*$/,"$1")},360:function(){return null==d?void 0:d.replace(/^.*QihooBrowser\/([\d.]+).*$/,"$1")},"360SE":function(){return{63:"10.0",55:"9.1",45:"8.1",42:"8.0",31:"7.0",21:"6.3"}[null==d?void 0:d.replace(/^.*Chrome\/([\d]+).*$/,"$1")]||""},"360EE":function(){return{69:"11.0",63:"9.5",55:"9.0",50:"8.7",30:"7.5"}[null==d?void 0:d.replace(/^.*Chrome\/([\d]+).*$/,"$1")]||""},Maxthon:function(){return null==d?void 0:d.replace(/^.*Maxthon\/([\d.]+).*$/,"$1")},QQBrowser:function(){return null==d?void 0:d.replace(/^.*QQBrowser\/([\d.]+).*$/,"$1")},QQ:function(){return null==d?void 0:d.replace(/^.*QQ\/([\d.]+).*$/,"$1")},Baidu:function(){return null==d?void 0:d.replace(/^.*BIDUBrowser[\s\/]([\d.]+).*$/,"$1")},UC:function(){return null==d?void 0:d.replace(/^.*UC?Browser\/([\d.]+).*$/,"$1")},Sogou:function(){var n;return null==d||null===(n=d.replace(/^.*SE ([\d.X]+).*$/,"$1"))||void 0===n?void 0:n.replace(/^.*SogouMobileBrowser\/([\d.]+).*$/,"$1")},Liebao:function(){var n="";(null==d?void 0:d.indexOf("LieBaoFast"))>-1&&(n=null==d?void 0:d.replace(/^.*LieBaoFast\/([\d.]+).*$/,"$1"));var e=null==d?void 0:d.replace(/^.*Chrome\/([\d]+).*$/,"$1");return n||{57:"6.5",49:"6.0",46:"5.9",42:"5.3",39:"5.2",34:"5.0",29:"4.5",21:"4.0"}[e]||""},LBBROWSER:function(){var n="";(null==d?void 0:d.indexOf("LieBaoFast"))>-1&&(n=null==d?void 0:d.replace(/^.*LieBaoFast\/([\d.]+).*$/,"$1"));var e=null==d?void 0:d.replace(/^.*Chrome\/([\d]+).*$/,"$1");return n||{57:"6.5",49:"6.0",46:"5.9",42:"5.3",39:"5.2",34:"5.0",29:"4.5",21:"4.0"}[e]||""},"2345Explorer":function(){return null==d?void 0:d.replace(/^.*2345Explorer\/([\d.]+).*$/,"$1")},"115Browser":function(){return null==d?void 0:d.replace(/^.*115Browser\/([\d.]+).*$/,"$1")},TheWorld:function(){return null==d?void 0:d.replace(/^.*TheWorld ([\d.]+).*$/,"$1")},XiaoMi:function(){return null==d?void 0:d.replace(/^.*MiuiBrowser\/([\d.]+).*$/,"$1")},Vivo:function(){return null==d?void 0:d.replace(/^.*VivoBrowser\/([\d.]+).*$/,"$1")},Quark:function(){return null==d?void 0:d.replace(/^.*Quark\/([\d.]+).*$/,"$1")},Qiyu:function(){return null==d?void 0:d.replace(/^.*Qiyu\/([\d.]+).*$/,"$1")},Wechat:function(){return null==d?void 0:d.replace(/^.*MicroMessenger\/([\d.]+).*$/,"$1")},WechatWork:function(){return null==d?void 0:d.replace(/^.*wxwork\/([\d.]+).*$/,"$1")},Taobao:function(){return null==d?void 0:d.replace(/^.*AliApp\(TB\/([\d.]+).*$/,"$1")},Alipay:function(){return null==d?void 0:d.replace(/^.*AliApp\(AP\/([\d.]+).*$/,"$1")},Weibo:function(){return null==d?void 0:d.replace(/^.*weibo__([\d.]+).*$/,"$1")},Douban:function(){return null==d?void 0:d.replace(/^.*com.douban.frodo\/([\d.]+).*$/,"$1")},Suning:function(){return null==d?void 0:d.replace(/^.*SNEBUY-APP([\d.]+).*$/,"$1")},iQiYi:function(){return null==d?void 0:d.replace(/^.*IqiyiVersion\/([\d.]+).*$/,"$1")},DingTalk:function(){return null==d?void 0:d.replace(/^.*DingTalk\/([\d.]+).*$/,"$1")},Huawei:function(){var n;return null==d||null===(n=d.replace(/^.*Version\/([\d.]+).*$/,"$1"))||void 0===n||null===(n=n.replace(/^.*HuaweiBrowser\/([\d.]+).*$/,"$1"))||void 0===n?void 0:n.replace(/^.*HBPC\/([\d.]+).*$/,"$1")}};return l.browserVersion="",s[l.browser]&&(l.browserVersion=null==s||null===(f=s[l.browser])||void 0===f?void 0:f.call(s),l.browserVersion==d&&(l.browserVersion="")),"Chrome"==l.browser&&null!=d&&d.match(/\S+Browser/)&&(l.browser=null==d?void 0:d.match(/\S+Browser/)[0],l.version=null==d?void 0:d.replace(/^.*Browser\/([\d.]+).*$/,"$1")),"Edge"==l.browser&&(l.version>"75"?l.engine="Blink":l.engine="EdgeHTML"),("Chrome"==l.browser&&parseInt(l.browserVersion)>27||t.Chrome&&"WebKit"==l.engine&&parseInt(s.Chrome())>27||"Opera"==l.browser&&parseInt(l.version)>12||"Yandex"==l.browser)&&(l.engine="Blink"),l.browser+"(版本: "+l.browserVersion+"  内核: "+l.engine+")"},getGeoPostion:function(){return new Promise((function(n,e){var i,o;null!==(i=navigator)&&void 0!==i&&i.geolocation?null===(o=navigator)||void 0===o||null===(o=o.geolocation)||void 0===o||o.getCurrentPosition((function(e){n(e)}),(function(e){n({coords:{longitude:"获取失败",latitude:"获取失败"}})}),{enableHighAccuracy:!1,timeout:1e4}):e("当前浏览器不支持获取地理位置")}))},toLunarDate:function(n){var e=new Date;return function(e){var o,l,r,u,d,a,t,v,c,f,s,p,g,x,O,h,w,$,b=null===(o=new Date(e))||void 0===o?void 0:o.getFullYear(),m=null===(l=new Date(e))||void 0===l?void 0:l.getMonth(),M=null===(r=new Date(e))||void 0===r?void 0:r.getDate(),y=1,S=0;function B(n){var e;return 15&(null==i||null===(e=i.lunarLib)||void 0===e||null===(e=e.lunarMap)||void 0===e?void 0:e[n-1900])}function E(n){var e;return B(n)?65536&(null==i||null===(e=i.lunarLib)||void 0===e||null===(e=e.lunarMap)||void 0===e?void 0:e[n-1900])?30:29:0}function L(n,e){var o;return(null==i||null===(o=i.lunarLib)||void 0===o||null===(o=o.lunarMap)||void 0===o?void 0:o[n-1900])&65536>>e?30:29}function D(n){var e,o,l=0,r=(n-new Date(1900,0,31))/864e5,u=r+40,d=14;for(e=1900;e<2050&&r>0;e++){for(var a=348,t=32768;t>8;t>>=1){var v;a+=(null==i||null===(v=i.lunarLib)||void 0===v?void 0:v.lunarMap[e-1900])&t?1:0}r-=l=a+E(e),d+=12}r<0&&(r+=l,e--,d-=12);var c=e,f=e-1864;o=B(e);var s=!1;for(e=1;e<13&&r>0;e++)o>0&&e===o+1&&!1===s?(--e,s=!0,l=E(c)):l=L(c,e),!0===s&&e===o+1&&(s=!1),r-=l,!1===s&&d++;return 0===r&&o>0&&e===o+1&&(s?s=!1:(s=!0,--e,--d)),r<0&&(r+=l,--e,--d),{year:c,month:e,day:r+1,isLeap:s,yearCycle:f,monthCycle:d,dayCycle:u}}new Array(3),w=1===m?b%4==0&&b%100!=0||b%400==0?29:28:null==i||null===($=i.lunarLib)||void 0===$?void 0:$.solarMonthArr[m];for(var C=0;CS&&(x=(g=D(new Date(b,m,n?M:null===(A=new Date)||void 0===A?void 0:A.getDate()))).year,O=g.month,y=g.day,S=(h=g.isLeap)?E(x):L(x,O),12===O&&(i.lunarLib.monthPlusOne=S))}p={lunarYear:x,lunarMonth:O,lunarDay:y,lunarLeap:h,chineseZodiac:null==i||null===(u=i.lunarLib)||void 0===u?void 0:u.AnimalsArr[(x-4)%12]};var k=null===(d=String(p.lunarYear))||void 0===d?void 0:d.split(""),T="".concat(null==i||null===(a=i.lunarLib)||void 0===a?void 0:a.chineseYear[k[0]]).concat(null==i||null===(t=i.lunarLib)||void 0===t?void 0:t.chineseYear[k[1]]).concat(null==i||null===(v=i.lunarLib)||void 0===v?void 0:v.chineseYear[k[2]]).concat(null==i||null===(c=i.lunarLib)||void 0===c?void 0:c.chineseYear[k[3]]);return{year:"".concat(T,"年"),month:"".concat(p.isLeap?"闰":"").concat(null==i||null===(f=i.lunarLib)||void 0===f?void 0:f.chineseMonth[p.lunarMonth-1],"月"),day:"".concat(function(n){var e;switch(n=null===Math||void 0===Math?void 0:Math.floor(n)){case 10:e="初十";break;case 20:e="二十";break;case 30:e="三十";break;default:e=i.lunarLib.numberToHanzi_2[null===Math||void 0===Math?void 0:Math.floor(n/10)],e+=i.lunarLib.numberToHanzi_1[n%10]}return e}(p.lunarDay)),chineseZodiac:null===(s=p)||void 0===s?void 0:s.chineseZodiac}}(n?null==n?void 0:n.replaceAll("-","/"):"".concat(null==e?void 0:e.getFullYear(),"/").concat((null==e?void 0:e.getMonth())+1,"/").concat(null==e?void 0:e.getDate()))},getPlatform:function(){var n,e;return(null==i||null===(n=i.navigator)||void 0===n||null===(n=n.userAgentData)||void 0===n?void 0:n.platform)||(null==i||null===(e=i.navigator)||void 0===e?void 0:e.platform)}},l={DeviceInfoObj:function(n){var l,r,u,d,a={deviceType:null==o?void 0:o.getDeviceType(),OS:null==o?void 0:o.getOS(),OSVersion:null==o?void 0:o.getOSVersion(),platform:null==o?void 0:o.getPlatform(),screenHeight:null==e||null===(l=e.screen)||void 0===l?void 0:l.height,screenWidth:null==e||null===(r=e.screen)||void 0===r?void 0:r.width,language:null==o?void 0:o.getLanguage(),netWork:null==o?void 0:o.getNetwork(),orientation:null==o?void 0:o.getOrientationStatu(),browserInfo:null==o?void 0:o.getBrowserInfo(),fingerprint:null==o?void 0:o.createFingerprint(n&&n.domain||""),userAgent:null==i||null===(u=i.navigator)||void 0===u?void 0:u.userAgent,geoPosition:!0,date:null==o?void 0:o.getDate(),lunarDate:null==o?void 0:o.toLunarDate(n&&n.transferDateToLunar||""),week:null==o?void 0:o.getWeek(),UUID:null==o?void 0:o.createUUID()},t={};if(n&&n.info&&0!==(null==n||null===(d=n.info)||void 0===d?void 0:d.length)){var v={},c=function(e){var i;null==n||null===(i=n.info)||void 0===i||i.forEach((function(n){var i;(null===(i=n)||void 0===i?void 0:i.toLowerCase())===(null==e?void 0:e.toLowerCase())&&(v[n=e]=null==a?void 0:a[n])}))};for(var f in a)c(f);t=v}else t=a;return new Promise((function(n){var e,i;null!==(e=t)&&void 0!==e&&e.geoPosition?null==o||null===(i=o.getGeoPostion)||void 0===i||null===(i=i.call(o))||void 0===i||null===(i=i.then((function(e){var i,o;t.geoPosition="经度:"+(null==e||null===(i=e.coords)||void 0===i?void 0:i.longitude)+" 纬度:"+(null==e||null===(o=e.coords)||void 0===o?void 0:o.latitude),n(t)})))||void 0===i||i.catch((function(e){t.geoPosition=e,n(t)})):n(t)}))}};return{Info:function(n){return null==o||o.createLoading(),new Promise((function(e){var i;null==l||null===(i=l.DeviceInfoObj(n))||void 0===i||i.then((function(n){null==o||o.removeLoading(),e(n)}))}))}}}();if("undefined"==typeof window||null===("undefined"==typeof window?"undefined":i(window))){var l,r=new(0,require("jsdom").JSDOM)("");window=null==r?void 0:r.window,document=null==r||null===(l=r.window)||void 0===l?void 0:l.document,globalThis.window=window,globalThis.document=document}window.Device=o;export{o as default}; -------------------------------------------------------------------------------- /dist/device.js: -------------------------------------------------------------------------------- 1 | !function(n,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(n="undefined"!=typeof globalThis?globalThis:n||self).Device=e()}(this,(function(){"use strict";function n(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var e={exports:{}};!function(n){function e(i){return n.exports=e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(n){return typeof n}:function(n){return n&&"function"==typeof Symbol&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},n.exports.__esModule=!0,n.exports.default=n.exports,e(i)}n.exports=e,n.exports.__esModule=!0,n.exports.default=n.exports}(e);var i=n(e.exports),o=function(){var n="undefined"!=typeof self?self:this,e=n||{},i={navigator:void 0!==(null==n?void 0:n.navigator)?null==n?void 0:n.navigator:{},infoMap:{engine:["WebKit","Trident","Gecko","Presto"],browser:["Safari","Chrome","Edge","IE","Firefox","Firefox Focus","Chromium","Opera","Vivaldi","Yandex","Arora","Lunascape","QupZilla","Coc Coc","Kindle","Iceweasel","Konqueror","Iceape","SeaMonkey","Epiphany","360","360SE","360EE","UC","QQBrowser","QQ","Baidu","Maxthon","Sogou","LBBROWSER","2345Explorer","TheWorld","XiaoMi","Quark","Qiyu","Wechat",,"WechatWork","Taobao","Alipay","Weibo","Douban","Suning","iQiYi"],os:["Windows","Linux","Mac OS","Android","Ubuntu","FreeBSD","Debian","iOS","Windows Phone","BlackBerry","MeeGo","Symbian","Chrome OS","WebOS","HarmonyOS"],device:["Mobile","Tablet","iPad"]},lunarLib:{lunarMap:[19416,19168,42352,21717,53856,55632,91476,22176,39632,21970,19168,42422,42192,53840,119381,46400,54944,44450,38320,84343,18800,42160,46261,27216,27968,109396,11104,38256,21234,18800,25958,54432,59984,28309,23248,11104,100067,37600,116951,51536,54432,120998,46416,22176,107956,9680,37584,53938,43344,46423,27808,46416,86869,19872,42448,83315,21200,43432,59728,27296,44710,43856,19296,43748,42352,21088,62051,55632,23383,22176,38608,19925,19152,42192,54484,53840,54616,46400,46496,103846,38320,18864,43380,42160,45690,27216,27968,44870,43872,38256,19189,18800,25776,29859,59984,27480,21952,43872,38613,37600,51552,55636,54432,55888,30034,22176,43959,9680,37584,51893,43344,46240,47780,44368,21977,19360,42416,86390,21168,43312,31060,27296,44368,23378,19296,42726,42208,53856,60005,54576,23200,30371,38608,19415,19152,42192,118966,53840,54560,56645,46496,22224,21938,18864,42359,42160,43600,111189,27936,44448],solarMonthArr:[31,28,31,30,31,30,31,31,30,31,30,31],AnimalsArr:["鼠","牛","虎","兔","龙","蛇","马","羊","猴","鸡","狗","猪"],numberToHanzi_1:["日","一","二","三","四","五","六","七","八","九","十"],numberToHanzi_2:["初","十","廿","卅"],chineseMonth:["正","二","三","四","五","六","七","八","九","十","冬","腊"],chineseYear:["零","一","二","三","四","五","六","七","八","九"],monthPlusOne:""}},o={createLoading:function(n,e){var i,o,l=1,r="";e&&(r='
'+l+"s
");var u="";n&&(u='
'+n+"
");var d=null===(i=document)||void 0===i?void 0:i.createElement("div");if(d.id="create_loading",d.style="display: block; position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 9999999999; text-align: center; font-size: 14px; display: flex; flex: 1; justify-content: center; flex-direction: column; align-items: center; background: rgba(0, 0, 0, 0.09);",d.innerHTML=r+'
'+u,null===(o=document)||void 0===o||null===(o=o.body)||void 0===o||o.appendChild(d),e){var a,t=null===(a=document)||void 0===a?void 0:a.getElementById("count_box");setInterval((function(){l++,t&&(t.innerHTML="
"+l+"s
")}),1e3)}},removeLoading:function(){var n,e,i=null===(n=document)||void 0===n?void 0:n.getElementById("create_loading");null===(e=document)||void 0===e||null===(e=e.body)||void 0===e||e.removeChild(i)},createUUID:function(){for(var n=[],e="0123456789abcdef",i=0;i<36;i++)n[i]=e.substr(null===Math||void 0===Math?void 0:Math.floor(16*(null===Math||void 0===Math?void 0:Math.random())),1);return n[14]="4",n[19]=e.substr(3&n[19]|8,1),n[8]=n[13]=n[18]=n[23]="-",null==n?void 0:n.join("")},getDate:function(){var n=new Date,e=null==n?void 0:n.getFullYear(),i=(null==n?void 0:n.getMonth())+1,o=null==n?void 0:n.getDate(),l=null==n?void 0:n.getHours(),r=null==n?void 0:n.getMinutes(),u=null==n?void 0:n.getSeconds();return i=i>9?i:"0"+i,o=o>9?o:"0"+o,l=l>9?l:"0"+l,r=r>9?r:"0"+r,u=u>9?u:"0"+u,"".concat(e,"/").concat(i,"/").concat(o," ").concat(l,":").concat(r,":").concat(u)},getWeek:function(){var n=new Array("周日","周一","周二","周三","周四","周五","周六"),e=new Date;return n[null==e?void 0:e.getDay()]},getMatchMap:function(n){return{Trident:(null==n?void 0:n.indexOf("Trident"))>-1||(null==n?void 0:n.indexOf("NET CLR"))>-1,Presto:(null==n?void 0:n.indexOf("Presto"))>-1,WebKit:(null==n?void 0:n.indexOf("AppleWebKit"))>-1,Gecko:(null==n?void 0:n.indexOf("Gecko/"))>-1,Safari:(null==n?void 0:n.indexOf("Safari"))>-1,Chrome:(null==n?void 0:n.indexOf("Chrome"))>-1||(null==n?void 0:n.indexOf("CriOS"))>-1,IE:(null==n?void 0:n.indexOf("MSIE"))>-1||(null==n?void 0:n.indexOf("Trident"))>-1,Edge:(null==n?void 0:n.indexOf("Edge"))>-1,Firefox:(null==n?void 0:n.indexOf("Firefox"))>-1||(null==n?void 0:n.indexOf("FxiOS"))>-1,"Firefox Focus":(null==n?void 0:n.indexOf("Focus"))>-1,Chromium:(null==n?void 0:n.indexOf("Chromium"))>-1,Opera:(null==n?void 0:n.indexOf("Opera"))>-1||(null==n?void 0:n.indexOf("OPR"))>-1,Vivaldi:(null==n?void 0:n.indexOf("Vivaldi"))>-1,Yandex:(null==n?void 0:n.indexOf("YaBrowser"))>-1,Arora:(null==n?void 0:n.indexOf("Arora"))>-1,Lunascape:(null==n?void 0:n.indexOf("Lunascape"))>-1,QupZilla:(null==n?void 0:n.indexOf("QupZilla"))>-1,"Coc Coc":(null==n?void 0:n.indexOf("coc_coc_browser"))>-1,Kindle:(null==n?void 0:n.indexOf("Kindle"))>-1||(null==n?void 0:n.indexOf("Silk/"))>-1,Iceweasel:(null==n?void 0:n.indexOf("Iceweasel"))>-1,Konqueror:(null==n?void 0:n.indexOf("Konqueror"))>-1,Iceape:(null==n?void 0:n.indexOf("Iceape"))>-1,SeaMonkey:(null==n?void 0:n.indexOf("SeaMonkey"))>-1,Epiphany:(null==n?void 0:n.indexOf("Epiphany"))>-1,360:(null==n?void 0:n.indexOf("QihooBrowser"))>-1||(null==n?void 0:n.indexOf("QHBrowser"))>-1,"360EE":(null==n?void 0:n.indexOf("360EE"))>-1,"360SE":(null==n?void 0:n.indexOf("360SE"))>-1,UC:(null==n?void 0:n.indexOf("UC"))>-1||(null==n?void 0:n.indexOf(" UBrowser"))>-1,QQBrowser:(null==n?void 0:n.indexOf("QQBrowser"))>-1,QQ:(null==n?void 0:n.indexOf("QQ/"))>-1,Baidu:(null==n?void 0:n.indexOf("Baidu"))>-1||(null==n?void 0:n.indexOf("BIDUBrowser"))>-1,Maxthon:(null==n?void 0:n.indexOf("Maxthon"))>-1,Sogou:(null==n?void 0:n.indexOf("MetaSr"))>-1||(null==n?void 0:n.indexOf("Sogou"))>-1,LBBROWSER:(null==n?void 0:n.indexOf("LBBROWSER"))>-1||(null==n?void 0:n.indexOf("LieBaoFast"))>-1,"2345Explorer":(null==n?void 0:n.indexOf("2345Explorer"))>-1,TheWorld:(null==n?void 0:n.indexOf("TheWorld"))>-1,XiaoMi:(null==n?void 0:n.indexOf("MiuiBrowser"))>-1,Quark:(null==n?void 0:n.indexOf("Quark"))>-1,Qiyu:(null==n?void 0:n.indexOf("Qiyu"))>-1,Wechat:(null==n?void 0:n.indexOf("MicroMessenger"))>-1,WechatWork:(null==n?void 0:n.indexOf("wxwork/"))>-1,Taobao:(null==n?void 0:n.indexOf("AliApp(TB"))>-1,Alipay:(null==n?void 0:n.indexOf("AliApp(AP"))>-1,Weibo:(null==n?void 0:n.indexOf("Weibo"))>-1,Douban:(null==n?void 0:n.indexOf("com.douban.frodo"))>-1,Suning:(null==n?void 0:n.indexOf("SNEBUY-APP"))>-1,iQiYi:(null==n?void 0:n.indexOf("IqiyiApp"))>-1,DingTalk:(null==n?void 0:n.indexOf("DingTalk"))>-1,Vivo:(null==n?void 0:n.indexOf("VivoBrowser"))>-1,Huawei:(null==n?void 0:n.indexOf("HuaweiBrowser"))>-1||(null==n?void 0:n.indexOf("HUAWEI/"))>-1||(null==n?void 0:n.indexOf("HONOR"))>-1||(null==n?void 0:n.indexOf("HBPC/"))>-1,Windows:(null==n?void 0:n.indexOf("Windows"))>-1,Linux:(null==n?void 0:n.indexOf("Linux"))>-1||(null==n?void 0:n.indexOf("X11"))>-1,"Mac OS":(null==n?void 0:n.indexOf("Macintosh"))>-1,Android:(null==n?void 0:n.indexOf("Android"))>-1||(null==n?void 0:n.indexOf("Adr"))>-1,Ubuntu:(null==n?void 0:n.indexOf("Ubuntu"))>-1,FreeBSD:(null==n?void 0:n.indexOf("FreeBSD"))>-1,Debian:(null==n?void 0:n.indexOf("Debian"))>-1,"Windows Phone":(null==n?void 0:n.indexOf("IEMobile"))>-1||(null==n?void 0:n.indexOf("Windows Phone"))>-1,BlackBerry:(null==n?void 0:n.indexOf("BlackBerry"))>-1||(null==n?void 0:n.indexOf("RIM"))>-1,MeeGo:(null==n?void 0:n.indexOf("MeeGo"))>-1,Symbian:(null==n?void 0:n.indexOf("Symbian"))>-1,iOS:(null==n?void 0:n.indexOf("like Mac OS X"))>-1,"Chrome OS":(null==n?void 0:n.indexOf("CrOS"))>-1,WebOS:(null==n?void 0:n.indexOf("hpwOS"))>-1,HarmonyOS:(null==n?void 0:n.indexOf("HarmonyOS"))>-1,Mobile:(null==n?void 0:n.indexOf("Mobi"))>-1||(null==n?void 0:n.indexOf("iPh"))>-1||(null==n?void 0:n.indexOf("480"))>-1,Tablet:(null==n?void 0:n.indexOf("Tablet"))>-1||(null==n?void 0:n.indexOf("Nexus 7"))>-1,iPad:(null==n?void 0:n.indexOf("iPad"))>-1}},matchInfoMap:function(n){var e,l=(null==i||null===(e=i.navigator)||void 0===e?void 0:e.userAgent)||{},r=null==o?void 0:o.getMatchMap(l);for(var u in null==i?void 0:i.infoMap)for(var d=0;d<(null==i||null===(a=i.infoMap)||void 0===a||null===(a=a[u])||void 0===a?void 0:a.length);d++){var a,t,v=null==i||null===(t=i.infoMap)||void 0===t||null===(t=t[u])||void 0===t?void 0:t[d];r[v]&&(n[u]=v)}},getOS:function(){return null==o||o.matchInfoMap(this),this.os},getOSVersion:function(){var n,e=this,o=(null==i||null===(n=i.navigator)||void 0===n?void 0:n.userAgent)||{};e.osVersion="";var l,r={Windows:function(){var n=null==o?void 0:o.replace(/^.*Windows NT ([\d.]+);.*$/,"$1");return{10:"10 || 11",6.3:"8.1",6.2:"8",6.1:"7","6.0":"Vista",5.2:"XP 64-Bit",5.1:"XP","5.0":"2000","4.0":"NT 4.0","3.5.1":"NT 3.5.1",3.5:"NT 3.5",3.1:"NT 3.1"}[n]||n},Android:function(){return null==o?void 0:o.replace(/^.*Android ([\d.]+);.*$/,"$1")},iOS:function(){var n;return null==o||null===(n=o.replace(/^.*OS ([\d_]+) like.*$/,"$1"))||void 0===n?void 0:n.replace(/_/g,".")},Debian:function(){return null==o?void 0:o.replace(/^.*Debian\/([\d.]+).*$/,"$1")},"Windows Phone":function(){return null==o?void 0:o.replace(/^.*Windows Phone( OS)? ([\d.]+);.*$/,"$2")},"Mac OS":function(){var n;return null==o||null===(n=o.replace(/^.*Mac OS X ([\d_]+).*$/,"$1"))||void 0===n?void 0:n.replace(/_/g,".")},WebOS:function(){return null==o?void 0:o.replace(/^.*hpwOS\/([\d.]+);.*$/,"$1")}};return r[e.os]&&(e.osVersion=null==r||null===(l=r[e.os])||void 0===l?void 0:l.call(r),e.osVersion==o&&(e.osVersion="")),e.osVersion},getOrientationStatu:function(){var n,e=null===(n=window)||void 0===n?void 0:n.matchMedia("(orientation: portrait)");return null!=e&&e.matches?"竖屏":"横屏"},getDeviceType:function(){var n=this;return n.device="PC",null==o||o.matchInfoMap(n),n.device},getNetwork:function(){var n,e,i=null===(n=navigator)||void 0===n||null===(n=n.connection)||void 0===n?void 0:n.effectiveType;return(null===(e=navigator)||void 0===e?void 0:e.onLine)?i||"网络状态获取失败":"离线"},getLanguage:function(){return this.language=(l=(null==i||null===(n=i.navigator)||void 0===n?void 0:n.browserLanguage)||(null==i||null===(e=i.navigator)||void 0===e?void 0:e.language),(r=null==l?void 0:l.split("-"))[1]&&(r[1]=null==r||null===(o=r[1])||void 0===o?void 0:o.toUpperCase()),null==r?void 0:r.join("_")),this.language;var n,e,o,l,r},createFingerprint:function(n){var e,i,o,l=null===(e=document)||void 0===e?void 0:e.createElement("canvas"),r=null==l?void 0:l.getContext("2d"),u=n||(null===(i=window)||void 0===i||null===(i=i.location)||void 0===i?void 0:i.host);r.textBaseline="top",r.font="14px 'Arial'",r.textBaseline="tencent",r.fillStyle="#f60",r.fillRect(125,1,62,20),r.fillStyle="#069",r.fillText(u,2,15),r.fillStyle="rgba(102, 204, 0, 0.7)",r.fillText(u,4,17);var d=null==l||null===(o=l.toDataURL())||void 0===o?void 0:o.replace("data:image/png;base64,",""),a=atob(d);return function(n){var e,i,o,l="";for(e=0,i=(n+="").length;e36&&e.showModalDialog?v=!0:c>45&&(v=a("type","application/vnd.chromium.remoting-viewer"))}if(t.Baidu&&t.Opera&&(t.Baidu=!1),t.Mobile&&(t.Mobile=!((null==d?void 0:d.indexOf("iPad"))>-1)),v&&(a("type","application/gameplugin")||null!=i&&i.navigator&&void 0===(null==i?void 0:i.navigator.connection.saveData)?t["360SE"]=!0:t["360EE"]=!0),t.IE||t.Edge)switch((null===(r=window)||void 0===r?void 0:r.screenTop)-(null===(u=window)||void 0===u?void 0:u.screenY)){case 71:case 74:case 99:case 75:case 74:case 105:break;case 102:t["360EE"]=!0;break;case 104:t["360SE"]=!0}var f,s={Safari:function(){return null==d?void 0:d.replace(/^.*Version\/([\d.]+).*$/,"$1")},Chrome:function(){var n;return null==d||null===(n=d.replace(/^.*Chrome\/([\d.]+).*$/,"$1"))||void 0===n?void 0:n.replace(/^.*CriOS\/([\d.]+).*$/,"$1")},IE:function(){var n;return null==d||null===(n=d.replace(/^.*MSIE ([\d.]+).*$/,"$1"))||void 0===n?void 0:n.replace(/^.*rv:([\d.]+).*$/,"$1")},Edge:function(){return null==d?void 0:d.replace(/^.*Edge\/([\d.]+).*$/,"$1")},Firefox:function(){var n;return null==d||null===(n=d.replace(/^.*Firefox\/([\d.]+).*$/,"$1"))||void 0===n?void 0:n.replace(/^.*FxiOS\/([\d.]+).*$/,"$1")},"Firefox Focus":function(){return null==d?void 0:d.replace(/^.*Focus\/([\d.]+).*$/,"$1")},Chromium:function(){return null==d?void 0:d.replace(/^.*Chromium\/([\d.]+).*$/,"$1")},Opera:function(){var n;return null==d||null===(n=d.replace(/^.*Opera\/([\d.]+).*$/,"$1"))||void 0===n?void 0:n.replace(/^.*OPR\/([\d.]+).*$/,"$1")},Vivaldi:function(){return null==d?void 0:d.replace(/^.*Vivaldi\/([\d.]+).*$/,"$1")},Yandex:function(){return null==d?void 0:d.replace(/^.*YaBrowser\/([\d.]+).*$/,"$1")},Arora:function(){return null==d?void 0:d.replace(/^.*Arora\/([\d.]+).*$/,"$1")},Lunascape:function(){return null==d?void 0:d.replace(/^.*Lunascape[\/\s]([\d.]+).*$/,"$1")},QupZilla:function(){return null==d?void 0:d.replace(/^.*QupZilla[\/\s]([\d.]+).*$/,"$1")},"Coc Coc":function(){return null==d?void 0:d.replace(/^.*coc_coc_browser\/([\d.]+).*$/,"$1")},Kindle:function(){return null==d?void 0:d.replace(/^.*Version\/([\d.]+).*$/,"$1")},Iceweasel:function(){return null==d?void 0:d.replace(/^.*Iceweasel\/([\d.]+).*$/,"$1")},Konqueror:function(){return null==d?void 0:d.replace(/^.*Konqueror\/([\d.]+).*$/,"$1")},Iceape:function(){return null==d?void 0:d.replace(/^.*Iceape\/([\d.]+).*$/,"$1")},SeaMonkey:function(){return null==d?void 0:d.replace(/^.*SeaMonkey\/([\d.]+).*$/,"$1")},Epiphany:function(){return null==d?void 0:d.replace(/^.*Epiphany\/([\d.]+).*$/,"$1")},360:function(){return null==d?void 0:d.replace(/^.*QihooBrowser\/([\d.]+).*$/,"$1")},"360SE":function(){return{63:"10.0",55:"9.1",45:"8.1",42:"8.0",31:"7.0",21:"6.3"}[null==d?void 0:d.replace(/^.*Chrome\/([\d]+).*$/,"$1")]||""},"360EE":function(){return{69:"11.0",63:"9.5",55:"9.0",50:"8.7",30:"7.5"}[null==d?void 0:d.replace(/^.*Chrome\/([\d]+).*$/,"$1")]||""},Maxthon:function(){return null==d?void 0:d.replace(/^.*Maxthon\/([\d.]+).*$/,"$1")},QQBrowser:function(){return null==d?void 0:d.replace(/^.*QQBrowser\/([\d.]+).*$/,"$1")},QQ:function(){return null==d?void 0:d.replace(/^.*QQ\/([\d.]+).*$/,"$1")},Baidu:function(){return null==d?void 0:d.replace(/^.*BIDUBrowser[\s\/]([\d.]+).*$/,"$1")},UC:function(){return null==d?void 0:d.replace(/^.*UC?Browser\/([\d.]+).*$/,"$1")},Sogou:function(){var n;return null==d||null===(n=d.replace(/^.*SE ([\d.X]+).*$/,"$1"))||void 0===n?void 0:n.replace(/^.*SogouMobileBrowser\/([\d.]+).*$/,"$1")},Liebao:function(){var n="";(null==d?void 0:d.indexOf("LieBaoFast"))>-1&&(n=null==d?void 0:d.replace(/^.*LieBaoFast\/([\d.]+).*$/,"$1"));var e=null==d?void 0:d.replace(/^.*Chrome\/([\d]+).*$/,"$1");return n||{57:"6.5",49:"6.0",46:"5.9",42:"5.3",39:"5.2",34:"5.0",29:"4.5",21:"4.0"}[e]||""},LBBROWSER:function(){var n="";(null==d?void 0:d.indexOf("LieBaoFast"))>-1&&(n=null==d?void 0:d.replace(/^.*LieBaoFast\/([\d.]+).*$/,"$1"));var e=null==d?void 0:d.replace(/^.*Chrome\/([\d]+).*$/,"$1");return n||{57:"6.5",49:"6.0",46:"5.9",42:"5.3",39:"5.2",34:"5.0",29:"4.5",21:"4.0"}[e]||""},"2345Explorer":function(){return null==d?void 0:d.replace(/^.*2345Explorer\/([\d.]+).*$/,"$1")},"115Browser":function(){return null==d?void 0:d.replace(/^.*115Browser\/([\d.]+).*$/,"$1")},TheWorld:function(){return null==d?void 0:d.replace(/^.*TheWorld ([\d.]+).*$/,"$1")},XiaoMi:function(){return null==d?void 0:d.replace(/^.*MiuiBrowser\/([\d.]+).*$/,"$1")},Vivo:function(){return null==d?void 0:d.replace(/^.*VivoBrowser\/([\d.]+).*$/,"$1")},Quark:function(){return null==d?void 0:d.replace(/^.*Quark\/([\d.]+).*$/,"$1")},Qiyu:function(){return null==d?void 0:d.replace(/^.*Qiyu\/([\d.]+).*$/,"$1")},Wechat:function(){return null==d?void 0:d.replace(/^.*MicroMessenger\/([\d.]+).*$/,"$1")},WechatWork:function(){return null==d?void 0:d.replace(/^.*wxwork\/([\d.]+).*$/,"$1")},Taobao:function(){return null==d?void 0:d.replace(/^.*AliApp\(TB\/([\d.]+).*$/,"$1")},Alipay:function(){return null==d?void 0:d.replace(/^.*AliApp\(AP\/([\d.]+).*$/,"$1")},Weibo:function(){return null==d?void 0:d.replace(/^.*weibo__([\d.]+).*$/,"$1")},Douban:function(){return null==d?void 0:d.replace(/^.*com.douban.frodo\/([\d.]+).*$/,"$1")},Suning:function(){return null==d?void 0:d.replace(/^.*SNEBUY-APP([\d.]+).*$/,"$1")},iQiYi:function(){return null==d?void 0:d.replace(/^.*IqiyiVersion\/([\d.]+).*$/,"$1")},DingTalk:function(){return null==d?void 0:d.replace(/^.*DingTalk\/([\d.]+).*$/,"$1")},Huawei:function(){var n;return null==d||null===(n=d.replace(/^.*Version\/([\d.]+).*$/,"$1"))||void 0===n||null===(n=n.replace(/^.*HuaweiBrowser\/([\d.]+).*$/,"$1"))||void 0===n?void 0:n.replace(/^.*HBPC\/([\d.]+).*$/,"$1")}};return l.browserVersion="",s[l.browser]&&(l.browserVersion=null==s||null===(f=s[l.browser])||void 0===f?void 0:f.call(s),l.browserVersion==d&&(l.browserVersion="")),"Chrome"==l.browser&&null!=d&&d.match(/\S+Browser/)&&(l.browser=null==d?void 0:d.match(/\S+Browser/)[0],l.version=null==d?void 0:d.replace(/^.*Browser\/([\d.]+).*$/,"$1")),"Edge"==l.browser&&(l.version>"75"?l.engine="Blink":l.engine="EdgeHTML"),("Chrome"==l.browser&&parseInt(l.browserVersion)>27||t.Chrome&&"WebKit"==l.engine&&parseInt(s.Chrome())>27||"Opera"==l.browser&&parseInt(l.version)>12||"Yandex"==l.browser)&&(l.engine="Blink"),l.browser+"(版本: "+l.browserVersion+"  内核: "+l.engine+")"},getGeoPostion:function(){return new Promise((function(n,e){var i,o;null!==(i=navigator)&&void 0!==i&&i.geolocation?null===(o=navigator)||void 0===o||null===(o=o.geolocation)||void 0===o||o.getCurrentPosition((function(e){n(e)}),(function(e){n({coords:{longitude:"获取失败",latitude:"获取失败"}})}),{enableHighAccuracy:!1,timeout:1e4}):e("当前浏览器不支持获取地理位置")}))},toLunarDate:function(n){var e=new Date;return function(e){var o,l,r,u,d,a,t,v,c,f,s,p,g,x,h,O,w,$,b=null===(o=new Date(e))||void 0===o?void 0:o.getFullYear(),m=null===(l=new Date(e))||void 0===l?void 0:l.getMonth(),y=null===(r=new Date(e))||void 0===r?void 0:r.getDate(),M=1,S=0;function B(n){var e;return 15&(null==i||null===(e=i.lunarLib)||void 0===e||null===(e=e.lunarMap)||void 0===e?void 0:e[n-1900])}function E(n){var e;return B(n)?65536&(null==i||null===(e=i.lunarLib)||void 0===e||null===(e=e.lunarMap)||void 0===e?void 0:e[n-1900])?30:29:0}function L(n,e){var o;return(null==i||null===(o=i.lunarLib)||void 0===o||null===(o=o.lunarMap)||void 0===o?void 0:o[n-1900])&65536>>e?30:29}function D(n){var e,o,l=0,r=(n-new Date(1900,0,31))/864e5,u=r+40,d=14;for(e=1900;e<2050&&r>0;e++){for(var a=348,t=32768;t>8;t>>=1){var v;a+=(null==i||null===(v=i.lunarLib)||void 0===v?void 0:v.lunarMap[e-1900])&t?1:0}r-=l=a+E(e),d+=12}r<0&&(r+=l,e--,d-=12);var c=e,f=e-1864;o=B(e);var s=!1;for(e=1;e<13&&r>0;e++)o>0&&e===o+1&&!1===s?(--e,s=!0,l=E(c)):l=L(c,e),!0===s&&e===o+1&&(s=!1),r-=l,!1===s&&d++;return 0===r&&o>0&&e===o+1&&(s?s=!1:(s=!0,--e,--d)),r<0&&(r+=l,--e,--d),{year:c,month:e,day:r+1,isLeap:s,yearCycle:f,monthCycle:d,dayCycle:u}}new Array(3),w=1===m?b%4==0&&b%100!=0||b%400==0?29:28:null==i||null===($=i.lunarLib)||void 0===$?void 0:$.solarMonthArr[m];for(var C=0;CS&&(x=(g=D(new Date(b,m,n?y:null===(A=new Date)||void 0===A?void 0:A.getDate()))).year,h=g.month,M=g.day,S=(O=g.isLeap)?E(x):L(x,h),12===h&&(i.lunarLib.monthPlusOne=S))}p={lunarYear:x,lunarMonth:h,lunarDay:M,lunarLeap:O,chineseZodiac:null==i||null===(u=i.lunarLib)||void 0===u?void 0:u.AnimalsArr[(x-4)%12]};var T=null===(d=String(p.lunarYear))||void 0===d?void 0:d.split(""),k="".concat(null==i||null===(a=i.lunarLib)||void 0===a?void 0:a.chineseYear[T[0]]).concat(null==i||null===(t=i.lunarLib)||void 0===t?void 0:t.chineseYear[T[1]]).concat(null==i||null===(v=i.lunarLib)||void 0===v?void 0:v.chineseYear[T[2]]).concat(null==i||null===(c=i.lunarLib)||void 0===c?void 0:c.chineseYear[T[3]]);return{year:"".concat(k,"年"),month:"".concat(p.isLeap?"闰":"").concat(null==i||null===(f=i.lunarLib)||void 0===f?void 0:f.chineseMonth[p.lunarMonth-1],"月"),day:"".concat(function(n){var e;switch(n=null===Math||void 0===Math?void 0:Math.floor(n)){case 10:e="初十";break;case 20:e="二十";break;case 30:e="三十";break;default:e=i.lunarLib.numberToHanzi_2[null===Math||void 0===Math?void 0:Math.floor(n/10)],e+=i.lunarLib.numberToHanzi_1[n%10]}return e}(p.lunarDay)),chineseZodiac:null===(s=p)||void 0===s?void 0:s.chineseZodiac}}(n?null==n?void 0:n.replaceAll("-","/"):"".concat(null==e?void 0:e.getFullYear(),"/").concat((null==e?void 0:e.getMonth())+1,"/").concat(null==e?void 0:e.getDate()))},getPlatform:function(){var n,e;return(null==i||null===(n=i.navigator)||void 0===n||null===(n=n.userAgentData)||void 0===n?void 0:n.platform)||(null==i||null===(e=i.navigator)||void 0===e?void 0:e.platform)}},l={DeviceInfoObj:function(n){var l,r,u,d,a={deviceType:null==o?void 0:o.getDeviceType(),OS:null==o?void 0:o.getOS(),OSVersion:null==o?void 0:o.getOSVersion(),platform:null==o?void 0:o.getPlatform(),screenHeight:null==e||null===(l=e.screen)||void 0===l?void 0:l.height,screenWidth:null==e||null===(r=e.screen)||void 0===r?void 0:r.width,language:null==o?void 0:o.getLanguage(),netWork:null==o?void 0:o.getNetwork(),orientation:null==o?void 0:o.getOrientationStatu(),browserInfo:null==o?void 0:o.getBrowserInfo(),fingerprint:null==o?void 0:o.createFingerprint(n&&n.domain||""),userAgent:null==i||null===(u=i.navigator)||void 0===u?void 0:u.userAgent,geoPosition:!0,date:null==o?void 0:o.getDate(),lunarDate:null==o?void 0:o.toLunarDate(n&&n.transferDateToLunar||""),week:null==o?void 0:o.getWeek(),UUID:null==o?void 0:o.createUUID()},t={};if(n&&n.info&&0!==(null==n||null===(d=n.info)||void 0===d?void 0:d.length)){var v={},c=function(e){var i;null==n||null===(i=n.info)||void 0===i||i.forEach((function(n){var i;(null===(i=n)||void 0===i?void 0:i.toLowerCase())===(null==e?void 0:e.toLowerCase())&&(v[n=e]=null==a?void 0:a[n])}))};for(var f in a)c(f);t=v}else t=a;return new Promise((function(n){var e,i;null!==(e=t)&&void 0!==e&&e.geoPosition?null==o||null===(i=o.getGeoPostion)||void 0===i||null===(i=i.call(o))||void 0===i||null===(i=i.then((function(e){var i,o;t.geoPosition="经度:"+(null==e||null===(i=e.coords)||void 0===i?void 0:i.longitude)+" 纬度:"+(null==e||null===(o=e.coords)||void 0===o?void 0:o.latitude),n(t)})))||void 0===i||i.catch((function(e){t.geoPosition=e,n(t)})):n(t)}))}};return{Info:function(n){return null==o||o.createLoading(),new Promise((function(e){var i;null==l||null===(i=l.DeviceInfoObj(n))||void 0===i||i.then((function(n){null==o||o.removeLoading(),e(n)}))}))}}}();if("undefined"==typeof window||null===("undefined"==typeof window?"undefined":i(window))){var l,r=new(0,require("jsdom").JSDOM)("");window=null==r?void 0:r.window,document=null==r||null===(l=r.window)||void 0===l?void 0:l.document,globalThis.window=window,globalThis.document=document}return window.Device=o,o})); -------------------------------------------------------------------------------- /src/device.js: -------------------------------------------------------------------------------- 1 | const Device = (function () { 2 | const root = typeof self !== 'undefined' ? self : this 3 | const _window = root || {} 4 | // 变量库 5 | const VariableLibrary = { 6 | navigator: typeof root?.navigator != 'undefined' ? root?.navigator : {}, 7 | // 信息map 8 | infoMap: { 9 | engine: ['WebKit', 'Trident', 'Gecko', 'Presto'], 10 | browser: [ 11 | 'Safari', 12 | 'Chrome', 13 | 'Edge', 14 | 'IE', 15 | 'Firefox', 16 | 'Firefox Focus', 17 | 'Chromium', 18 | 'Opera', 19 | 'Vivaldi', 20 | 'Yandex', 21 | 'Arora', 22 | 'Lunascape', 23 | 'QupZilla', 24 | 'Coc Coc', 25 | 'Kindle', 26 | 'Iceweasel', 27 | 'Konqueror', 28 | 'Iceape', 29 | 'SeaMonkey', 30 | 'Epiphany', 31 | '360', 32 | '360SE', 33 | '360EE', 34 | 'UC', 35 | 'QQBrowser', 36 | 'QQ', 37 | 'Baidu', 38 | 'Maxthon', 39 | 'Sogou', 40 | 'LBBROWSER', 41 | '2345Explorer', 42 | 'TheWorld', 43 | 'XiaoMi', 44 | 'Quark', 45 | 'Qiyu', 46 | 'Wechat', , 47 | 'WechatWork', 48 | 'Taobao', 49 | 'Alipay', 50 | 'Weibo', 51 | 'Douban', 52 | 'Suning', 53 | 'iQiYi' 54 | ], 55 | os: [ 56 | 'Windows', 57 | 'Linux', 58 | 'Mac OS', 59 | 'Android', 60 | 'Ubuntu', 61 | 'FreeBSD', 62 | 'Debian', 63 | 'iOS', 64 | 'Windows Phone', 65 | 'BlackBerry', 66 | 'MeeGo', 67 | 'Symbian', 68 | 'Chrome OS', 69 | 'WebOS', 70 | 'HarmonyOS' 71 | ], 72 | device: ['Mobile', 'Tablet', 'iPad'] 73 | }, 74 | // 农历相关 75 | lunarLib: { 76 | /* 77 | * 农历1900-2100的润大小信息表 78 | * 0x代表十六进制,后面的是十六进制数 79 | * 例:1980年的数据是:0x095b0 80 | 二进制:0000 1001 0101 1011 0000 81 | | ------------------------------- | 82 | | 0000 | 1001 0101 1011 | 0000 | 83 | | ------------------------------- | 84 | | 1~4 | 5~16 | 17~20 | 85 | | ------------------------------- | 86 | 1-4: 表示当年有无闰年,有的话,为闰月的月份,没有的话,为0。 87 | 5-16:为除了闰月外的正常月份是大月还是小月,1为30天,0为29天。 88 | 17-20:表示闰月是大月还是小月,仅当存在闰月的情况下有意义。 89 | 表示1980年没有闰月,从1月到12月的天数依次为:30、29、29、30、29、30、29、30、30、29、30、30。 90 | */ 91 | lunarMap: [ 92 | 0x04bd8, 0x04ae0, 0x0a570, 0x054d5, 0x0d260, 0x0d950, 0x16554, 0x056a0, 0x09ad0, 0x055d2, // 1900-1909 93 | 0x04ae0, 0x0a5b6, 0x0a4d0, 0x0d250, 0x1d255, 0x0b540, 0x0d6a0, 0x0ada2, 0x095b0, 0x14977, // 1910-1919 94 | 0x04970, 0x0a4b0, 0x0b4b5, 0x06a50, 0x06d40, 0x1ab54, 0x02b60, 0x09570, 0x052f2, 0x04970, // 1920-1929 95 | 0x06566, 0x0d4a0, 0x0ea50, 0x06e95, 0x05ad0, 0x02b60, 0x186e3, 0x092e0, 0x1c8d7, 0x0c950, // 1930-1939 96 | 0x0d4a0, 0x1d8a6, 0x0b550, 0x056a0, 0x1a5b4, 0x025d0, 0x092d0, 0x0d2b2, 0x0a950, 0x0b557, // 1940-1949 97 | 0x06ca0, 0x0b550, 0x15355, 0x04da0, 0x0a5d0, 0x14573, 0x052d0, 0x0a9a8, 0x0e950, 0x06aa0, // 1950-1959 98 | 0x0aea6, 0x0ab50, 0x04b60, 0x0aae4, 0x0a570, 0x05260, 0x0f263, 0x0d950, 0x05b57, 0x056a0, // 1960-1969 99 | 0x096d0, 0x04dd5, 0x04ad0, 0x0a4d0, 0x0d4d4, 0x0d250, 0x0d558, 0x0b540, 0x0b5a0, 0x195a6, // 1970-1979 100 | 0x095b0, 0x049b0, 0x0a974, 0x0a4b0, 0x0b27a, 0x06a50, 0x06d40, 0x0af46, 0x0ab60, 0x09570, // 1980-1989 101 | 0x04af5, 0x04970, 0x064b0, 0x074a3, 0x0ea50, 0x06b58, 0x055c0, 0x0ab60, 0x096d5, 0x092e0, // 1990-1999 102 | 0x0c960, 0x0d954, 0x0d4a0, 0x0da50, 0x07552, 0x056a0, 0x0abb7, 0x025d0, 0x092d0, 0x0cab5, // 2000-2009 103 | 0x0a950, 0x0b4a0, 0x0baa4, 0x0ad50, 0x055d9, 0x04ba0, 0x0a5b0, 0x15176, 0x052b0, 0x0a930, // 2010-2019 104 | 0x07954, 0x06aa0, 0x0ad50, 0x05b52, 0x04b60, 0x0a6e6, 0x0a4e0, 0x0d260, 0x0ea65, 0x0d530, // 2020-2029 105 | 0x05aa0, 0x076a3, 0x096d0, 0x04bd7, 0x04ad0, 0x0a4d0, 0x1d0b6, 0x0d250, 0x0d520, 0x0dd45, // 2030-2039 106 | 0x0b5a0, 0x056d0, 0x055b2, 0x049b0, 0x0a577, 0x0a4b0, 0x0aa50, 0x1b255, 0x06d20, 0x0ada0 // 2040-2049 107 | ], 108 | // 阳历每个月的天数普通表 109 | solarMonthArr: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], 110 | // 十二生肖 111 | AnimalsArr: ["鼠", "牛", "虎", "兔", "龙", "蛇", "马", "羊", "猴", "鸡", "狗", "猪"], 112 | // 数字转汉字表1 113 | numberToHanzi_1: ['日', '一', '二', '三', '四', '五', '六', '七', '八', '九', '十'], 114 | // 数字转汉字表2 115 | numberToHanzi_2: ['初', '十', '廿', '卅'], 116 | // 中文月份 117 | chineseMonth: ['正', '二', '三', '四', '五', '六', '七', '八', '九', '十', '冬', '腊'], 118 | // 中文年份 119 | chineseYear: ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九'], 120 | monthPlusOne: '', // 保存y年m+1月的相关信息 121 | } 122 | } 123 | // 方法库 124 | const MethodLibrary = (function () { 125 | return { 126 | /** 127 | * 创建loading 128 | */ 129 | createLoading: function (text, showTimeCount) { 130 | let count = 1 131 | let timeCountStr = '' 132 | if (showTimeCount) { 133 | timeCountStr = 134 | '
' + 146 | '
' + count + 's
' + 147 | '
' 148 | } 149 | let textStr = '' 150 | if (text) { 151 | textStr = '
' + 152 | text + 153 | '
' 154 | } 155 | 156 | let loading = document?.createElement('div') 157 | loading.id = 'create_loading' 158 | loading.style = 'display: block;' + 159 | ' position: fixed;' + 160 | ' top: 0;' + 161 | ' left: 0;' + 162 | ' width: 100%;' + 163 | ' height: 100%;' + 164 | ' z-index: 9999999999;' + 165 | ' text-align: center;' + 166 | ' font-size: 14px;' + 167 | ' display: flex;' + 168 | ' flex: 1;' + 169 | ' justify-content: center;' + 170 | ' flex-direction: column;' + 171 | ' align-items: center;' + 172 | ' background: rgba(0, 0, 0, 0.09);' 173 | loading.innerHTML = 174 | timeCountStr + 175 | '
' + 176 | '
' + 177 | '
' + 178 | '
' + 179 | '
' + 180 | textStr 181 | document?.body?.appendChild(loading) 182 | 183 | if (showTimeCount) { 184 | let countBox = document?.getElementById('count_box') 185 | setInterval(function () { 186 | count++ 187 | if (countBox) { 188 | countBox.innerHTML = '
' + count + 's
' 189 | } 190 | }, 1000) 191 | } 192 | }, 193 | /** 194 | * 删除loading 195 | */ 196 | removeLoading: function () { 197 | let loading = document?.getElementById('create_loading') 198 | document?.body?.removeChild(loading) 199 | }, 200 | // 生成UUID通用唯一标识码 201 | createUUID: function () { 202 | let result = [] 203 | let hexDigits = "0123456789abcdef" 204 | for (let i = 0; i < 36; i++) { 205 | result[i] = hexDigits?.substr(Math?.floor(Math?.random() * 0x10), 1) 206 | } 207 | // bits 12-15 of the time_hi_and_version field to 0010 208 | result[14] = "4" 209 | // bits 6-7 of the clock_seq_hi_and_reserved to 01 210 | result[19] = hexDigits?.substr((result[19] & 0x3) | 0x8, 1) 211 | result[8] = result[13] = result[18] = result[23] = "-" 212 | return result?.join("") 213 | }, 214 | // 获取阳历日期时间 215 | getDate: function () { 216 | let date = new Date() 217 | let year = date?.getFullYear() 218 | let month = date?.getMonth() + 1 219 | let day = date?.getDate() 220 | let hour = date?.getHours() 221 | let minutes = date?.getMinutes() 222 | let seconds = date?.getSeconds() 223 | month = month > 9 ? month : "0" + month 224 | day = day > 9 ? day : "0" + day 225 | hour = hour > 9 ? hour : "0" + hour 226 | minutes = minutes > 9 ? minutes : "0" + minutes 227 | seconds = seconds > 9 ? seconds : "0" + seconds 228 | return `${year}/${month}/${day} ${hour}:${minutes}:${seconds}` 229 | }, 230 | // 获取当前周几 231 | getWeek: function () { 232 | let show_week = new Array('周日', '周一', '周二', '周三', '周四', '周五', '周六') 233 | let time = new Date() 234 | let day = time?.getDay() 235 | let now_week = show_week[day] 236 | return now_week 237 | }, 238 | // 获取匹配库 239 | getMatchMap: function (u) { 240 | return { 241 | // 内核 242 | 'Trident': u?.indexOf('Trident') > -1 || u?.indexOf('NET CLR') > -1, 243 | 'Presto': u?.indexOf('Presto') > -1, 244 | 'WebKit': u?.indexOf('AppleWebKit') > -1, 245 | 'Gecko': u?.indexOf('Gecko/') > -1, 246 | // 浏览器 247 | 'Safari': u?.indexOf('Safari') > -1, 248 | 'Chrome': u?.indexOf('Chrome') > -1 || u?.indexOf('CriOS') > -1, 249 | 'IE': u?.indexOf('MSIE') > -1 || u?.indexOf('Trident') > -1, 250 | 'Edge': u?.indexOf('Edge') > -1, 251 | 'Firefox': u?.indexOf('Firefox') > -1 || u?.indexOf('FxiOS') > -1, 252 | 'Firefox Focus': u?.indexOf('Focus') > -1, 253 | 'Chromium': u?.indexOf('Chromium') > -1, 254 | 'Opera': u?.indexOf('Opera') > -1 || u?.indexOf('OPR') > -1, 255 | 'Vivaldi': u?.indexOf('Vivaldi') > -1, 256 | 'Yandex': u?.indexOf('YaBrowser') > -1, 257 | 'Arora': u?.indexOf('Arora') > -1, 258 | 'Lunascape': u?.indexOf('Lunascape') > -1, 259 | 'QupZilla': u?.indexOf('QupZilla') > -1, 260 | 'Coc Coc': u?.indexOf('coc_coc_browser') > -1, 261 | 'Kindle': u?.indexOf('Kindle') > -1 || u?.indexOf('Silk/') > -1, 262 | 'Iceweasel': u?.indexOf('Iceweasel') > -1, 263 | 'Konqueror': u?.indexOf('Konqueror') > -1, 264 | 'Iceape': u?.indexOf('Iceape') > -1, 265 | 'SeaMonkey': u?.indexOf('SeaMonkey') > -1, 266 | 'Epiphany': u?.indexOf('Epiphany') > -1, 267 | '360': u?.indexOf('QihooBrowser') > -1 || u?.indexOf('QHBrowser') > -1, 268 | '360EE': u?.indexOf('360EE') > -1, 269 | '360SE': u?.indexOf('360SE') > -1, 270 | 'UC': u?.indexOf('UC') > -1 || u?.indexOf(' UBrowser') > -1, 271 | 'QQBrowser': u?.indexOf('QQBrowser') > -1, 272 | 'QQ': u?.indexOf('QQ/') > -1, 273 | 'Baidu': u?.indexOf('Baidu') > -1 || u?.indexOf('BIDUBrowser') > -1, 274 | 'Maxthon': u?.indexOf('Maxthon') > -1, 275 | 'Sogou': u?.indexOf('MetaSr') > -1 || u?.indexOf('Sogou') > -1, 276 | 'LBBROWSER': u?.indexOf('LBBROWSER') > -1 || u?.indexOf('LieBaoFast') > -1, 277 | '2345Explorer': u?.indexOf('2345Explorer') > -1, 278 | 'TheWorld': u?.indexOf('TheWorld') > -1, 279 | 'XiaoMi': u?.indexOf('MiuiBrowser') > -1, 280 | 'Quark': u?.indexOf('Quark') > -1, 281 | 'Qiyu': u?.indexOf('Qiyu') > -1, 282 | 'Wechat': u?.indexOf('MicroMessenger') > -1, 283 | 'WechatWork': u?.indexOf('wxwork/') > -1, 284 | 'Taobao': u?.indexOf('AliApp(TB') > -1, 285 | 'Alipay': u?.indexOf('AliApp(AP') > -1, 286 | 'Weibo': u?.indexOf('Weibo') > -1, 287 | 'Douban': u?.indexOf('com.douban.frodo') > -1, 288 | 'Suning': u?.indexOf('SNEBUY-APP') > -1, 289 | 'iQiYi': u?.indexOf('IqiyiApp') > -1, 290 | 'DingTalk': u?.indexOf('DingTalk') > -1, 291 | 'Vivo': u?.indexOf('VivoBrowser') > -1, 292 | 'Huawei': u?.indexOf('HuaweiBrowser') > -1 || u?.indexOf('HUAWEI/') > -1 || u?.indexOf( 293 | 'HONOR') > -1 || u?.indexOf('HBPC/') > -1, 294 | // 系统或平台 295 | 'Windows': u?.indexOf('Windows') > -1, 296 | 'Linux': u?.indexOf('Linux') > -1 || u?.indexOf('X11') > -1, 297 | 'Mac OS': u?.indexOf('Macintosh') > -1, 298 | 'Android': u?.indexOf('Android') > -1 || u?.indexOf('Adr') > -1, 299 | 'Ubuntu': u?.indexOf('Ubuntu') > -1, 300 | 'FreeBSD': u?.indexOf('FreeBSD') > -1, 301 | 'Debian': u?.indexOf('Debian') > -1, 302 | 'Windows Phone': u?.indexOf('IEMobile') > -1 || u?.indexOf('Windows Phone') > -1, 303 | 'BlackBerry': u?.indexOf('BlackBerry') > -1 || u?.indexOf('RIM') > -1, 304 | 'MeeGo': u?.indexOf('MeeGo') > -1, 305 | 'Symbian': u?.indexOf('Symbian') > -1, 306 | 'iOS': u?.indexOf('like Mac OS X') > -1, 307 | 'Chrome OS': u?.indexOf('CrOS') > -1, 308 | 'WebOS': u?.indexOf('hpwOS') > -1, 309 | 'HarmonyOS': u?.indexOf('HarmonyOS') > -1, 310 | // 设备 311 | 'Mobile': u?.indexOf('Mobi') > -1 || u?.indexOf('iPh') > -1 || u?.indexOf('480') > -1, 312 | 'Tablet': u?.indexOf('Tablet') > -1 || u?.indexOf('Nexus 7') > -1, 313 | 'iPad': u?.indexOf('iPad') > -1 314 | } 315 | }, 316 | // 在信息map和匹配库中进行匹配 317 | matchInfoMap: function (_this) { 318 | let u = VariableLibrary?.navigator?.userAgent || {} 319 | let match = MethodLibrary?.getMatchMap(u) 320 | for (let s in VariableLibrary?.infoMap) { 321 | for (let i = 0; i < VariableLibrary?.infoMap?.[s]?.length; i++) { 322 | let value = VariableLibrary?.infoMap?.[s]?.[i] 323 | if (match[value]) { 324 | _this[s] = value 325 | } 326 | } 327 | } 328 | }, 329 | // 获取当前操作系统 330 | getOS: function () { 331 | let _this = this 332 | MethodLibrary?.matchInfoMap(_this) 333 | return _this.os 334 | }, 335 | // 获取操作系统版本 336 | getOSVersion: function () { 337 | let _this = this 338 | let u = VariableLibrary?.navigator?.userAgent || {} 339 | _this.osVersion = '' 340 | // 系统版本信息 341 | let osVersion = { 342 | 'Windows': function () { 343 | let v = u?.replace(/^.*Windows NT ([\d.]+);.*$/, '$1') 344 | let oldWindowsVersionMap = { 345 | '10': '10 || 11', 346 | '6.3': '8.1', 347 | '6.2': '8', 348 | '6.1': '7', 349 | '6.0': 'Vista', 350 | '5.2': 'XP 64-Bit', 351 | '5.1': 'XP', 352 | '5.0': '2000', 353 | '4.0': 'NT 4.0', 354 | '3.5.1': 'NT 3.5.1', 355 | '3.5': 'NT 3.5', 356 | '3.1': 'NT 3.1', 357 | } 358 | return oldWindowsVersionMap[v] || v 359 | }, 360 | 'Android': function () { 361 | return u?.replace(/^.*Android ([\d.]+);.*$/, '$1') 362 | }, 363 | 'iOS': function () { 364 | return u?.replace(/^.*OS ([\d_]+) like.*$/, '$1')?.replace(/_/g, '.') 365 | }, 366 | 'Debian': function () { 367 | return u?.replace(/^.*Debian\/([\d.]+).*$/, '$1') 368 | }, 369 | 'Windows Phone': function () { 370 | return u?.replace(/^.*Windows Phone( OS)? ([\d.]+);.*$/, '$2') 371 | }, 372 | 'Mac OS': function () { 373 | return u?.replace(/^.*Mac OS X ([\d_]+).*$/, '$1')?.replace(/_/g, '.') 374 | }, 375 | 'WebOS': function () { 376 | return u?.replace(/^.*hpwOS\/([\d.]+);.*$/, '$1') 377 | } 378 | } 379 | if (osVersion[_this.os]) { 380 | _this.osVersion = osVersion?.[_this.os]?.() 381 | if (_this.osVersion == u) { 382 | _this.osVersion = '' 383 | } 384 | } 385 | return _this.osVersion 386 | }, 387 | // 获取横竖屏状态 388 | getOrientationStatu: function () { 389 | let orientationStatus = '' 390 | let orientation = window?.matchMedia("(orientation: portrait)") 391 | if (orientation?.matches) { 392 | orientationStatus = "竖屏" 393 | } else { 394 | orientationStatus = "横屏" 395 | } 396 | return orientationStatus 397 | }, 398 | // 获取设备类型 399 | getDeviceType: function () { 400 | let _this = this 401 | _this.device = 'PC' 402 | MethodLibrary?.matchInfoMap(_this) 403 | return _this.device 404 | }, 405 | // 获取网络状态 406 | getNetwork: function () { 407 | let netWork = navigator?.connection?.effectiveType 408 | let isOnline = navigator?.onLine 409 | let res = "" 410 | if (isOnline) { 411 | res = netWork ? netWork : "网络状态获取失败" 412 | } else { 413 | res = "离线" 414 | } 415 | return res 416 | }, 417 | // 获取当前语言 418 | getLanguage: function () { 419 | let _this = this 420 | _this.language = (function () { 421 | let language = (VariableLibrary?.navigator?.browserLanguage || VariableLibrary?.navigator?.language) 422 | let arr = language?.split('-') 423 | if (arr[1]) { 424 | arr[1] = arr?.[1]?.toUpperCase() 425 | } 426 | return arr?.join('_') 427 | })() 428 | return _this.language 429 | }, 430 | // 生成浏览器指纹 431 | createFingerprint: function (domain) { 432 | let fingerprint 433 | 434 | function bin2hex(s) { 435 | let i, l, n, o = '' 436 | s += '' 437 | for (i = 0, l = s.length; i < l; i++) { 438 | n = s.charCodeAt(i)?.toString(16) 439 | o += n.length < 2 ? '0' + n : n 440 | } 441 | return o 442 | } 443 | 444 | let canvas = document?.createElement('canvas') 445 | let ctx = canvas?.getContext('2d') 446 | let txt = domain || window?.location?.host 447 | ctx.textBaseline = "top" 448 | ctx.font = "14px 'Arial'" 449 | ctx.textBaseline = "tencent" 450 | ctx.fillStyle = "#f60" 451 | ctx.fillRect(125, 1, 62, 20) 452 | ctx.fillStyle = "#069" 453 | ctx.fillText(txt, 2, 15) 454 | ctx.fillStyle = "rgba(102, 204, 0, 0.7)" 455 | ctx.fillText(txt, 4, 17) 456 | let b64 = canvas?.toDataURL()?.replace("data:image/png;base64,", "") 457 | let bin = atob(b64) 458 | let crc = bin2hex(bin?.slice(-16, -12)) 459 | fingerprint = crc 460 | return fingerprint 461 | }, 462 | // 浏览器信息 463 | getBrowserInfo: function () { 464 | let _this = this 465 | MethodLibrary?.matchInfoMap(_this) 466 | 467 | let u = VariableLibrary?.navigator?.userAgent || {} 468 | 469 | let _mime = function (option, value) { 470 | let mimeTypes = VariableLibrary?.navigator?.mimeTypes 471 | for (let key in mimeTypes) { 472 | if (mimeTypes[key][option] == value) { 473 | return true 474 | } 475 | } 476 | return false 477 | } 478 | 479 | let match = MethodLibrary?.getMatchMap(u) 480 | 481 | let is360 = false 482 | 483 | if (_window.chrome) { 484 | let chrome_version = u?.replace(/^.*Chrome\/([\d]+).*$/, '$1') 485 | if (chrome_version > 36 && _window.showModalDialog) { 486 | is360 = true 487 | } else if (chrome_version > 45) { 488 | is360 = _mime("type", "application/vnd.chromium.remoting-viewer") 489 | } 490 | } 491 | 492 | if (match['Baidu'] && match['Opera']) { 493 | match['Baidu'] = false 494 | } 495 | 496 | if (match['Mobile']) { 497 | match['Mobile'] = !(u?.indexOf('iPad') > -1) 498 | } 499 | 500 | if (is360) { 501 | if (_mime("type", "application/gameplugin")) { 502 | match['360SE'] = true 503 | } else if (VariableLibrary?.navigator && typeof VariableLibrary?.navigator['connection']['saveData'] == 'undefined') { 504 | match['360SE'] = true 505 | } else { 506 | match['360EE'] = true 507 | } 508 | } 509 | 510 | if (match['IE'] || match['Edge']) { 511 | let navigator_top = window?.screenTop - window?.screenY 512 | switch (navigator_top) { 513 | case 71: // 无收藏栏,贴边 514 | break 515 | case 74: // 无收藏栏,非贴边 516 | break 517 | case 99: // 有收藏栏,贴边 518 | break 519 | case 102: // 有收藏栏,非贴边 520 | match['360EE'] = true 521 | break; 522 | case 75: // 无收藏栏,贴边 523 | break 524 | case 74: // 无收藏栏,非贴边 525 | break 526 | case 105: // 有收藏栏,贴边 527 | break 528 | case 104: // 有收藏栏,非贴边 529 | match['360SE'] = true 530 | break 531 | default: 532 | break 533 | } 534 | } 535 | 536 | let browerVersionMap = { 537 | 'Safari': function () { 538 | return u?.replace(/^.*Version\/([\d.]+).*$/, '$1') 539 | }, 540 | 'Chrome': function () { 541 | return u?.replace(/^.*Chrome\/([\d.]+).*$/, '$1')?.replace(/^.*CriOS\/([\d.]+).*$/, '$1') 542 | }, 543 | 'IE': function () { 544 | return u?.replace(/^.*MSIE ([\d.]+).*$/, '$1')?.replace(/^.*rv:([\d.]+).*$/, '$1') 545 | }, 546 | 'Edge': function () { 547 | return u?.replace(/^.*Edge\/([\d.]+).*$/, '$1') 548 | }, 549 | 'Firefox': function () { 550 | return u?.replace(/^.*Firefox\/([\d.]+).*$/, '$1')?.replace(/^.*FxiOS\/([\d.]+).*$/, '$1') 551 | }, 552 | 'Firefox Focus': function () { 553 | return u?.replace(/^.*Focus\/([\d.]+).*$/, '$1') 554 | }, 555 | 'Chromium': function () { 556 | return u?.replace(/^.*Chromium\/([\d.]+).*$/, '$1') 557 | }, 558 | 'Opera': function () { 559 | return u?.replace(/^.*Opera\/([\d.]+).*$/, '$1')?.replace(/^.*OPR\/([\d.]+).*$/, '$1') 560 | }, 561 | 'Vivaldi': function () { 562 | return u?.replace(/^.*Vivaldi\/([\d.]+).*$/, '$1') 563 | }, 564 | 'Yandex': function () { 565 | return u?.replace(/^.*YaBrowser\/([\d.]+).*$/, '$1') 566 | }, 567 | 'Arora': function () { 568 | return u?.replace(/^.*Arora\/([\d.]+).*$/, '$1') 569 | }, 570 | 'Lunascape': function () { 571 | return u?.replace(/^.*Lunascape[\/\s]([\d.]+).*$/, '$1') 572 | }, 573 | 'QupZilla': function () { 574 | return u?.replace(/^.*QupZilla[\/\s]([\d.]+).*$/, '$1') 575 | }, 576 | 'Coc Coc': function () { 577 | return u?.replace(/^.*coc_coc_browser\/([\d.]+).*$/, '$1') 578 | }, 579 | 'Kindle': function () { 580 | return u?.replace(/^.*Version\/([\d.]+).*$/, '$1') 581 | }, 582 | 'Iceweasel': function () { 583 | return u?.replace(/^.*Iceweasel\/([\d.]+).*$/, '$1') 584 | }, 585 | 'Konqueror': function () { 586 | return u?.replace(/^.*Konqueror\/([\d.]+).*$/, '$1') 587 | }, 588 | 'Iceape': function () { 589 | return u?.replace(/^.*Iceape\/([\d.]+).*$/, '$1') 590 | }, 591 | 'SeaMonkey': function () { 592 | return u?.replace(/^.*SeaMonkey\/([\d.]+).*$/, '$1') 593 | }, 594 | 'Epiphany': function () { 595 | return u?.replace(/^.*Epiphany\/([\d.]+).*$/, '$1') 596 | }, 597 | '360': function () { 598 | return u?.replace(/^.*QihooBrowser\/([\d.]+).*$/, '$1') 599 | }, 600 | '360SE': function () { 601 | let hash = {'63': '10.0', '55': '9.1', '45': '8.1', '42': '8.0', '31': '7.0', '21': '6.3'} 602 | let chrome_version = u?.replace(/^.*Chrome\/([\d]+).*$/, '$1') 603 | return hash[chrome_version] || '' 604 | }, 605 | '360EE': function () { 606 | let hash = {'69': '11.0', '63': '9.5', '55': '9.0', '50': '8.7', '30': '7.5'}; 607 | let chrome_version = u?.replace(/^.*Chrome\/([\d]+).*$/, '$1') 608 | return hash[chrome_version] || '' 609 | }, 610 | 'Maxthon': function () { 611 | return u?.replace(/^.*Maxthon\/([\d.]+).*$/, '$1') 612 | }, 613 | 'QQBrowser': function () { 614 | return u?.replace(/^.*QQBrowser\/([\d.]+).*$/, '$1') 615 | }, 616 | 'QQ': function () { 617 | return u?.replace(/^.*QQ\/([\d.]+).*$/, '$1') 618 | }, 619 | 'Baidu': function () { 620 | return u?.replace(/^.*BIDUBrowser[\s\/]([\d.]+).*$/, '$1') 621 | }, 622 | 'UC': function () { 623 | return u?.replace(/^.*UC?Browser\/([\d.]+).*$/, '$1') 624 | }, 625 | 'Sogou': function () { 626 | return u?.replace(/^.*SE ([\d.X]+).*$/, '$1')?.replace(/^.*SogouMobileBrowser\/([\d.]+).*$/, '$1') 627 | }, 628 | 'Liebao': function () { 629 | let version = '' 630 | if (u?.indexOf('LieBaoFast') > -1) { 631 | version = u?.replace(/^.*LieBaoFast\/([\d.]+).*$/, '$1'); 632 | } 633 | let hash = { 634 | '57': '6.5', 635 | '49': '6.0', 636 | '46': '5.9', 637 | '42': '5.3', 638 | '39': '5.2', 639 | '34': '5.0', 640 | '29': '4.5', 641 | '21': '4.0' 642 | }; 643 | let chrome_version = u?.replace(/^.*Chrome\/([\d]+).*$/, '$1'); 644 | return version || hash[chrome_version] || ''; 645 | }, 646 | 'LBBROWSER': function () { 647 | let version = '' 648 | if (u?.indexOf('LieBaoFast') > -1) { 649 | version = u?.replace(/^.*LieBaoFast\/([\d.]+).*$/, '$1'); 650 | } 651 | let hash = { 652 | '57': '6.5', 653 | '49': '6.0', 654 | '46': '5.9', 655 | '42': '5.3', 656 | '39': '5.2', 657 | '34': '5.0', 658 | '29': '4.5', 659 | '21': '4.0' 660 | }; 661 | let chrome_version = u?.replace(/^.*Chrome\/([\d]+).*$/, '$1'); 662 | return version || hash[chrome_version] || ''; 663 | }, 664 | '2345Explorer': function () { 665 | return u?.replace(/^.*2345Explorer\/([\d.]+).*$/, '$1') 666 | }, 667 | '115Browser': function () { 668 | return u?.replace(/^.*115Browser\/([\d.]+).*$/, '$1'); 669 | }, 670 | 'TheWorld': function () { 671 | return u?.replace(/^.*TheWorld ([\d.]+).*$/, '$1') 672 | }, 673 | 'XiaoMi': function () { 674 | return u?.replace(/^.*MiuiBrowser\/([\d.]+).*$/, '$1') 675 | }, 676 | 'Vivo': function () { 677 | return u?.replace(/^.*VivoBrowser\/([\d.]+).*$/, '$1'); 678 | }, 679 | 'Quark': function () { 680 | return u?.replace(/^.*Quark\/([\d.]+).*$/, '$1') 681 | }, 682 | 'Qiyu': function () { 683 | return u?.replace(/^.*Qiyu\/([\d.]+).*$/, '$1') 684 | }, 685 | 'Wechat': function () { 686 | return u?.replace(/^.*MicroMessenger\/([\d.]+).*$/, '$1') 687 | }, 688 | 'WechatWork': function () { 689 | return u?.replace(/^.*wxwork\/([\d.]+).*$/, '$1'); 690 | }, 691 | 'Taobao': function () { 692 | return u?.replace(/^.*AliApp\(TB\/([\d.]+).*$/, '$1') 693 | }, 694 | 'Alipay': function () { 695 | return u?.replace(/^.*AliApp\(AP\/([\d.]+).*$/, '$1') 696 | }, 697 | 'Weibo': function () { 698 | return u?.replace(/^.*weibo__([\d.]+).*$/, '$1') 699 | }, 700 | 'Douban': function () { 701 | return u?.replace(/^.*com.douban.frodo\/([\d.]+).*$/, '$1') 702 | }, 703 | 'Suning': function () { 704 | return u?.replace(/^.*SNEBUY-APP([\d.]+).*$/, '$1') 705 | }, 706 | 'iQiYi': function () { 707 | return u?.replace(/^.*IqiyiVersion\/([\d.]+).*$/, '$1') 708 | }, 709 | 'DingTalk': function () { 710 | return u?.replace(/^.*DingTalk\/([\d.]+).*$/, '$1'); 711 | }, 712 | 'Huawei': function () { 713 | return u?.replace(/^.*Version\/([\d.]+).*$/, '$1')?.replace(/^.*HuaweiBrowser\/([\d.]+).*$/, '$1') 714 | ?.replace(/^.*HBPC\/([\d.]+).*$/, '$1'); 715 | } 716 | } 717 | 718 | _this.browserVersion = '' 719 | 720 | if (browerVersionMap[_this.browser]) { 721 | _this.browserVersion = browerVersionMap?.[_this.browser]?.() 722 | if (_this.browserVersion == u) { 723 | _this.browserVersion = '' 724 | } 725 | } 726 | 727 | if (_this.browser == 'Chrome' && u?.match(/\S+Browser/)) { 728 | _this.browser = u?.match(/\S+Browser/)[0]; 729 | _this.version = u?.replace(/^.*Browser\/([\d.]+).*$/, '$1'); 730 | } 731 | 732 | if (_this.browser == 'Edge') { 733 | if (_this.version > "75") { 734 | _this.engine = 'Blink' 735 | } else { 736 | _this.engine = 'EdgeHTML' 737 | } 738 | } 739 | 740 | if (_this.browser == 'Chrome' && parseInt(_this.browserVersion) > 27) { 741 | _this.engine = 'Blink' 742 | } else if (match['Chrome'] && _this.engine == 'WebKit' && parseInt(browerVersionMap['Chrome']()) > 27) { 743 | _this.engine = 'Blink'; 744 | } else if (_this.browser == 'Opera' && parseInt(_this.version) > 12) { 745 | _this.engine = 'Blink'; 746 | } else if (_this.browser == 'Yandex') { 747 | _this.engine = 'Blink'; 748 | } 749 | 750 | return _this.browser + '(版本: ' + _this.browserVersion + '  内核: ' + _this.engine + ')' 751 | }, 752 | // 获取地理位置 753 | getGeoPostion: function () { 754 | return new Promise((resolve, reject) => { 755 | if (navigator?.geolocation) { 756 | navigator?.geolocation?.getCurrentPosition( 757 | // 位置获取成功 758 | function (position) { 759 | resolve(position) 760 | }, 761 | // 位置获取失败 762 | function (error) { 763 | resolve({ 764 | coords: { 765 | longitude: '获取失败', 766 | latitude: '获取失败' 767 | } 768 | }) 769 | }, 770 | { 771 | // 是否开启高精度模式,开启高精度模式耗时较长 772 | enableHighAccuracy: false, 773 | // 超时时间,单位毫秒。默认为infinity 774 | timeout: 10000 775 | } 776 | ) 777 | } else { 778 | reject('当前浏览器不支持获取地理位置') 779 | } 780 | }) 781 | }, 782 | /* 阳历转阴历 783 | * @date: 2023/01/01 784 | */ 785 | toLunarDate: function (date) { 786 | let now_date = new Date() 787 | let date_str = date ? date?.replaceAll('-', '/') : `${now_date?.getFullYear()}/${now_date?.getMonth() + 1}/${now_date?.getDate()}` 788 | 789 | function transferToLunar(str) { 790 | let lunar 791 | 792 | let solarYear = new Date(str)?.getFullYear() 793 | let solarMonth = new Date(str)?.getMonth() 794 | let solarDay = new Date(str)?.getDate() 795 | let solarDateObj 796 | let lunarDateObj, lunarYear, lunarMonth, lunarDay = 1 797 | let lunarLeap // 农历是否闰月 798 | let lunarLastDay = 0 // 农历当月最后一天 799 | let firstLunarMonth = '' // 农历第一个月 800 | let lunarDayPositionArr = new Array(3) 801 | let n = 0 802 | 803 | // 阳历当月天数 804 | let solarMonthLength 805 | if (solarMonth === 1) { 806 | solarMonthLength = (((solarYear % 4 === 0) && (solarYear % 100 != 0) || (solarYear % 400 === 0)) ? 29 : 28) 807 | } else { 808 | solarMonthLength = (VariableLibrary?.lunarLib?.solarMonthArr[solarMonth]) 809 | } 810 | 811 | // 判断year年的农历中那个月是闰月,不是闰月返回0 812 | function whitchMonthLeap(year) { 813 | return (VariableLibrary?.lunarLib?.lunarMap?.[year - 1900] & 0xf) 814 | } 815 | 816 | // 返回农历year年润月天数 817 | function leapMonthDays(year) { 818 | if (whitchMonthLeap(year)) { 819 | return ((VariableLibrary?.lunarLib?.lunarMap?.[year - 1900] & 0x10000) ? 30 : 29) 820 | } else { 821 | return (0) 822 | } 823 | } 824 | 825 | // 返回农历y年m月的总天数 826 | function monthDays(y, m) { 827 | return ((VariableLibrary?.lunarLib?.lunarMap?.[y - 1900] & (0x10000 >> m)) ? 30 : 29) 828 | } 829 | 830 | // 算出当前月第一天的农历日期和当前农历日期下一个月农历的第一天日期 831 | function calculateLunarFirstDay(objDate) { 832 | let j, leap = 0, temp = 0 833 | let baseDate = new Date(1900, 0, 31) 834 | let offset = (objDate - baseDate) / 86400000 835 | let dayCycle = offset + 40 836 | let monthCycle = 14 837 | 838 | for (j = 1900; j < 2050 && offset > 0; j++) { 839 | // 返回农历j年的总天数 840 | let sum = 348 841 | for (let k = 0x8000; k > 0x8; k >>= 1) { 842 | sum += (VariableLibrary?.lunarLib?.lunarMap[j - 1900] & k) ? 1 : 0 843 | } 844 | 845 | temp = (sum + leapMonthDays(j)) 846 | offset -= temp 847 | monthCycle += 12 848 | } 849 | 850 | if (offset < 0) { 851 | offset += temp 852 | j-- 853 | monthCycle -= 12 854 | } 855 | 856 | let year = j 857 | let yearCycle = j - 1864 858 | 859 | // 判断j年的农历中那个月是闰月,不是闰月返回0 860 | leap = whitchMonthLeap(j) 861 | 862 | let isLeap = false 863 | 864 | for (j = 1; j < 13 && offset > 0; j++) { 865 | if (leap > 0 && j === (leap + 1) && isLeap === false) { // 闰月 866 | --j 867 | isLeap = true 868 | temp = leapMonthDays(year) 869 | } else { 870 | temp = monthDays(year, j) 871 | } 872 | if (isLeap === true && j === (leap + 1)) isLeap = false // 解除闰月 873 | offset -= temp 874 | if (isLeap === false) monthCycle++ 875 | } 876 | 877 | if (offset === 0 && leap > 0 && j === leap + 1) { 878 | if (isLeap) { 879 | isLeap = false 880 | } else { 881 | isLeap = true 882 | --j 883 | --monthCycle 884 | } 885 | } 886 | 887 | if (offset < 0) { 888 | offset += temp 889 | --j 890 | --monthCycle 891 | } 892 | 893 | let month = j 894 | 895 | let day = offset + 1 896 | 897 | return { 898 | year, 899 | month, 900 | day, 901 | isLeap, 902 | yearCycle, 903 | monthCycle, 904 | dayCycle 905 | } 906 | } 907 | 908 | for (let i = 0; i < solarMonthLength; i++) { 909 | if (lunarDay > lunarLastDay) { 910 | // 阳历当月第一天的日期 911 | solarDateObj = new Date(solarYear, solarMonth, date ? solarDay : new Date()?.getDate()) 912 | 913 | // 农历 914 | lunarDateObj = calculateLunarFirstDay(solarDateObj) 915 | lunarYear = lunarDateObj.year; // 农历年 916 | lunarMonth = lunarDateObj.month; // 农历月 917 | lunarDay = lunarDateObj.day; // 农历日 918 | lunarLeap = lunarDateObj.isLeap; // 农历是否闰月 919 | lunarLastDay = lunarLeap ? leapMonthDays(lunarYear) : monthDays(lunarYear, lunarMonth) 920 | 921 | if (lunarMonth === 12) { 922 | VariableLibrary.lunarLib.monthPlusOne = lunarLastDay 923 | } 924 | 925 | if (n === 0) { 926 | firstLunarMonth = lunarMonth 927 | } else { 928 | lunarDayPositionArr[n++] = i - lunarDay + 1 929 | } 930 | } 931 | } 932 | 933 | 934 | lunar = { 935 | lunarYear, 936 | lunarMonth, 937 | lunarDay, 938 | lunarLeap, 939 | chineseZodiac: VariableLibrary?.lunarLib?.AnimalsArr[(lunarYear - 4) % 12] 940 | } 941 | 942 | // 用中文显示农历的日期 943 | function chineseDay(date) { 944 | date = Math?.floor(date) 945 | let ChineseDate 946 | switch (date) { 947 | case 10: 948 | ChineseDate = '初十'; 949 | break; 950 | case 20: 951 | ChineseDate = '二十'; 952 | break; 953 | case 30: 954 | ChineseDate = '三十'; 955 | break; 956 | default: 957 | ChineseDate = VariableLibrary.lunarLib.numberToHanzi_2[Math?.floor(date / 10)]; 958 | ChineseDate += VariableLibrary.lunarLib.numberToHanzi_1[date % 10]; 959 | } 960 | return ChineseDate 961 | } 962 | 963 | let lunarYearArr = String(lunar.lunarYear)?.split('') 964 | let chineseYear = `${VariableLibrary?.lunarLib?.chineseYear[lunarYearArr[0]]}${VariableLibrary?.lunarLib?.chineseYear[lunarYearArr[1]]}${VariableLibrary?.lunarLib?.chineseYear[lunarYearArr[2]]}${VariableLibrary?.lunarLib?.chineseYear[lunarYearArr[3]]}` 965 | 966 | return { 967 | year: `${chineseYear}年`, 968 | month: `${lunar.isLeap ? '闰' : ''}${VariableLibrary?.lunarLib?.chineseMonth[lunar.lunarMonth - 1]}月`, 969 | day: `${chineseDay(lunar.lunarDay)}`, 970 | chineseZodiac: lunar?.chineseZodiac 971 | } 972 | } 973 | 974 | return transferToLunar(date_str) 975 | }, 976 | // 获取操作系统平台 977 | getPlatform() { 978 | const platform = VariableLibrary?.navigator?.userAgentData?.platform || VariableLibrary?.navigator?.platform 979 | return platform 980 | } 981 | } 982 | })() 983 | // 逻辑层 984 | const LogicLibrary = (function () { 985 | return { 986 | DeviceInfoObj: function (params) { 987 | let info = { 988 | deviceType: MethodLibrary?.getDeviceType(), // 设备类型 989 | OS: MethodLibrary?.getOS(), // 操作系统 990 | OSVersion: MethodLibrary?.getOSVersion(), // 操作系统版本 991 | platform: MethodLibrary?.getPlatform(), // 获取操作系统平台 992 | screenHeight: _window?.screen?.height, // 屏幕高 993 | screenWidth: _window?.screen?.width, // 屏幕宽 994 | language: MethodLibrary?.getLanguage(), // 当前使用的语言-国家 995 | netWork: MethodLibrary?.getNetwork(), // 联网类型 996 | orientation: MethodLibrary?.getOrientationStatu(), // 横竖屏 997 | browserInfo: MethodLibrary?.getBrowserInfo(), // 浏览器信息 998 | fingerprint: MethodLibrary?.createFingerprint(params && params.domain || ''), // 浏览器指纹 999 | userAgent: VariableLibrary?.navigator?.userAgent, // 包含 appCodeName,appName,appVersion,language 等 1000 | geoPosition: true, // 获取地理位置 1001 | date: MethodLibrary?.getDate(), // 获取阳历日期时间 1002 | lunarDate: MethodLibrary?.toLunarDate(params && params.transferDateToLunar || ''), // 获取农历日期时间 1003 | week: MethodLibrary?.getWeek(), // 获取周几 1004 | UUID: MethodLibrary?.createUUID(), // 生成通用唯一标识 1005 | } 1006 | 1007 | let resultInfo = {} 1008 | if (!params || !params.info || params?.info?.length === 0) { 1009 | resultInfo = info 1010 | } else { 1011 | let infoTemp = {} 1012 | for (let i in info) { 1013 | params?.info?.forEach(function (item) { 1014 | if (item?.toLowerCase() === i?.toLowerCase()) { 1015 | item = i 1016 | infoTemp[item] = info?.[item] 1017 | } 1018 | }) 1019 | } 1020 | resultInfo = infoTemp 1021 | } 1022 | 1023 | return new Promise(resolve => { 1024 | if (resultInfo?.geoPosition) { 1025 | MethodLibrary?.getGeoPostion?.()?.then(geoPosition => { 1026 | resultInfo.geoPosition = '经度:' + geoPosition?.coords?.longitude + ' 纬度:' + geoPosition?.coords?.latitude 1027 | resolve(resultInfo) 1028 | })?.catch(err => { 1029 | resultInfo.geoPosition = err 1030 | resolve(resultInfo) 1031 | }) 1032 | } else { 1033 | resolve(resultInfo) 1034 | } 1035 | }) 1036 | } 1037 | } 1038 | })() 1039 | // 对外暴露方法 1040 | return { 1041 | /** 1042 | * @params:{ 1043 | * domain: 生成浏览器指纹所需,不传默认使用window.location.host; 1044 | * info: 想要获取的信息,不传默认显示全部信息 1045 | * } 1046 | * 1047 | * @return: 返回 Promise 对象 1048 | */ 1049 | Info: function (params) { 1050 | MethodLibrary?.createLoading() 1051 | return new Promise(resolve => { 1052 | LogicLibrary?.DeviceInfoObj(params)?.then(res => { 1053 | MethodLibrary?.removeLoading() 1054 | resolve(res) 1055 | }) 1056 | }) 1057 | } 1058 | } 1059 | })() 1060 | 1061 | if (typeof window === "undefined" || typeof window === null) { 1062 | const jsdom = require("jsdom") 1063 | const {JSDOM} = jsdom 1064 | const DOM = new JSDOM(``) 1065 | window = DOM?.window 1066 | document = DOM?.window?.document 1067 | globalThis.window = window 1068 | globalThis.document = document 1069 | } 1070 | 1071 | window.Device = Device 1072 | 1073 | export default Device 1074 | --------------------------------------------------------------------------------