任一存 1 jaar geleden
commit
17719e05b2

+ 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"]
+}

+ 39 - 0
package.json

@@ -0,0 +1,39 @@
+{
+  "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",
+    "element-plus": "^2.6.2",
+    "lodash": "^4.17.21",
+    "mapbox-gl": "^3.2.0",
+    "mitt": "^3.0.0",
+    "v-viewer": "^3.0.11",
+    "viewerjs": "^1.11.6",
+    "vue": "^3.2.13",
+    "vue-router": "^4.0.3",
+    "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"
+  }
+}

+ 24 - 0
public/index.html

@@ -0,0 +1,24 @@
+<!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>
+    
+    <script src="https://unpkg.com/@turf/turf@6/turf.min.js"></script>
+
+    <div id="app"></div>
+
+    <script>
+      // new VConsole()
+    </script>
+  </body>
+</html>

BIN
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 {
+}

BIN
src/assets/images/tower.jpg


+ 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__
+      }
+    })
+  }
+}

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


+ 104 - 0
src/main.js

@@ -0,0 +1,104 @@
+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'
+import 'mapbox-gl/dist/mapbox-gl.css'
+import ElementPlus from 'element-plus'
+import 'element-plus/dist/index.css'
+
+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)
+  .use(ElementPlus)
+  // .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)
+    }
+  },
+}

+ 398 - 0
src/views/HomeView.vue

