diff --git a/src/api/Simulation.ts b/src/api/Simulation.ts index a5028d9..fca8fe5 100644 --- a/src/api/Simulation.ts +++ b/src/api/Simulation.ts @@ -16,7 +16,7 @@ export async function createSimulation(data: { mapId: number }) { * @param simulationId 仿真id */ export async function destroySimulation(data: { simulationId: string }) { - const response = await api.post(`${UriBase}/destroy`, data); + const response = await api.post(`${UriBase}/destroy/${data.simulationId}`); return response.data; } diff --git a/src/api/UserApi.ts b/src/api/UserApi.ts index 342af04..6d97396 100644 --- a/src/api/UserApi.ts +++ b/src/api/UserApi.ts @@ -42,12 +42,18 @@ interface LoginInfo { password: string; } +interface LoginRes { + code: number; + expire: string; + token: string; +} + /** * 用户登录 * @param loginInfo * @returns */ -export async function login(loginInfo: LoginInfo): Promise { +export async function login(loginInfo: LoginInfo): Promise { const info = { ...loginInfo, password: encryptPassword(loginInfo.password) }; const response = await api.post(`${UserUriBase}/login`, info); return response.data.token; diff --git a/src/configs/TokenManage.ts b/src/configs/TokenManage.ts index 11dddf9..96828b1 100644 --- a/src/configs/TokenManage.ts +++ b/src/configs/TokenManage.ts @@ -11,3 +11,11 @@ export function getJwtToken(): string | null { export function clearJwtToken(): void { sessionStorage.removeItem(JwtTokenKey); } + +export function getOnlyToken(): string | null { + // 去除token前的Bearer + let t = sessionStorage.getItem(JwtTokenKey); + const Rxg = /^Bearer /; + t = t ? t.replace(Rxg, '') : ''; + return t; +} diff --git a/src/configs/UrlManage.ts b/src/configs/UrlManage.ts index 290fe6d..b75d13b 100644 --- a/src/configs/UrlManage.ts +++ b/src/configs/UrlManage.ts @@ -4,7 +4,8 @@ function getHost(): string { // return '192.168.3.37:9091'; // return '192.168.3.15:9091'; // return '192.168.3.5:9091'; - return '192.168.3.233:9091'; + return '192.168.3.37:9091'; + // return '192.168.3.233:9091'; // return 'test.joylink.club/bjrtss-server'; } @@ -15,7 +16,8 @@ export function getHttpBase() { export function getWebsocketUrl() { const host = '192.168.3.233'; + const port = 8000; // return `ws://${host}/ws-bj`; - return `ws://${host}/connection/websocket`; + return `ws://${host}:${port}/connection/websocket`; // return `wss://${getHost()}/ws-bj`; } diff --git a/src/drawApp/lineApp.ts b/src/drawApp/lineApp.ts index d05a812..e6dff2f 100644 --- a/src/drawApp/lineApp.ts +++ b/src/drawApp/lineApp.ts @@ -41,7 +41,7 @@ import { graphicData } from 'src/protos/stationLayoutGraphics'; import { useLineStore } from 'src/stores/line-store'; import { toUint8Array } from 'js-base64'; import { getWebsocketUrl } from 'src/configs/UrlManage'; -import { getJwtToken } from 'src/configs/TokenManage'; +import { getOnlyToken } from 'src/configs/TokenManage'; import { state } from 'src/protos/device_state'; import { AxleCounting, @@ -311,11 +311,12 @@ export async function loadLineDatas(app: GraphicApp) { app.enableWsMassaging({ engine: ClientEngine.Centrifugo, wsUrl: `${getWebsocketUrl()}`, - token: getJwtToken() as string, + token: getOnlyToken() as string, }); app.subscribe({ - destination: `/simulation/${simulationId}/devices/status`, + // destination: `/simulation/${simulationId}/devices/status`, + destination: `simulation-${simulationId}-devices-status`, messageConverter: (message: Uint8Array) => { const states: GraphicState[] = []; const storage = state.PushedDevicesStatus.deserialize(message); diff --git a/src/layouts/DrawLayout.vue b/src/layouts/DrawLayout.vue index 85be230..3aa2e9c 100644 --- a/src/layouts/DrawLayout.vue +++ b/src/layouts/DrawLayout.vue @@ -195,7 +195,7 @@ diff --git a/src/pages/DraftManage.vue b/src/pages/DraftManage.vue index 73a4ba8..5512f1d 100644 --- a/src/pages/DraftManage.vue +++ b/src/pages/DraftManage.vue @@ -209,15 +209,15 @@ const columnDefs: QTableColumn[] = [ // align: 'center', // }, { - name: 'createdAt', + name: 'created_at', label: '创建时间', - field: 'createdAt', + field: 'created_at', align: 'center', }, { - name: 'updateAt', + name: 'update_at', label: '更新时间', - field: 'updateAt', + field: 'update_at', align: 'center', }, { name: 'operations', label: '操作', field: 'operations', align: 'center' }, diff --git a/src/pages/PublishManage.vue b/src/pages/PublishManage.vue index 4b462b9..a915429 100644 --- a/src/pages/PublishManage.vue +++ b/src/pages/PublishManage.vue @@ -80,9 +80,9 @@ const columnDefs: QTableColumn[] = [ align: 'center', }, { - name: 'publishAt', + name: 'publish_at', label: '发布时间', - field: 'publishAt', + field: 'publish_at', align: 'center', }, { name: 'operations', label: '操作', field: 'operations', align: 'center' }, diff --git a/src/pages/UserLogin.vue b/src/pages/UserLogin.vue index 1e0c96c..f07e614 100644 --- a/src/pages/UserLogin.vue +++ b/src/pages/UserLogin.vue @@ -70,7 +70,7 @@ const loginInfo = reactive({ async function doLogin() { try { clearJwtToken(); - const token = await login(loginInfo); + const { token } = await login(loginInfo); saveJwtToken(token); router.push({ name: 'home' }); } catch (err) { diff --git a/src/pages/UserManage.vue b/src/pages/UserManage.vue index 43f81ba..63e02f8 100644 --- a/src/pages/UserManage.vue +++ b/src/pages/UserManage.vue @@ -105,9 +105,9 @@ const columnDefs: QTableColumn[] = [ }, { name: 'id', label: '用户ID', field: 'id', align: 'center' }, { - name: 'registerTime', + name: 'register_time', label: '创建时间', - field: 'registerTime', + field: 'register_time', align: 'center', }, { @@ -116,7 +116,7 @@ const columnDefs: QTableColumn[] = [ field: 'mobile', align: 'center', }, - { name: 'operations', label: '操作', field: 'operations', align: 'center' }, + // { name: 'operations', label: '操作', field: 'operations', align: 'center' }, ]; const operateDisabled = ref(false);