任一存 před 1 rokem
revize
643d94bf3d

+ 4 - 0
.browserslistrc

@@ -0,0 +1,4 @@
+> 1%
+last 2 versions
+not dead
+not ie 11

+ 0 - 0
.env


+ 3 - 0
.env.dev

@@ -0,0 +1,3 @@
+VUE_APP_CLI_MODE=dev
+NODE_ENV=development
+PUBLIC_PATH=/

+ 3 - 0
.env.mytest

@@ -0,0 +1,3 @@
+VUE_APP_CLI_MODE=test
+NODE_ENV=production
+PUBLIC_PATH=./

+ 3 - 0
.env.prod

@@ -0,0 +1,3 @@
+VUE_APP_CLI_MODE=prod
+NODE_ENV=production
+PUBLIC_PATH=./

+ 3 - 0
.eslintignore

@@ -0,0 +1,3 @@
+*/libs
+/node_modules
+/.vscode

+ 56 - 0
.eslintrc.js

@@ -0,0 +1,56 @@
+module.exports = {
+  root: true,
+  env: {
+    browser: true,
+    commonjs: true,
+    es6: true,
+    jest: true,
+    jquery: true,
+    node: true,
+  },
+  'extends': [
+    'plugin:vue/vue3-recommended',
+    'eslint:recommended'
+  ],
+  parserOptions: {
+    parser: '@babel/eslint-parser'
+  },
+  rules: {
+    'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
+    'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
+    'semi': ['error', 'never'],
+    "no-unused-vars": ["warn", {
+      "vars": "all",
+      "args": "after-used",
+      "ignoreRestSiblings": false
+    }],
+    "keyword-spacing": ["error", { "before": true, "after": true }],
+    "object-curly-spacing": ["error", "always"],
+    "space-infix-ops": ["error"],
+    'key-spacing': ["error", {
+      "mode": "strict"
+    }],
+    "comma-spacing": ["error", { "before": false, "after": true }],
+    "func-call-spacing": ["error", "never"],
+    "semi-spacing": ["error", { "before": false, "after": true }],
+    "space-before-blocks": ["error", "always"],
+    'no-trailing-spaces': 'error',
+    'no-multi-spaces': 'error',
+    "indent": ["error", 2],
+    'no-empty': 'off',
+    // 默认不启用:为了避免细微的 bug,最好直接从 Object.prototype 调用挂载于prototype上的方法方法。例如,foo.hasOwnProperty("bar") 应该替换为 Object.prototype.hasOwnProperty.call(foo, "bar")。
+    'no-prototype-builtins': "off",
+  },
+  globals: {
+    api: true,
+    config: true,
+    mapState: true,
+    mapGetters: true,
+    mapMutations: true,
+    store: true,
+    utils: true,
+    useSizeAdapt: true,
+    defineProps: true,
+    defineEmits: true,
+  }
+}

+ 24 - 0
.gitignore

@@ -0,0 +1,24 @@
+.DS_Store
+node_modules
+/dist
+
+*.zip
+
+# local env files
+.env.local
+.env.*.local
+
+# Log files
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*
+pnpm-debug.log*
+
+# Editor directories and files
+.idea
+.vscode
+*.suo
+*.ntvs*
+*.njsproj
+*.sln
+*.sw?

+ 4 - 0
README.md

@@ -0,0 +1,4 @@
+## 部署测试环境
+文件存放位置:
+
+访问url:

+ 9 - 0
babel.config.js

@@ -0,0 +1,9 @@
+module.exports = {
+  presets: [
+    '@vue/cli-plugin-babel/preset',
+  ],
+  // plugins: [
+  //   "transform-object-rest-spread",
+  //   "@babel/plugin-proposal-optional-chaining",
+  // ],
+}

+ 20 - 0
jsconfig.json

@@ -0,0 +1,20 @@
+{
+  "compilerOptions": {
+    "target": "es5",
+    "module": "esnext",
+    "baseUrl": "./",
+    "moduleResolution": "node",
+    "paths": {
+      "@/*": [
+        "src/*"
+      ]
+    },
+    "lib": [
+      "esnext",
+      "dom",
+      "dom.iterable",
+      "scripthost"
+    ]
+  },
+  "exclude": ["libs", "node_modules"]
+}

+ 37 - 0
package.json