@@ -0,0 +1,398 @@
+<template>
+  <div
+    class="home"
+  >
+    <div id="map" />
+
+    <div class="panel">
+      <el-select
+        v-model="timeInDay"
+        placeholder="Select"
+        size="large"
+      >
+        <el-option
+          v-for="item in timeOptions"
+          :key="item.value"
+          :label="item.label"
+          :value="item.value"
+        />
+      </el-select>
+      <el-checkbox
+        v-model="isShowLabels"
+        label="show labels"
+        size="large"
+      />
+      <el-checkbox
+        v-model="isShowTerrain"
+        label="show terrain"
+        size="large"
+      />
+      <el-checkbox
+        v-model="isShowFog"
+        label="show fog"
+        size="large"
+      />
+    </div>
+  </div>
+</template>
+
+<script setup>
+import { ref, computed, watch, onMounted } from "vue"
+import { useRoute, useRouter } from "vue-router"
+import { useStore } from "vuex"
+import mapboxgl from 'mapbox-gl'
+
+const route = useRoute()
+const router = useRouter()
+const store = useStore()
+
+mapboxgl.accessToken = 'pk.eyJ1IjoiamlidmFnIiwiYSI6ImNsdDVibmxvZDAwbjcyanAzNmpzOHpoeHUifQ.KKYv3iK0IiL37rNDYkb-dQ'
+
+let map = null
+
+onMounted(() => {
+  map = new mapboxgl.Map({
+    container: 'map', // container ID
+    center: [2.294444, 48.858056], // starting position [lng, lat]
+    zoom: 16, // starting zoom
+    pitch: 65,
+    maxBounds: [
+      [2.25, 48.80, ], // 西南角
+      [2.35, 48.92, ], // 东北角
+    ]
+  })
+  map.on('style.load', () => {
+    // 隐藏标签。
+    map.setConfigProperty('basemap', 'showPlaceLabels', false)
+    map.setConfigProperty('basemap', 'showRoadLabels', false)
+    map.setConfigProperty('basemap', 'showPointOfInterestLabels', false)
+    map.setConfigProperty('basemap', 'showTransitLabels', false)
+
+    // 准备 3D terrain source
+    map.addSource('mapbox-dem', {
+      'type': 'raster-dem',
+      'url': 'mapbox://mapbox.terrain-rgb',
+      'tileSize': 512,
+      'maxzoom': 14
+    })
+  })
+
+  // todo: 自动旋转开关
+  // map.on('idle', () => {
+  //   let lastFrameTime = 0.0
+  //   let animationTotalTime = 0.0
+  //   const initialBearing = map.getBearing()
+
+  //   function frameTask(timeStamp) {
+  //     animationTotalTime += ((timeStamp - lastFrameTime) / 1000.0)
+  //     const rotation = initialBearing + animationTotalTime * 2.0
+  //     map.setBearing(rotation % 360)
+  //     lastFrameTime = timeStamp
+  //     window.requestAnimationFrame(frameTask)
+  //   }
+  //   window.requestAnimationFrame(frameTask)
+  // })
+
+  map.on('click', (e) => {
+    console.log(e.lngLat.wrap())
+  })
+
+  map.on('load', () => {
+    // todo: 操控
+    // 桥梁高亮
+    map.addSource('bridge-demo-1', {
+      'type': 'geojson',
+      'data': {
+        'type': 'Feature',
+        'properties': {},
+        'geometry': {
+          'type': 'LineString',
+          'coordinates': [
+            [
+              2.291370903863708,
+              48.860291730262816
+            ],
+            [
+              2.2926683589130334,
+              48.85941742662925
+            ],
+          ]
+        }
+      }
+    })
+    map.addSource('bridge-demo-2', {
+      'type': 'geojson',
+      'data': {
+        'type': 'Feature',
+        'properties': {},
+        'geometry': {
+          'type': 'LineString',
+          'coordinates': [
+            [
+              2.2867527694825185,
+              48.85655006915218
+            ],
+            [
+              2.28846012300869,
+              48.85483140541177
+            ],
+          ]
+        }
+      }
+    })
+    map.addSource('bridge-demo-3', {
+      'type': 'geojson',
+      'data': {
+        'type': 'Feature',
+        'properties': {},
+        'geometry': {
+          'type': 'LineString',
+          'coordinates': [
+            [
+              2.3016957824563633,
+              48.86404969411541
+            ],
+            [
+              2.3018487764027213,
+              48.862882778017564
+            ],
+          ]
+        }
+      }
+    })
+    map.addLayer({
+      'id': 'bridge-demo-1',
+      'type': 'line',
+      'source': 'bridge-demo-1',
+      'layout': {
+        'line-join': 'round',
+        'line-cap': 'round'
+      },
+      'paint': {
+        'line-color': 'rgba(244, 208, 133, 0.8)',
+        'line-width': 40,
+      }
+    })
+    map.addLayer({
+      'id': 'bridge-demo-2',
+      'type': 'line',
+      'source': 'bridge-demo-2',
+      'layout': {
+        'line-join': 'round',
+        'line-cap': 'round'
+      },
+      'paint': {
+        'line-color': 'rgba(244, 208, 133, 0.8)',
+        'line-width': 40,
+      }
+    })
+    map.addLayer({
+      'id': 'bridge-demo-3',
+      'type': 'line',
+      'source': 'bridge-demo-3',
+      'layout': {
+        'line-join': 'round',
+        'line-cap': 'round'
+      },
+      'paint': {
+        'line-color': 'rgba(244, 208, 133, 0.8)',
+        'line-width': 40,
+      }
+    })
+
+    // todo:操控
+    // 操场高亮
+    // Add a data source containing GeoJSON data.
+    map.addSource('playground', {
+      'type': 'geojson',
+      'data': {
+        'type': 'Feature',
+        'geometry': {
+          'type': 'Polygon',
+          // These coordinates outline playground.
+          'coordinates': [
+            [
+              [2.290685454637469, 48.85648212786501],
+              [2.290678167471242, 48.85674317251818],
+              [2.2909987705963886, 48.856988869994325],
+              [2.2913584104396705, 48.85706691648497],
+              [2.2926340590652217, 48.856240774123734],
+              [2.2926899302722177, 48.85607261804398],
+              [2.291903329216666, 48.85567435087097],
+              [2.2916458346767286, 48.855731990701315],
+            ]
+          ]
+        }
+      }
+    })
+    map.addLayer({
+      'id': 'playground',
+      'type': 'fill',
+      'source': 'playground', // reference the data source
+      'layout': {},
+      'paint': {
+        'fill-color': '#0080ff', // blue color fill
+        'fill-opacity': 0.5
+      }
+    })
+  })
+})
+
+// 时间选择
+const timeOptions = [
+  {
+    label: 'dusk',
+    value: 'dusk',
+  },
+  {
+    label: 'day',
+    value: 'day',
+  },
+  {
+    label: 'dawn',
+    value: 'dawn',
+  },
+  {
+    label: 'night',
+    value: 'night',
+  },
+]
+const timeInDay = ref(timeOptions[1].value)
+watch(timeInDay, (v) => {
+  map.setConfigProperty('basemap', 'lightPreset', v) // dusk, dawn, day, and night
+  if (isShowFog.value) {
+    if (timeInDay.value === 'day') {
+      map.setFog({
+        'range': [-1, 2],
+        'horizon-blend': 0.3,
+        'color': 'white',
+        'high-color': '#add8e6',
+        'space-color': '#d8f2ff',
+        'star-intensity': 0.0
+      })
+    } else if (timeInDay.value === 'dusk' || timeInDay.value === 'dawn') {
+      map.setFog({
+        'range': [-1, 2],
+        'horizon-blend': 0.3,
+        'color': '#999',
+        'high-color': '#add8e6',
+        'space-color': '#d8f2ff',
+        'star-intensity': 0.4
+      })
+    } else {
+      map.setFog({
+        'range': [-1, 2],
+        'horizon-blend': 0.3,
+        'color': '#242B4B',
+        'high-color': '#161B36',
+        'space-color': '#0B1026',
+        'star-intensity': 0.8
+      })
+    }
+  }
+})
+
+
+// 标签开关
+const isShowLabels = ref(false)
+watch(isShowLabels, (v) => {
+  map.setConfigProperty('basemap', 'showPlaceLabels', v)
+  map.setConfigProperty('basemap', 'showRoadLabels', v)
+  map.setConfigProperty('basemap', 'showPointOfInterestLabels', v)
+  map.setConfigProperty('basemap', 'showTransitLabels', v)
+})
+
+// 地形开关
+const isShowTerrain = ref(false)
+watch(isShowTerrain, (v) => {
+  if (v) {
+    map.setTerrain({
+      'source': 'mapbox-dem',
+      'exaggeration': 1
+    })
+  } else {
+    map.setTerrain(null)
+  }
+})
+
+// 雾开关
+const isShowFog = ref(false)
+watch(isShowFog, (v) => {
+  if (v) {
+    if (timeInDay.value === 'day') {
+      map.setFog({
+        'range': [-1, 2],
+        'horizon-blend': 0.3,
+        'color': 'white',
+        'high-color': '#add8e6',
+        'space-color': '#d8f2ff',
+        'star-intensity': 0.0
+      })
+    } else if (timeInDay.value === 'dusk' || timeInDay.value === 'dawn') {
+      map.setFog({
+        'range': [-1, 2],
+        'horizon-blend': 0.3,
+        'color': '#999',
+        'high-color': '#add8e6',
+        'space-color': '#d8f2ff',
+        'star-intensity': 0.4
+      })
+    } else {
+      map.setFog({
+        'range': [-1, 2],
+        'horizon-blend': 0.3,
+        'color': '#242B4B',
+        'high-color': '#161B36',
+        'space-color': '#0B1026',
+        'star-intensity': 0.8
+      })
+    }
+  } else {
+    map.setFog(null)
+  }
+})
+
+
+
+
+
+// 一种style可有多个layer,每个layer有对应的source。
+
+// todo: 日照控件
+
+// todo: 道路显隐控件
+// map.setPaintProperty('route', 'line-opacity', 0.9);
+
+// 添加自定义图层。同一个slot内的各个图层用beforeId参数指定顺序。
+// map.addLayer({ type: 'line', slot: 'middle' /* ... */ });
+
+
+
+// 移除图层
+//
+</script>
+
+<style lang="less" scoped>
+.home {
+  position: absolute;
+  left: 0;
+  top: 0;
+  width: 100%;
+  height: 100%;
+  #map{
+    position: absolute;
+    left: 0;
+    top: 0;
+    width: 100%;
+    height: 100%;
+  }
+  .panel{
+    position: absolute;
+    top: 0;
+    left: 0;
+    padding: 10px;
+    display: flex;
+    flex-direction: column;
+  }
+}
+</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'],
+      }),
+    ],
+  },
+})

File diff suppressed because it is too large
+ 6773 - 0
yarn.lock