update
This commit is contained in:
+22
-11
@@ -4,6 +4,8 @@ import { useUserStore } from '/@/store/modules/user.ts';
|
|||||||
import { getAuthCache } from '/@/utils/auth.ts';
|
import { getAuthCache } from '/@/utils/auth.ts';
|
||||||
import { TOKEN_KEY } from '/@/enum/cacheEnum.ts';
|
import { TOKEN_KEY } from '/@/enum/cacheEnum.ts';
|
||||||
import { useMessage } from '/@/hooks/web/useMessage.ts';
|
import { useMessage } from '/@/hooks/web/useMessage.ts';
|
||||||
|
import { checkStatus } from '/@/api/checkStatus.ts';
|
||||||
|
import router from '/@/router';
|
||||||
|
|
||||||
const { createMessage, createErrorModal } = useMessage();
|
const { createMessage, createErrorModal } = useMessage();
|
||||||
const { VITE_GLOB_API_URL } = getAppEnvConfig();
|
const { VITE_GLOB_API_URL } = getAppEnvConfig();
|
||||||
@@ -17,18 +19,27 @@ const service = axios.create({
|
|||||||
'Content-Type': 'application/json;charset=UTF-8',
|
'Content-Type': 'application/json;charset=UTF-8',
|
||||||
'X-Access-Token': token || getAuthCache(TOKEN_KEY),
|
'X-Access-Token': token || getAuthCache(TOKEN_KEY),
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* @description: 响应错误处理
|
|
||||||
*/
|
|
||||||
responseInterceptorsCatch(error: any) {
|
|
||||||
const { response, code, message, config } = error || {};
|
|
||||||
const errorMessageMode = config?.requestOptions?.errorMessageMode || 'none';
|
|
||||||
if (errorMessageMode === 'message') {
|
|
||||||
createMessage.error(message);
|
|
||||||
}
|
|
||||||
return Promise.reject(error);
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
service.interceptors.request.use((config, options) => {
|
||||||
|
config.headers['X-Access-Token'] = token || getAuthCache(TOKEN_KEY);
|
||||||
|
return config;
|
||||||
|
});
|
||||||
|
service.interceptors.response.use(
|
||||||
|
(response) => {
|
||||||
|
return response;
|
||||||
|
},
|
||||||
|
(error) => {
|
||||||
|
if (error.response) {
|
||||||
|
switch (error.response.data.code) {
|
||||||
|
case 401:
|
||||||
|
router.replace({
|
||||||
|
path: '/login',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Promise.reject(error.response.data); // 返回接口返回的错误信息
|
||||||
|
}
|
||||||
|
);
|
||||||
export const get = (url, params = {}) => {
|
export const get = (url, params = {}) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
service
|
service
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 3.9 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 3.7 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 3.4 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 3.4 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 3.3 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.8 KiB |
@@ -148,7 +148,6 @@ export const Map = {
|
|||||||
|
|
||||||
this.overlayGroup.on('click', function (e) {
|
this.overlayGroup.on('click', function (e) {
|
||||||
//拿到点中携带的数据
|
//拿到点中携带的数据
|
||||||
// console.log(e.target.getExtData());
|
|
||||||
if (!isFunction(callback)) return;
|
if (!isFunction(callback)) return;
|
||||||
callback(e.target.getExtData());
|
callback(e.target.getExtData());
|
||||||
});
|
});
|
||||||
@@ -166,7 +165,6 @@ export const Map = {
|
|||||||
* @param result
|
* @param result
|
||||||
*/
|
*/
|
||||||
createAircraft(result: ResultType[]) {
|
createAircraft(result: ResultType[]) {
|
||||||
console.log('result', result);
|
|
||||||
this.removeOverlayGroup();
|
this.removeOverlayGroup();
|
||||||
this.clearActiveHospital();
|
this.clearActiveHospital();
|
||||||
// debugger;
|
// debugger;
|
||||||
@@ -180,7 +178,6 @@ export const Map = {
|
|||||||
arr,
|
arr,
|
||||||
{
|
{
|
||||||
renderMarker: (context) => {
|
renderMarker: (context) => {
|
||||||
console.log('context', context);
|
|
||||||
let factor = Math.pow(context.count / count, 1 / 18);
|
let factor = Math.pow(context.count / count, 1 / 18);
|
||||||
let div = document.createElement('div');
|
let div = document.createElement('div');
|
||||||
div.className = 'render-air';
|
div.className = 'render-air';
|
||||||
|
|||||||
@@ -39,7 +39,7 @@
|
|||||||
const dataSource = ref([]);
|
const dataSource = ref([]);
|
||||||
const pagination = ref({
|
const pagination = ref({
|
||||||
current: 1,
|
current: 1,
|
||||||
pageSize: 2,
|
pageSize: 10,
|
||||||
total: 0,
|
total: 0,
|
||||||
onChange: pageChange,
|
onChange: pageChange,
|
||||||
});
|
});
|
||||||
@@ -90,7 +90,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function interval() {
|
function interval() {
|
||||||
console.log(55555);
|
|
||||||
// timer.value = setInterval(() => {
|
// timer.value = setInterval(() => {
|
||||||
let page = pagination.value.current < pages.value ? pagination.value.current + 1 : 1;
|
let page = pagination.value.current < pages.value ? pagination.value.current + 1 : 1;
|
||||||
init(page);
|
init(page);
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import AllLookItem from '/@/views/healthMonitor/healMonitorManage/monitorToll/userInfo/componets/allLookItem.vue';
|
import AllLookItem from '/@/components/secondaryScreen/secondMap/components/userInfoModal/allLookItem.vue';
|
||||||
import { propTypes } from '/@/utils/propTypes';
|
import { propTypes } from '/@/utils/propTypes';
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
@@ -29,4 +29,4 @@
|
|||||||
emit('changeParamsDate', v.target.value);
|
emit('changeParamsDate', v.target.value);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<style scoped lang="less"></style>
|
<style scoped lang="less"></style>
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
<div style="display: flex; margin-top: 20px">
|
<div style="display: flex; margin-top: 20px">
|
||||||
<div style="width: calc(70% - 20px); border: 1px solid #ededed; padding: 20px">
|
<div style="width: calc(70% - 20px); border: 1px solid #ededed; padding: 20px">
|
||||||
<div style="display: flex; align-items: center; padding: 10px 0; justify-content: flex-start">
|
<div style="display: flex; align-items: center; padding: 10px 0; justify-content: flex-start">
|
||||||
<img src="../../../../../../assets/images/allLook/heart_rate.png" alt="" />
|
<img :src="heart_rate" alt="" />
|
||||||
心率
|
心率
|
||||||
</div>
|
</div>
|
||||||
<div style="display: flex">
|
<div style="display: flex">
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div style="width: 30%; margin-left: 20px; border: 1px solid #ededed; padding: 20px">
|
<div style="width: 30%; margin-left: 20px; border: 1px solid #ededed; padding: 20px">
|
||||||
<div style="display: flex; align-items: center; padding: 10px 0; justify-content: flex-start">
|
<div style="display: flex; align-items: center; padding: 10px 0; justify-content: flex-start">
|
||||||
<img src="../../../../../../assets/images/allLook/blood_oxygen.png" alt="" />
|
<img :src="blood" alt="" />
|
||||||
血氧
|
血氧
|
||||||
</div>
|
</div>
|
||||||
<div style="display: flex">
|
<div style="display: flex">
|
||||||
@@ -56,7 +56,7 @@
|
|||||||
<div style="display: flex; margin-top: 20px">
|
<div style="display: flex; margin-top: 20px">
|
||||||
<div style="width: calc(70% - 20px); border: 1px solid #ededed; padding: 20px">
|
<div style="width: calc(70% - 20px); border: 1px solid #ededed; padding: 20px">
|
||||||
<div style="display: flex; align-items: center; padding: 10px 0; justify-content: flex-start">
|
<div style="display: flex; align-items: center; padding: 10px 0; justify-content: flex-start">
|
||||||
<img src="../../../../../../assets/images/allLook/sleep.png" alt="" />
|
<img :src="sleep" alt="" />
|
||||||
睡眠
|
睡眠
|
||||||
</div>
|
</div>
|
||||||
<div style="display: flex">
|
<div style="display: flex">
|
||||||
@@ -92,7 +92,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div style="width: 30%; margin-left: 20px; border: 1px solid #ededed; padding: 20px">
|
<div style="width: 30%; margin-left: 20px; border: 1px solid #ededed; padding: 20px">
|
||||||
<div style="display: flex; align-items: center; padding: 10px 0; justify-content: flex-start">
|
<div style="display: flex; align-items: center; padding: 10px 0; justify-content: flex-start">
|
||||||
<img src="../../../../../../assets/images/allLook/pressure.png" alt="" />
|
<img :src="pressure" alt="" />
|
||||||
压力
|
压力
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -117,7 +117,7 @@
|
|||||||
<div style="display: flex; margin-top: 20px">
|
<div style="display: flex; margin-top: 20px">
|
||||||
<div style="width: 100%; border: 1px solid #ededed">
|
<div style="width: 100%; border: 1px solid #ededed">
|
||||||
<div style="display: flex; align-items: center; padding: 30px 20px 10px; justify-content: flex-start">
|
<div style="display: flex; align-items: center; padding: 30px 20px 10px; justify-content: flex-start">
|
||||||
<img src="../../../../../../assets/images/allLook/motion.png" alt="" />
|
<img :src="temperature" alt="" />
|
||||||
运动
|
运动
|
||||||
</div>
|
</div>
|
||||||
<div style="display: flex; justify-content: space-between">
|
<div style="display: flex; justify-content: space-between">
|
||||||
@@ -177,7 +177,7 @@
|
|||||||
<div style="display: flex; margin-top: 20px">
|
<div style="display: flex; margin-top: 20px">
|
||||||
<div style="width: calc(70% - 20px); border: 1px solid #ededed; padding: 20px">
|
<div style="width: calc(70% - 20px); border: 1px solid #ededed; padding: 20px">
|
||||||
<div style="display: flex; align-items: center; padding: 10px 0; justify-content: flex-start">
|
<div style="display: flex; align-items: center; padding: 10px 0; justify-content: flex-start">
|
||||||
<img src="../../../../../../assets/images/allLook/temperature.png" alt="" />
|
<img :src="temperature" alt="" />
|
||||||
体温
|
体温
|
||||||
</div>
|
</div>
|
||||||
<div style="display: flex">
|
<div style="display: flex">
|
||||||
@@ -212,6 +212,11 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { propTypes } from '/@/utils/propTypes';
|
import { propTypes } from '/@/utils/propTypes';
|
||||||
|
|
||||||
|
const blood = new URL('/@/assets/images/blood_oxygen.png', import.meta.url).href;
|
||||||
|
const heart_rate = new URL('/@/assets/images/heart_rate.png', import.meta.url).href;
|
||||||
|
const temperature = new URL('/@/assets/images/temperature.png', import.meta.url).href;
|
||||||
|
const pressure = new URL('/@/assets/images/pressure.png', import.meta.url).href;
|
||||||
|
const sleep = new URL('/@/assets/images/sleep.png', import.meta.url).href;
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
infoData: propTypes.object.def({}),
|
infoData: propTypes.object.def({}),
|
||||||
});
|
});
|
||||||
@@ -226,6 +231,7 @@
|
|||||||
function getC(c) {
|
function getC(c) {
|
||||||
return c === 0 ? 0 + '(千卡)' : parseFloat(c / 1000).toFixed(3) + '(千卡)';
|
return c === 0 ? 0 + '(千卡)' : parseFloat(c / 1000).toFixed(3) + '(千卡)';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getK(k) {
|
function getK(k) {
|
||||||
return k === 0 ? 0 + '(km)' : parseFloat(k / 1000).toFixed(3) + '(km)';
|
return k === 0 ? 0 + '(km)' : parseFloat(k / 1000).toFixed(3) + '(km)';
|
||||||
}
|
}
|
||||||
@@ -243,15 +249,19 @@
|
|||||||
height: 30px;
|
height: 30px;
|
||||||
margin-right: 5px;
|
margin-right: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.label-d {
|
.label-d {
|
||||||
width: 50%;
|
width: 50%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.value-d {
|
.value-d {
|
||||||
width: 50%;
|
width: 50%;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.border-d {
|
.border-d {
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
||||||
&:after {
|
&:after {
|
||||||
content: '';
|
content: '';
|
||||||
height: 90%;
|
height: 90%;
|
||||||
@@ -262,8 +272,10 @@
|
|||||||
background-color: #d3d3d3;
|
background-color: #d3d3d3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.border-d-d {
|
.border-d-d {
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
||||||
&:after {
|
&:after {
|
||||||
content: '';
|
content: '';
|
||||||
height: 90%;
|
height: 90%;
|
||||||
@@ -274,10 +286,11 @@
|
|||||||
background-color: #d3d3d3;
|
background-color: #d3d3d3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.label-d,
|
.label-d,
|
||||||
.value-d {
|
.value-d {
|
||||||
div {
|
div {
|
||||||
padding: 5px 0;
|
padding: 5px 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -1,10 +1,30 @@
|
|||||||
import { get } from '/@/api/request.ts';
|
import { get, post } from '/@/api/request.ts';
|
||||||
|
|
||||||
export enum Api {
|
export enum Api {
|
||||||
footerStatistic = '/health-watch/watch/deptStatisticData/listByorgCode',
|
footerStatistic = '/health-watch/watch/deptStatisticData/listByorgCode',
|
||||||
mapListApi = '/health-watch/watch/watchDevice/getMapList',
|
mapListApi = '/health-watch/watch/watchDevice/getMapList',
|
||||||
getUserListByDeptId = '/health-watch/watch/watchDevice/getUserListByDeptId',
|
getUserListByDeptId = '/health-watch/watch/watchDevice/getUserListByDeptId',
|
||||||
queryAllStatistics = '/health-watch/watch/watchData/queryAllStatistics',
|
queryAllStatistics = '/health-watch/watch/watchData/queryAllStatistics',
|
||||||
|
// 心率
|
||||||
|
queryHeartRateStatistics = '/health-watch/watch/watchData/queryHeartRateStatistics',
|
||||||
|
queryHeartRateStatisticsPage = '/health-watch/watch/watchData/queryHeartRateStatisticsPage',
|
||||||
|
// 血氧
|
||||||
|
queryBloodOxygenStatistics = '/health-watch/watch/watchData/queryBloodOxygenStatistics',
|
||||||
|
queryBloodOxygenStatisticsPage = '/health-watch/watch/watchData/queryBloodOxygenStatisticsPage',
|
||||||
|
// 压力
|
||||||
|
queryStressStatistics = '/health-watch/watch/watchData/queryStressStatistics',
|
||||||
|
queryStressStatisticsPage = '/health-watch/watch/watchData/queryStressStatisticsPage',
|
||||||
|
// 睡眠
|
||||||
|
querySleepStatistics = '/health-watch/watch/watchData/querySleepStatistics',
|
||||||
|
querySleepStatisticsPage = '/health-watch/watch/watchData/querySleepStatisticsPage',
|
||||||
|
// 体温
|
||||||
|
queryBodyTemperatureStat = '/health-watch/watch/watchData/queryBodyTemperatureStat',
|
||||||
|
queryBodyTemperatureStatPage = '/health-watch/watch/watchData/queryBodyTemperatureStatPage',
|
||||||
|
// 锻炼
|
||||||
|
queryExercisePage = '/health-watch/watch/watchData/queryExercisePage',
|
||||||
|
// 步数
|
||||||
|
queryStepStatistics = '/health-watch/watch/watchData/queryStepStatistics',
|
||||||
|
queryStepStatisticsPage = '/health-watch/watch/watchData/queryStepStatisticsPage',
|
||||||
// 获取是否有数据
|
// 获取是否有数据
|
||||||
userDataDayByYear = '/health-watch/watch/watchData/userDataDayByYear',
|
userDataDayByYear = '/health-watch/watch/watchData/userDataDayByYear',
|
||||||
}
|
}
|
||||||
@@ -18,3 +38,21 @@ export const mapListApi = (params) => get(Api.mapListApi, params);
|
|||||||
export const getUserListByDeptId = (params) => get(Api.getUserListByDeptId, params);
|
export const getUserListByDeptId = (params) => get(Api.getUserListByDeptId, params);
|
||||||
export const queryAllStatisticsApi = (params) => get(Api.queryAllStatistics, params);
|
export const queryAllStatisticsApi = (params) => get(Api.queryAllStatistics, params);
|
||||||
export const userDataDayByYearApi = (params) => get(Api.userDataDayByYear, params);
|
export const userDataDayByYearApi = (params) => get(Api.userDataDayByYear, params);
|
||||||
|
// 血氧
|
||||||
|
export const queryBloodOxygenStatisticsApi = (params: any) => post(Api.queryBloodOxygenStatistics, params);
|
||||||
|
export const queryBloodOxygenStatisticsPageApi = (params: any) => post(Api.queryBloodOxygenStatisticsPage, params);
|
||||||
|
// 压力
|
||||||
|
export const queryStressStatisticsApi = (params: any) => post(Api.queryBloodOxygenStatisticsPage, params);
|
||||||
|
export const queryStressStatisticsPageApi = (params: any) => post(Api.queryStressStatisticsPage, params);
|
||||||
|
// 睡眠
|
||||||
|
export const querySleepStatisticsApi = (params: any) => post(Api.querySleepStatistics, params);
|
||||||
|
export const querySleepStatisticsPageApi = (params: any) => post(Api.querySleepStatisticsPage, params);
|
||||||
|
// 体温
|
||||||
|
export const queryBodyTemperatureStatApi = (params: any) => post(Api.queryBodyTemperatureStat, params);
|
||||||
|
export const queryBodyTemperatureStatPageApi = (params: any) => post(Api.queryBodyTemperatureStatPage, params);
|
||||||
|
// 锻炼
|
||||||
|
export const queryExercisePageApi = (params: any) => post(Api.queryExercisePage, params);
|
||||||
|
// 步数
|
||||||
|
export const queryStepStatisticsApi = (params: any) => post(Api.queryStepStatistics, params);
|
||||||
|
export const queryStepStatisticsPageApi = (params: any) => post(Api.queryStepStatisticsPage, params);
|
||||||
|
|
||||||
|
|||||||
+24
-1
@@ -1,4 +1,6 @@
|
|||||||
import { createRouter, createWebHistory, Router, RouteRecordRaw } from 'vue-router';
|
import {createRouter, createWebHistory, Router, RouteRecordRaw} from 'vue-router';
|
||||||
|
import {getAuthCache} from '/@/utils/auth.ts';
|
||||||
|
import {TOKEN_KEY} from '/@/enum/cacheEnum.ts';
|
||||||
|
|
||||||
const routes: Array<RouteRecordRaw> = [
|
const routes: Array<RouteRecordRaw> = [
|
||||||
{
|
{
|
||||||
@@ -34,6 +36,27 @@ const routes: Array<RouteRecordRaw> = [
|
|||||||
|
|
||||||
const router: Router = createRouter({
|
const router: Router = createRouter({
|
||||||
history: createWebHistory('/'),
|
history: createWebHistory('/'),
|
||||||
|
// mode: 'hash',
|
||||||
routes: [...routes],
|
routes: [...routes],
|
||||||
});
|
});
|
||||||
|
let token = getAuthCache(TOKEN_KEY);
|
||||||
|
// router.beforeEach((to, from, next) => {
|
||||||
|
// console.log('to', to);
|
||||||
|
// console.log('token', token);
|
||||||
|
// // token = null;
|
||||||
|
// if (token) {
|
||||||
|
// // 如果已经登录的话
|
||||||
|
// next();
|
||||||
|
// } else {
|
||||||
|
// if (to.path === '/login') {
|
||||||
|
// // 如果是登录页面的话,直接next()
|
||||||
|
// next();
|
||||||
|
// } else {
|
||||||
|
// // 否则 跳转到登录页面
|
||||||
|
// next({
|
||||||
|
// path: '/login',
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// });
|
||||||
export default router;
|
export default router;
|
||||||
|
|||||||
@@ -93,7 +93,8 @@ export const useUserStore = defineStore({
|
|||||||
this.setToken('');
|
this.setToken('');
|
||||||
this.setUserInfo(null);
|
this.setUserInfo(null);
|
||||||
this.setLoginInfo(null);
|
this.setLoginInfo(null);
|
||||||
goLogin && (await router.push({ path: PageEnum.BASE_LOGIN }));
|
console.log('goLogin', goLogin);
|
||||||
|
goLogin && router.replace({ path: PageEnum.BASE_LOGIN });
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
+17
-6
@@ -1,30 +1,40 @@
|
|||||||
import { onMounted, onUnmounted, ref } from 'vue';
|
import { onMounted, onUnmounted, ref } from 'vue';
|
||||||
import { getAppEnvConfig } from '/@/utils/env.ts';
|
import { getAppEnvConfig } from '/@/utils/env.ts';
|
||||||
|
import { useUserStore } from '/@/store/modules/user.ts';
|
||||||
|
import { getAuthCache } from '/@/utils/auth.ts';
|
||||||
|
import { TOKEN_KEY } from '/@/enum/cacheEnum.ts';
|
||||||
|
import { useRouter } from 'vue-router';
|
||||||
|
|
||||||
|
const router = useRouter();
|
||||||
|
const userStore = useUserStore();
|
||||||
|
const { token } = userStore;
|
||||||
const { VITE_GLOB_API_YIN_JI, VITE_GLOB_API_JIAN_CE } = getAppEnvConfig();
|
const { VITE_GLOB_API_YIN_JI, VITE_GLOB_API_JIAN_CE } = getAppEnvConfig();
|
||||||
//健康监测工具报警
|
//健康监测工具报警
|
||||||
export const basicPath = VITE_GLOB_API_YIN_JI;
|
export const basicPath = VITE_GLOB_API_YIN_JI;
|
||||||
//应急求助
|
//应急求助
|
||||||
export const emergencyPath = VITE_GLOB_API_JIAN_CE;
|
export const emergencyPath = VITE_GLOB_API_JIAN_CE;
|
||||||
const token =
|
let t = token || getAuthCache(TOKEN_KEY);
|
||||||
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImFkbWluIiwiaWRlbnRpZmllciI6ImU5Y2EyM2Q2OGQ4ODRkNGViYjE5ZDA3ODg5NzI3ZGFlIiwiZXhwIjoxNzAzMjExNzQ1fQ.dadvKgAgzfK6DUd8xtrgadxPbPXUsayNNSrt3mNxKC8';
|
|
||||||
|
|
||||||
export function useSocket(path = basicPath) {
|
export function useSocket(path = basicPath) {
|
||||||
const socket = ref();
|
const socket = ref();
|
||||||
let socketData = ref({});
|
let socketData = ref({});
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
|
if (!t) {
|
||||||
|
return router?.replace('/login');
|
||||||
|
}
|
||||||
if (typeof WebSocket === 'undefined') {
|
if (typeof WebSocket === 'undefined') {
|
||||||
alert('您的浏览器不支持socket');
|
alert('您的浏览器不支持socket');
|
||||||
} else {
|
} else {
|
||||||
// 实例化socket
|
// 实例化socket
|
||||||
socket.value = new WebSocket(path, [token]);
|
socket.value = new WebSocket(path, [t]);
|
||||||
// 监听socket连接
|
// 监听socket连接
|
||||||
socket.value.onopen = open;
|
socket.value.onopen = open;
|
||||||
// 监听socket错误信息
|
// 监听socket错误信息
|
||||||
socket.value.onerror = error;
|
socket.value.onerror = error;
|
||||||
// 监听socket消息
|
// 监听socket消息
|
||||||
socket.value.onmessage = getMessage;
|
socket.value.onmessage = getMessage;
|
||||||
|
socket.value.onclose = close;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,7 +47,7 @@ export function useSocket(path = basicPath) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getMessage(msg) {
|
function getMessage(msg) {
|
||||||
console.log('y', msg.data);
|
console.log('getMessage', msg);
|
||||||
socketData.value = JSON.parse(msg.data);
|
socketData.value = JSON.parse(msg.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,7 +55,8 @@ export function useSocket(path = basicPath) {
|
|||||||
socketData.value = data;
|
socketData.value = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
function close() {
|
function close(data) {
|
||||||
|
console.log(data);
|
||||||
console.log('socket已经关闭');
|
console.log('socket已经关闭');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,7 +64,7 @@ export function useSocket(path = basicPath) {
|
|||||||
init();
|
init();
|
||||||
});
|
});
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
socket.value.onclose = close;
|
//socket.value.onclose = close;
|
||||||
});
|
});
|
||||||
return { socket, socketData, setSocketData };
|
return { socket, socketData, setSocketData };
|
||||||
}
|
}
|
||||||
@@ -84,7 +84,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function clickBack() {
|
function clickBack() {
|
||||||
router.go(-1);
|
router.replace({ path: '/home' });
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
|
|||||||
Reference in New Issue
Block a user