@@ -0,0 +1,37 @@
+{
+  "name": "my-app",
+  "version": "0.0.1",
+  "private": true,
+  "scripts": {
+    "serve": "vue-cli-service serve --mode dev",
+    "build-test": "vue-cli-service build --mode mytest",
+    "build-prod": "vue-cli-service build --mode prod",
+    "lint": "vue-cli-service lint"
+  },
+  "dependencies": {
+    "@vueuse/core": "^10.4.1",
+    "axios": "^1.1.3",
+    "core-js": "^3.8.3",
+    "dayjs": "^1.11.7",
+    "lodash": "^4.17.21",
+    "mitt": "^3.0.0",
+    "v-viewer": "^3.0.11",
+    "viewerjs": "^1.11.6",
+    "vue-router": "^4.0.3",
+    "vue": "^3.2.13",
+    "vuex": "^4.0.0"
+  },
+  "devDependencies": {
+    "@babel/core": "^7.12.16",
+    "@babel/eslint-parser": "^7.12.16",
+    "@vue/cli-plugin-babel": "~5.0.0",
+    "@vue/cli-plugin-eslint": "~5.0.0",
+    "@vue/cli-plugin-router": "~5.0.0",
+    "@vue/cli-plugin-vuex": "~5.0.0",
+    "@vue/cli-service": "~5.0.0",
+    "eslint": "^7.32.0",
+    "eslint-plugin-vue": "^8.0.3",
+    "less": "^4.0.0",
+    "less-loader": "^8.0.0"
+  }
+}

+ 22 - 0
public/index.html

@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html lang="">
+  <head>
+    <meta charset="utf-8">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge">
+    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no">
+    <link rel="icon" href="<%= BASE_URL %>logo.png">
+    <title>我是标题</title>
+  </head>
+  <body>
+    <!-- <script src="https://cdn.bootcss.com/vConsole/3.2.0/vconsole.min.js"></script> -->
+    <noscript>
+      <strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
+    </noscript>
+    <div id="app"></div>
+    <!-- built files will be auto injected -->
+
+    <script>
+      // new VConsole()
+    </script>
+  </body>
+</html>

binární
public/logo.png


+ 116 - 0
src/App.vue

@@ -0,0 +1,116 @@
+<template>
+  <router-view />
+</template>
+
+<script setup>
+import { ref, computed, watch, onMounted } from "vue"
+import { useRoute, useRouter } from "vue-router"
+import { useStore } from "vuex"
+
+const route = useRoute()
+const router = useRouter()
+const store = useStore()
+</script>
+
+<style lang="less">
+// html, body {
+//   overscroll-behavior: none;
+//   overflow: hidden;
+// }
+
+// * {
+//   user-select: none;
+//   -webkit-touch-callout: none;
+// }
+
+// #app {
+//   height: 100%;
+// }
+
+// // 360浏览器不支持not()
+// input, textarea {
+//   user-select: initial;
+// }
+
+// 字体
+// @font-face {
+//   font-family: 'Source Han Serif CN';
+//   src: url('@/assets/style/SourceHanSerifCN-Regular.otf');
+// }
+// @font-face {
+//   font-family: 'Source Han Serif CN-Bold';
+//   src: url('@/assets/style/SourceHanSerifCN-Bold.otf');
+// }
+// i {
+//   font-style: italic;
+// }
+
+// 滚动条,只设置某一项可能导致不生效。
+// ::-webkit-scrollbar { background: #dddecc; width: 6px; height: 6px; }
+// ::-webkit-scrollbar-thumb { background: #828a5b; border-radius: 3px; }
+// ::-webkit-scrollbar-corner { background: #dddecc; }
+
+// vue组件过渡效果
+.fade-out-leave-active {
+  transition: opacity 1s;
+  pointer-events: none;
+}
+.fade-out-leave-to {
+  opacity: 0;
+}
+
+// vue组件过渡效果
+.fade-in-enter-active {
+  transition: opacity 1s;
+}
+.fade-in-enter-from {
+  opacity: 0;
+}
+
+.fade-out-leave-active {
+  transition: opacity 1s;
+  pointer-events: none;
+}
+.fade-out-leave-to {
+  opacity: 0;
+}
+
+.fade-in-out-enter-active {
+  transition: opacity 2s;
+}
+.fade-in-out-leave-active {
+  transition: opacity 2s;
+  pointer-events: none;
+}
+.fade-in-out-enter-from {
+  opacity: 0;
+}
+.fade-in-out-leave-to {
+  opacity: 0;
+}
+
+// 不断渐变显隐 animation
+.animation-show-hide {
+  animation: show-hide 1.8s infinite;
+}
+@keyframes show-hide {
+  0% {
+    opacity: 0;
+  }
+  50% {
+    opacity: 1;
+  }
+  100% {
+    opacity: 0;
+  }
+}
+
+// // vue-viewer
+// .viewer-container {
+//   background-color: rgba(0, 0, 0, 80%) !important;
+// }
+// 或者
+// .viewer-backdrop {
+//   background-color: rgba(0, 0, 0, 90%) !important;
+// }
+</style>

