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 getPluginList = (data: any) => server.post('/plugin/driver/_query/no-paging', data)
export const getPluginConfig = (id: string) => server.get(`/plugin/driver/${id}/description`) 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 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 removeFn = (id: string) => remove(`/plugin/driver/${id}`)
export const detail = (id: string) => get(`/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 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}`) 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 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 '*.ts';
declare module 'js-cookie'; declare module 'js-cookie';
declare module 'jetlinks-ui-components'; 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'; record.format = 'timestamp';
break; break;
case 'double': case 'double':
record.format = '%.xf'; record.format = '%.2f';
break; break;
} }
}; };

View File

@ -1219,6 +1219,10 @@ const handleSubmit = () => {
delete formData.value.template.ttsmessage; 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() formRef.value?.validate()
.then(async () => { .then(async () => {
btnLoading.value = true; btnLoading.value = true;

View File

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

View File

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