Browse Source

初始设置

任一存 2 years ago
parent
commit
aad83f915f
5 changed files with 121 additions and 1 deletions
  1. 1 1
      public/index.html
  2. 43 0
      src/assets/style/my-reset.css
  3. 48 0
      src/assets/style/reset.css
  4. 4 0
      src/libs/ua-parser.min.js
  5. 25 0
      src/main.js

+ 1 - 1
public/index.html

@@ -3,7 +3,7 @@
   <head>
     <meta charset="utf-8">
     <meta http-equiv="X-UA-Compatible" content="IE=edge">
-    <meta name="viewport" content="width=device-width,initial-scale=1.0">
+    <meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no">
     <link rel="icon" href="<%= BASE_URL %>favicon.ico">
     <title>title undefined</title>
   </head>

+ 43 - 0
src/assets/style/my-reset.css

@@ -0,0 +1,43 @@
+*,
+*::before,
+*::after {
+  /* 阻止safari在用户交互设置一些元素的背景色 */
+  -webkit-tap-highlight-color: transparent;
+  box-sizing: border-box;
+}
+
+html {
+  overflow: hidden;
+  touch-action: none;
+  scroll-behavior: smooth; /* MDN: When this property is specified on the root element, it applies to the viewport instead. This property specified on the body element will not propagate to the viewport.(???) */
+}
+
+body {
+  text-align: justify;
+}
+
+a {
+  color: initial;
+  text-decoration: initial;
+  outline: none;
+}
+
+button {
+  padding: 0;
+  cursor: pointer;
+  background-color: initial;
+  border: initial;
+  outline: none;
+}
+
+img {
+  user-select: none;
+}
+
+menu {
+  list-style-type: initial;
+}
+
+li {
+  display: initial;
+}

+ 48 - 0
src/assets/style/reset.css

@@ -0,0 +1,48 @@
+/* http://meyerweb.com/eric/tools/css/reset/ 
+   v2.0 | 20110126
+   License: none (public domain)
+*/
+
+html, body, div, span, applet, object, iframe,
+h1, h2, h3, h4, h5, h6, p, blockquote, pre,
+a, abbr, acronym, address, big, cite, code,
+del, dfn, em, img, ins, kbd, q, s, samp,
+small, strike, strong, sub, sup, tt, var,
+b, u, i, center,
+dl, dt, dd, ol, ul, li,
+fieldset, form, label, legend,
+table, caption, tbody, tfoot, thead, tr, th, td,
+article, aside, canvas, details, embed, 
+figure, figcaption, footer, header, hgroup, 
+menu, nav, output, ruby, section, summary,
+time, mark, audio, video {
+	margin: 0;
+	padding: 0;
+	border: 0;
+	font-size: 100%;
+	font: inherit;
+	vertical-align: baseline;
+}
+/* HTML5 display-role reset for older browsers */
+article, aside, details, figcaption, figure, 
+footer, header, hgroup, menu, nav, section {
+	display: block;
+}
+body {
+	line-height: 1;
+}
+ol, ul {
+	list-style: none;
+}
+blockquote, q {
+	quotes: none;
+}
+blockquote:before, blockquote:after,
+q:before, q:after {
+	content: '';
+	content: none;
+}
+table {
+	border-collapse: collapse;
+	border-spacing: 0;
+}

File diff suppressed because it is too large
+ 4 - 0
src/libs/ua-parser.min.js


+ 25 - 0
src/main.js

@@ -2,6 +2,31 @@ import Vue from 'vue'
 import App from './App.vue'
 import router from './router'
 import store from './store'
+import UAParser from "@/libs/ua-parser.min.js"
+
+console.log('v1012.1146')
+
+const uaParser = new UAParser()
+const uaInfo = uaParser.getResult()
+Vue.prototype.$uaInfo = uaInfo
+if (uaInfo.browser && uaInfo.browser.name === 'WeChat') {
+  Vue.prototype.$isWeChat = true
+}
+if (uaInfo.browser && uaInfo.browser.name === 'Safari') {
+  Vue.prototype.$isSafari = true
+}
+
+const idealWindowInnerHeight = 1125 // 设计稿的高度
+const idealRootFontSize = 24 // 设计稿里选择的根元素尺寸
+Vue.prototype.$oneRemToPx = window.innerHeight * idealRootFontSize / idealWindowInnerHeight
+
+function onResize() {
+  document.documentElement.style.fontSize = Vue.prototype.$oneRemToPx + 'px'
+}
+onResize()
+window.addEventListener('resize', () => {
+  onResize()
+})
 
 Vue.config.productionTip = false