+ 17 - 0
src/api.js

@@ -0,0 +1,17 @@
+// import axios from "axios"
+
+// axios({
+//   method: 'post',
+//   url: `${config.backendDir}visit/saveType`,
+//   headers: {
+//     appId: "CA02F83A5FA162B930AA2F962D202F43B0F6DE0B51AD79FEDB03FA8202BB4909330105B3B347510D87C97060C4288280D4A744E00565A4EC",
+//     "Content-Type": "application/json",
+//   },
+//   data: {
+//     moduleType,
+//     type: 'visit',
+//   },
+// })
+
+export default {
+}

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

@@ -0,0 +1,59 @@
+* {
+  /* 阻止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.(???) */
+  height: 100%;
+}
+
+body {
+  text-align: justify;
+  height: 100%;
+  -webkit-font-smoothing: antialiased;
+  -moz-osx-font-smoothing: grayscale;
+}
+
+a {
+  color: initial;
+  text-decoration: initial;
+  outline: none;
+}
+
+button {
+  padding: 0;
+  cursor: pointer;
+  background-color: initial;
+  border: initial;
+  outline: none;
+  white-space: pre;
+}
+
+img {
+  user-select: none;
+}
+
+menu {
+  list-style-type: initial;
+}
+
+li {
+  display: initial;
+}
+
+input {
+  outline: initial;
+  background: initial;
+  border: initial;
+  border-radius: initial;
+  width: initial;
+  height: initial;
+}
+
+td {
+  vertical-align: inherit;
+}

+ 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;
+}

+ 2 - 0
src/config.js

@@ -0,0 +1,2 @@
+export default {
+}

+ 44 - 0
src/directives/v-click-outside.js

@@ -0,0 +1,44 @@
+export default {
+  install(app) {
+    app.directive('click-outside', {
+      mounted(el, binding) {
+        function documentHandler(e) {
+          if (el.contains(e.target)) {
+            return false
+          }
+          if (binding.value) {
+            binding.value(e)
+          }
+        }
+        el.__vueClickOutside__ = documentHandler
+        if (binding.modifiers.click) {
+          document.addEventListener('click', documentHandler, {
+            capture: binding.modifiers.capture
+          })
+        }
+        if (binding.modifiers.mousedown) {
+          document.addEventListener('mousedown', documentHandler, {
+            capture: binding.modifiers.capture
+          })
+        }
+        if (binding.modifiers.touchstart) {
+          document.addEventListener('touchstart', documentHandler, {
+            capture: binding.modifiers.capture
+          })
+        }
+      },
+      unMounted(el, binding) {
+        document.removeEventListener('click', el.__vueClickOutside__, {
+          capture: binding.modifiers.capture
+        })
+        document.removeEventListener('mousedown', el.__vueClickOutside__, {
+          capture: binding.modifiers.capture
+        })
+        document.removeEventListener('tarchstart', el.__vueClickOutside__, {
+          capture: binding.modifiers.capture
+        })
+        delete el.__vueClickOutside__
+      }
+    })
+  }
+}

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 4 - 0
src/libs/ua-parser.min.js


+ 100 - 0
src/main.js

