fix: 修复登录成功之后在某些情况下无法进入初始化页面

This commit is contained in:
XieYongHong 2023-04-21 14:41:06 +08:00 committed by GitHub
parent 4d9263f4fa
commit 1e37450614
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 47 additions and 23 deletions

View File

@ -1,4 +1,4 @@
<h1 align="center"> JetLinks-ui-vue v1.0.0</h1>
<h1 align="center"> JetLinks-ui-vue</h1>
## 平台简介

View File

@ -47,3 +47,7 @@ export const getClusters = () =>
export const getPluginList = (data: any) => server.post('/plugin/driver/_query/no-paging', data)
export const getPluginConfig = (id: string) => server.get(`/plugin/driver/${id}/description`)
export const getCommandsByAccess = (id: string) => server.get(`/gateway/device/${id}/commands`)
export const getCommandsDevicesByAccessId = (id: string, data: any) => server.post(`/gateway/device/${id}/command/QueryDevicePage`, data)

View File

@ -7,6 +7,8 @@ export const uploadFile = `${BASE_API_PATH}/plugin/driver/upload`
export const add = (data: any) => post('/plugin/driver', data)
export const update = (data: any) => patch('/plugin/driver', data)
export const removeFn = (id: string) => remove(`/plugin/driver/${id}`)
export const detail = (id: string) => get(`/plugin/driver/${id}`)
@ -19,7 +21,7 @@ export const detail = (id: string) => get(`/plugin/driver/${id}`)
*/
export const getProductsById = (id: string) => get(`/plugin/driver/${id}/products`)
export const savePluginData = (type: string, pluginId: string, internalId: string, externalId: string ) => patch(`/plugin/mapping/${type}/${pluginId}/${internalId}`, externalId)
export const savePluginData = (type: string, pluginId: string, internalId: string, externalId: string ) => patch(`/plugin/mapping/${type}/${pluginId}/${internalId}`, externalId, { headers: {'Content-Type': "text/plain"}})
export const getPluginData = (type: string, pluginId: string, internalId: string ) => get(`/plugin/mapping/${type}/${pluginId}/${internalId}`)
@ -27,4 +29,6 @@ export const getPublic = (id: string, path: string) => get(`/plugin/driver/${id}
export const getTypes = () => get(`/dictionary/internal-plugin-type/items`)
export const vailIdFn = (id: string ) => get(`/plugin/driver/id/_validate`, { id })
export const vailIdFn = (id: string ) => get(`/plugin/driver/id/_validate`, { id })
export const getProductByPluginId = (id: string) => get(`/plugin/driver/${id}/products`)

3
src/global.d.ts vendored
View File

@ -12,4 +12,5 @@ declare module '*.js';
declare module '*.ts';
declare module 'js-cookie';
declare module 'jetlinks-ui-components';
declare module 'vue3-json-viewer';
declare module 'vue3-json-viewer';
declare module 'event-source-polyfill';

View File

@ -143,7 +143,7 @@ const handleTypeChange = (record: IVariable) => {
record.format = 'timestamp';
break;
case 'double':
record.format = '%.xf';
record.format = '%.2f';
break;
}
};

View File

@ -1219,6 +1219,10 @@ const handleSubmit = () => {
delete formData.value.template.ttsmessage;
}
if (formData.value.provider === 'dingTalkRobotWebHook' && formData.value.template?.messageType === 'text') {
formData.value.template.text!.content = formData.value.template.message as string
}
formRef.value?.validate()
.then(async () => {
btnLoading.value = true;

View File

@ -89,7 +89,7 @@
<script setup lang="ts" name="user">
import PermissionButton from '@/components/PermissionButton/index.vue';
import AddBindUserDialog from './components/addBindUserDialog.vue';
import AddBindUserDialog from './components/AddBindUserDialog.vue';
import { getBindUserList_api, unBindUser_api } from '@/api/system/department';
import { message } from 'jetlinks-ui-components';

View File

@ -163,14 +163,14 @@
<script setup lang="ts">
import { getImage } from '@/utils/comm';
import {
config,
code,
authLogin,
getInitSet,
systemVersion,
bindInfo,
settingDetail,
} from '@/api/login';
config,
code,
authLogin,
getInitSet,
systemVersion,
bindInfo,
settingDetail, userDetail
} from '@/api/login'
import { useUserInfo } from '@/store/userInfo';
import { LocalStore } from '@/utils/comm';
import { BASE_API_PATH, TOKEN_KEY, Version_Code } from '@/utils/variable';
@ -250,18 +250,29 @@ const onFinish = async () => {
const res: any = await authLogin(form);
loading.value = false;
if (res.success) {
LocalStore.set(TOKEN_KEY, res?.result.token);
const userResp = await userDetail()
if (userResp.success) {
store.$patch({
...res.result,
username: form.username,
userInfos: {
...userResp.result,
token: res?.result.token,
},
isAdmin: userResp.username === "admin",
});
LocalStore.set(TOKEN_KEY, res?.result.token);
if (res.result.user?.username === 'admin') {
const resp: any = await getInitSet();
if (resp.status === 200 && !resp.result.length) {
window.location.href = '/#/init-home';
return;
}
if (userResp.result?.username === 'admin') {
const resp: any = await getInitSet();
if (resp.status === 200 && !resp.result.length) {
window.location.href = '/#/init-home';
return;
}
}
} else {
store.$patch({
...res.result
});
}
window.location.href = '/';
}
} catch (error) {