全部修改架构
This commit is contained in:
72
src/config/CustomOrbitControls.js
Normal file
72
src/config/CustomOrbitControls.js
Normal file
@@ -0,0 +1,72 @@
|
||||
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js';
|
||||
|
||||
class CustomOrbitControls extends OrbitControls {
|
||||
constructor(object, domElement) {
|
||||
super(object, domElement);
|
||||
}
|
||||
|
||||
_handleTouchMoveDolly(event) {
|
||||
const scale = this.getZoomScale();
|
||||
|
||||
if (event.touches.length < 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
const dx = event.touches[0].pageX - event.touches[1].pageX;
|
||||
const dy = event.touches[0].pageY - event.touches[1].pageY;
|
||||
|
||||
if (dx === undefined || dy === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
const distance = Math.sqrt(dx * dx + dy * dy);
|
||||
|
||||
if (distance === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (distance > this._touchZoomDistanceStart) {
|
||||
this.scale /= scale;
|
||||
} else {
|
||||
this.scale *= scale;
|
||||
}
|
||||
|
||||
this._touchZoomDistanceEnd = distance;
|
||||
}
|
||||
|
||||
_handleTouchMoveDollyPan(event) {
|
||||
if (event.touches.length < 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
const dx = event.touches[0].pageX - event.touches[1].pageX;
|
||||
const dy = event.touches[0].pageY - event.touches[1].pageY;
|
||||
|
||||
if (dx === undefined || dy === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
const distance = Math.sqrt(dx * dx + dy * dy);
|
||||
|
||||
if (distance === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
const scale = this.getZoomScale();
|
||||
|
||||
if (distance > this._touchZoomDistanceStart) {
|
||||
this.scale /= scale;
|
||||
} else {
|
||||
this.scale *= scale;
|
||||
}
|
||||
|
||||
this._touchZoomDistanceEnd = distance;
|
||||
|
||||
const center = this._getPointerCenter(event.touches);
|
||||
if (center) {
|
||||
this._panDelta(center);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default CustomOrbitControls;
|
||||
@@ -1,4 +1,4 @@
|
||||
import {post, get} from '@config/http.js'
|
||||
import {post, get} from './http.js'
|
||||
|
||||
// 登录
|
||||
export const authlogin = (username, password) => post('auth/login', {
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import axios from 'axios'
|
||||
import store from '../vuex/store'
|
||||
import i18n from '../i18n/i18n'
|
||||
|
||||
const urlHost = process.env.VUE_APP_API_BASE_URL
|
||||
|
||||
axios.defaults.timeout = 50000
|
||||
axios.defaults.headers.post['Content-Type'] = 'application/json;charset=UTF-8'
|
||||
// 补充GET请求默认Content-Type(可选,GET请求通常无需此配置,但部分后端可能需要)
|
||||
@@ -10,14 +11,6 @@ axios.defaults.headers.get['Content-Type'] = 'application/json;charset=UTF-8'
|
||||
// 请求拦截器
|
||||
axios.interceptors.request.use(
|
||||
config => {
|
||||
let token = ''
|
||||
if (store.getters.userInfo !== '') {
|
||||
token = JSON.parse(store.getters.userInfo).token
|
||||
}
|
||||
token && (config.headers.Authorization = token)
|
||||
if (config.method === 'post') {
|
||||
config.data = config.data
|
||||
}
|
||||
config.headers['Accept-Language'] = i18n.locale === 'en-us' ? 'en' : 'zh'
|
||||
return config
|
||||
},
|
||||
@@ -59,7 +52,7 @@ axios.interceptors.response.use(
|
||||
|
||||
export const post = (sevmethod, params) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios.post(`${store.getters.baseUrl}/${sevmethod}`, params)
|
||||
axios.post(`${urlHost}/${sevmethod}`, params)
|
||||
.then(response => {
|
||||
resolve(response.data)
|
||||
})
|
||||
@@ -71,7 +64,7 @@ export const post = (sevmethod, params) => {
|
||||
|
||||
export const get = (sevmethod, params = {}) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios.get(`${store.getters.baseUrl}/${sevmethod}`, { params })
|
||||
axios.get(`${urlHost}/${sevmethod}`, { params })
|
||||
.then(response => {
|
||||
resolve(response.data)
|
||||
})
|
||||
|
||||
4804
src/config/point.js
Normal file
4804
src/config/point.js
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,6 @@
|
||||
|
||||
// import { getToken } from '@/utils/authToken' // 与后端的协商,websocket请求需要带上token参数
|
||||
import Vue from 'vue'
|
||||
let websock = null
|
||||
let messageCallback = null
|
||||
let errorCallback = null
|
||||
@@ -36,7 +37,7 @@ function websocketclose (e) {
|
||||
// e.code === 1000 表示正常关闭。 无论为何目的而创建, 该链接都已成功完成任务。
|
||||
// e.code !== 1000 表示非正常关闭。
|
||||
if (e && e.code !== 1000) {
|
||||
this.$message.error('server error')
|
||||
Vue.prototype.$message.error('server error')
|
||||
errorCallback()
|
||||
// // 如果需要设置异常重连则可替换为下面的代码,自行进行测试
|
||||
// if (tryTime < 10) {
|
||||
@@ -52,14 +53,14 @@ function websocketclose (e) {
|
||||
}
|
||||
}
|
||||
// 建立ws连接
|
||||
function websocketOpen (e) {
|
||||
function websocketOpen () {
|
||||
// console.log('ws连接成功')
|
||||
}
|
||||
|
||||
// 初始化weosocket
|
||||
function initWebSocket () {
|
||||
if (typeof (WebSocket) === 'undefined') {
|
||||
this.$message.error('您的浏览器不支持WebSocket,无法获取数据')
|
||||
Vue.prototype.$message.error('您的浏览器不支持WebSocket,无法获取数据')
|
||||
return false
|
||||
}
|
||||
// ws请求完整地址
|
||||
|
||||
Reference in New Issue
Block a user