@@ -0,0 +1,100 @@
+import { createApp } from 'vue'
+import App from './App.vue'
+import router from './router'
+import store from './store'
+import "@/assets/style/reset.css"
+import "@/assets/style/my-reset.css"
+import UAParser from "@/libs/ua-parser.min.js"
+import clickOutside from "@/directives/v-click-outside.js"
+import mitt from "mitt"
+import 'viewerjs/dist/viewer.css'
+import VueViewer from 'v-viewer'
+
+console.log(`version: ${process.env.VUE_APP_VERSION}`)
+console.log(`Build time: ${process.env.VUE_APP_UPDATE_TIME}`)
+
+const app = createApp(App)
+
+// 挂载配置信息
+app.provide('$config', config)
+app.provide('$env', process.env)
+
+// 挂载消息发布订阅中心
+app.provide('$mitt', mitt())
+
+// 解析、挂载浏览器信息
+const uaParser = new UAParser()
+const uaInfo = uaParser.getResult()
+console.log('uaInfo: ', uaInfo)
+app.provide('$uaInfo', uaInfo)
+if (uaInfo.browser && uaInfo.browser.name === 'WeChat') {
+  app.provide('$isWeChat', true)
+}
+if (uaInfo.browser && uaInfo.browser.name === 'Safari') {
+  app.provide('$isSafari', true)
+}
+if (uaInfo.device.type === 'mobile') {
+  app.provide('$isMobile', true)
+}
+
+// 处理resize事件
+let windowWidthLast = window.innerWidth
+let windowHeightLast = window.innerHeight
+function onResize() {
+  if (window.innerWidth === windowWidthLast) {
+    // 发生了高度变化,认为发生了软键盘显隐
+    if (uaInfo.os.name === 'Android') {
+      if (window.innerHeight < windowHeightLast) {
+        // ...
+      } else if (window.innerHeight > windowHeightLast) {
+        // ...
+      }
+    }
+  }
+  windowWidthLast = window.innerWidth
+  windowHeightLast = window.innerHeight
+}
+window.addEventListener('resize', () => {
+  onResize()
+})
+
+// // 禁用上下文菜单
+// document.oncontextmenu = function(e) {
+//   e.preventDefault()
+// }
+
+// // safari里只能在交互行为的回调中成功地首次调用audio的play方法,所以需要一个全局的audio元素来播放随时可能需要自发播放的音频。
+// const audioNode = document.createElement("audio")
+// audioNode.id = 'global-audio'
+// audioNode.style.display = 'none'
+// audioNode.loop = true
+// document.body.appendChild(audioNode)
+
+app.use(store)
+  .use(router)
+  .use(clickOutside)
+  .use(VueViewer)
+  // .component('HotSpot', HotSpot)
+  .mount('#app')
+
+//  you can reset the default options at any other time
+VueViewer.setDefaults({
+  inline: false,
+  button: true,
+  navbar: false,
+  title: false,
+  toolbar: false,
+  tooltip: false,
+  movable: true,
+  zoomable: true,
+  rotatable: false,
+  // "scalable": true,
+  transition: true,
+  fullscreen: true,
+  keyboard: true,
+})
+
+// 必须在vue根组件挂载之后执行
+if (uaInfo.device.type === 'mobile') {
+  document.getElementById('app').classList.add('mobile')
+}

+ 25 - 0
src/router/index.js

@@ -0,0 +1,25 @@
+import { createRouter, createWebHashHistory } from 'vue-router'
+import HomeView from '../views/HomeView.vue'
+// import store from '@/store/index.js'
+
+const routes = [
+  {
+    path: '/',
+    name: 'HomeView',
+    component: HomeView,
+  },
+]
+
+const router = createRouter({
+  history: createWebHashHistory(),
+  routes
+})
+
+router.beforeEach((to, from) => {
+  // 生产环境下强制每次都从首页进入
+  if (process.env.NODE_ENV === 'production' && !from.name && to.name !== 'HomeView') {
+    return '/'
+  }
+})
+
+export default router

+ 18 - 0
src/store/index.js

@@ -0,0 +1,18 @@
+import { createStore } from 'vuex'
+
+export default createStore({
+  state: {
+    usingChinese: true,
+  },
+  getters: {
+  },
+  mutations: {
+    setUsingChinese(state, value) {
+      state.usingChinese = value
+    },
+  },
+  actions: {
+  },
+  modules: {
+  }
+})

+ 37 - 0
src/useFunctions/useSizeAdapt.js

@@ -0,0 +1,37 @@
+// 用法:
+// width: calc(950 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
+
+import { onBeforeUnmount, ref } from 'vue'
+
+export default function useSizeAdapt(windowWidthWhenDesign = 1920, windowHeightWhenDesign = 1080, needReactivity = true) {
+  const windowSizeInCssForRef = ref('')
+  const windowSizeWhenDesignForRef = ref('')
+  const scaleRate = ref(-1)
+
+  function compute() {
+    if (window.innerWidth / window.innerHeight > windowWidthWhenDesign / windowHeightWhenDesign) {
+      windowSizeWhenDesignForRef.value = windowHeightWhenDesign
+      windowSizeInCssForRef.value = window.innerHeight + 'px' // 用100vh的话在移动端会有兼容性问题。
+      scaleRate.value = windowHeightWhenDesign / window.innerHeight
+    } else {
+      windowSizeWhenDesignForRef.value = windowWidthWhenDesign
+      windowSizeInCssForRef.value = '100vw'
+      scaleRate.value = windowWidthWhenDesign / window.innerWidth
+    }
+  }
+
+  compute()
+
+  if (needReactivity) {
+    window.addEventListener('resize', compute)
+    onBeforeUnmount(() => {
+      window.removeEventListener('resize', compute)
+    })
+  }
+
+  return {
+    windowSizeInCssForRef,
+    windowSizeWhenDesignForRef,
+    scaleRate,
+  }
+}

