diff --git a/src/App.vue b/src/App.vue index b06ad71..332f8d1 100644 --- a/src/App.vue +++ b/src/App.vue @@ -10,29 +10,24 @@ import { routes } from '@/routers/index.js'; const local = zhCn; const store = useStore(); let timer = null; - const routeList = ref(routes); - const menu = computed(() => store.state.menu); // 验证 获取query中u参数 获取token -const validateQuery = () => { - const route = useRoute(); - useRouter() - .isReady() - .then(async () => { - const u = computed(() => route.query.u); - if (!u) { - // 获取url中的u参数, 没有提示缺少参数 - ElMessage.error('缺少用户信息参数'); - } else { - // 根据userId 获取token - await store.dispatch('user/getTokenByUserId', u.value); - } - }); -}; -validateQuery(); +const route = useRoute(); +useRouter() + .isReady() + .then(async () => { + const u = computed(() => route.query.u); + if (!u) { + // 获取url中的u参数, 没有提示缺少参数 + ElMessage.error('缺少用户信息参数'); + } else { + // 根据userId 获取token + await store.dispatch('user/getTokenByUserId', u.value); + } + }); const token = computed(() => store.getters['user/token']); // 获取设备数据 diff --git a/src/apis/index.js b/src/apis/index.js index 98608ba..efc13cd 100644 --- a/src/apis/index.js +++ b/src/apis/index.js @@ -23,10 +23,10 @@ export const getMonthsDate = params => http.get(`${corrosion}/statistics/months` export const getRealtimeData = params => http.get(`${corrosion}/statistics/realtime`, { params }); // 获取网络配置参数 -export const getConfigNetwork = () => http.get(`${corrosion}/config/network`); +export const getConfigNetwork = params => http.get(`${corrosion}/config/network`, { params }); // 获取功能配置参数 -export const getConfigFunction = () => http.get(`${corrosion}/config/function`); +export const getConfigFunction = params => http.get(`${corrosion}/config/function`, { params }); // 提交网络配置参数 export const createConfigNetwork = data => http.post(`${corrosion}/config/network`, data); diff --git a/src/components/device-select-and-status.vue b/src/components/device-select-and-status.vue new file mode 100644 index 0000000..82d32d5 --- /dev/null +++ b/src/components/device-select-and-status.vue @@ -0,0 +1,41 @@ + + + diff --git a/src/components/refresh.vue b/src/components/refresh.vue new file mode 100644 index 0000000..be91fc9 --- /dev/null +++ b/src/components/refresh.vue @@ -0,0 +1,19 @@ + + + + + diff --git a/src/components/search-bar.vue b/src/components/search-bar.vue index 816731f..eb5c246 100644 --- a/src/components/search-bar.vue +++ b/src/components/search-bar.vue @@ -2,7 +2,7 @@ - + @@ -26,8 +26,7 @@ const store = useStore(); const devices = computed(() => store.state.device.devices); const onSubmit = () => { - searchDeviceForm.value.validate(valid => { - console.log(valid, { ...searchDevice }); + searchDeviceForm.value.validate(() => { const { device } = searchDevice; emit('search', { deviceId: device }); }); diff --git a/src/store/user.js b/src/store/user.js index 47689fe..72e8d3e 100644 --- a/src/store/user.js +++ b/src/store/user.js @@ -12,7 +12,7 @@ export default { }, userId({ user }) { if (!user) return null; - return user.userId; + return user.id; }, }, @@ -26,7 +26,7 @@ export default { state.user = user; if (user) { localStorage.setItem('token', user.token); - localStorage.setItem('user', user); + localStorage.setItem('user', JSON.stringify(user)); } else { localStorage.removeItem('token'); localStorage.removeItem('user'); diff --git a/src/views/device-list.vue b/src/views/device-list.vue index 35341ce..4d6c85b 100644 --- a/src/views/device-list.vue +++ b/src/views/device-list.vue @@ -17,23 +17,41 @@ - - - - - - - - - + + + + + + + + + @@ -59,11 +77,13 @@ diff --git a/src/views/function-config.vue b/src/views/function-config.vue index 4f8bf1f..cbba5e9 100644 --- a/src/views/function-config.vue +++ b/src/views/function-config.vue @@ -1,4 +1,7 @@ diff --git a/src/views/network-config.vue b/src/views/network-config.vue index ac225a1..651f41e 100644 --- a/src/views/network-config.vue +++ b/src/views/network-config.vue @@ -1,4 +1,7 @@