+ 70 - 0
src/utils.js

@@ -0,0 +1,70 @@
+export default {
+  /**
+   * 返回一个自带消抖效果的函数,用res表示。
+   *
+   * fn: 需要被消抖的函数
+   * delay: 消抖时长
+   * isImmediateCall: 是否在一组操作中的第一次调用时立即执行fn
+   * isRememberLastCall:是否在一组中最后一次调用后等delay时长再执行fn
+   */
+  debounce(fn, delay = 250, isImmediateCall = true, isRememberLastCall = true) {
+    console.assert(isImmediateCall || isRememberLastCall, 'isImmediateCall 和 isRememberLastCall 至少应有一个是true,否则没有意义!')
+    let timer = null
+    // 上次调用的时刻
+    let lastCallTime = 0
+
+    if (isImmediateCall && !isRememberLastCall) {
+      return function (...args) {
+        const currentTime = Date.now()
+        if (currentTime - lastCallTime >= delay) {
+          fn.apply(this, args)
+        }
+        lastCallTime = currentTime
+      }
+    } else if (!isImmediateCall && isRememberLastCall) {
+      return function (...args) {
+        if (timer) {
+          clearTimeout(timer)
+        }
+        timer = setTimeout(() => {
+          fn.apply(this, args)
+        }, delay)
+      }
+    } else if (isImmediateCall && isRememberLastCall) {
+      return function (...args) {
+        const currentTime = Date.now()
+        if (currentTime - lastCallTime >= delay) { // 一组操作中的第一次
+          fn.apply(this, args)
+          lastCallTime = currentTime
+          return
+        } else { // 一组中的后续调用
+          if (timer) { // 在此之前存在中间调用
+            lastCallTime = currentTime
+            clearTimeout(timer)
+          }
+          timer = setTimeout(() => {
+            fn.apply(this, args)
+            lastCallTime = 0
+            timer = null
+          }, delay)
+        }
+      }
+    } else {
+      console.error('不应该执行到这里!')
+    }
+  },
+  throttle(fn, interval = 250) {
+    let lastRunTime = 0
+
+    return function (...args) {
+      let elapsedTime = Date.now() - lastRunTime
+      if (elapsedTime < interval) {
+        return null
+      }
+
+      let context = this
+      lastRunTime = Date.now()
+      return fn.apply(context, args)
+    }
+  },
+}

+ 23 - 0
src/views/HomeView.vue

@@ -0,0 +1,23 @@
+<template>
+  <div
+    class="home"
+  >
+  </div>
+</template>
+
+<script setup>
+import { ref, computed, watch, onMounted } from "vue"
+import { useRoute, useRouter } from "vue-router"
+import { useStore } from "vuex"
+
+const route = useRoute()
+const router = useRouter()
+const store = useStore()
+</script>
+
+<style lang="less" scoped>
+.home {
+  width: 100%;
+  height: 100%;
+}
+</style>

+ 38 - 0
vue.config.js

@@ -0,0 +1,38 @@
+const webpack = require('webpack')
+const { defineConfig } = require('@vue/cli-service')
+
+process.env.VUE_APP_VERSION = require('./package.json').version
+
+const dayjs = require('dayjs')
+const time = dayjs().format('YYYY-M-D HH:mm:ss')
+process.env.VUE_APP_UPDATE_TIME = time
+
+module.exports = defineConfig({
+  publicPath: process.env.PUBLIC_PATH,
+  productionSourceMap: process.env.VUE_APP_CLI_MODE === 'prod' ? false : true,
+  // transpileDependencies: true, // 默认false,表示babel-loader 会忽略所有 node_modules 中的文件
+  configureWebpack: {
+    module: {
+      rules: [
+        // {
+        //   test: /\.cur$/,
+        //   use: {
+        //     loader: 'file-loader'
+        //   }
+        // }
+      ]
+    },
+    plugins: [
+      new webpack.ProvidePlugin({
+        utils: ['/src/utils.js', 'default'],
+        store: ['/src/store/index.js', 'default'],
+        api: ['/src/api.js', 'default'],
+        config: ['/src/config.js', 'default'],
+        mapState: ['vuex', 'mapState'],
+        mapGetters: ['vuex', 'mapGetters'],
+        mapMutations: ['vuex', 'mapMutations'],
+        useSizeAdapt: ['/src/useFunctions/useSizeAdapt.js', 'default'],
+      }),
+    ],
+  },
+})