This commit is contained in:
fan 2023-07-31 15:42:29 +08:00
commit a47a0730ea
10 changed files with 35 additions and 18 deletions

View File

@ -16,7 +16,7 @@ export async function createSimulation(data: { mapId: number }) {
* @param simulationId 仿id * @param simulationId 仿id
*/ */
export async function destroySimulation(data: { simulationId: string }) { 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; return response.data;
} }

View File

@ -42,12 +42,18 @@ interface LoginInfo {
password: string; password: string;
} }
interface LoginRes {
code: number;
expire: string;
token: string;
}
/** /**
* *
* @param loginInfo * @param loginInfo
* @returns * @returns
*/ */
export async function login(loginInfo: LoginInfo): Promise<string> { export async function login(loginInfo: LoginInfo): Promise<LoginRes> {
const info = { ...loginInfo, password: encryptPassword(loginInfo.password) }; const info = { ...loginInfo, password: encryptPassword(loginInfo.password) };
const response = await api.post(`${UserUriBase}/login`, info); const response = await api.post(`${UserUriBase}/login`, info);
return response.data.token; return response.data.token;

View File

@ -11,3 +11,11 @@ export function getJwtToken(): string | null {
export function clearJwtToken(): void { export function clearJwtToken(): void {
sessionStorage.removeItem(JwtTokenKey); 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;
}

View File

@ -4,7 +4,8 @@ function getHost(): string {
// return '192.168.3.37:9091'; // return '192.168.3.37:9091';
// return '192.168.3.15:9091'; // return '192.168.3.15:9091';
// return '192.168.3.5: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'; // return 'test.joylink.club/bjrtss-server';
} }
@ -15,7 +16,8 @@ export function getHttpBase() {
export function getWebsocketUrl() { export function getWebsocketUrl() {
const host = '192.168.3.233'; const host = '192.168.3.233';
const port = 8000;
// return `ws://${host}/ws-bj`; // return `ws://${host}/ws-bj`;
return `ws://${host}/connection/websocket`; return `ws://${host}:${port}/connection/websocket`;
// return `wss://${getHost()}/ws-bj`; // return `wss://${getHost()}/ws-bj`;
} }

View File

@ -41,7 +41,7 @@ import { graphicData } from 'src/protos/stationLayoutGraphics';
import { useLineStore } from 'src/stores/line-store'; import { useLineStore } from 'src/stores/line-store';
import { toUint8Array } from 'js-base64'; import { toUint8Array } from 'js-base64';
import { getWebsocketUrl } from 'src/configs/UrlManage'; 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 { state } from 'src/protos/device_state';
import { import {
AxleCounting, AxleCounting,
@ -311,11 +311,12 @@ export async function loadLineDatas(app: GraphicApp) {
app.enableWsMassaging({ app.enableWsMassaging({
engine: ClientEngine.Centrifugo, engine: ClientEngine.Centrifugo,
wsUrl: `${getWebsocketUrl()}`, wsUrl: `${getWebsocketUrl()}`,
token: getJwtToken() as string, token: getOnlyToken() as string,
}); });
app.subscribe({ app.subscribe({
destination: `/simulation/${simulationId}/devices/status`, // destination: `/simulation/${simulationId}/devices/status`,
destination: `simulation-${simulationId}-devices-status`,
messageConverter: (message: Uint8Array) => { messageConverter: (message: Uint8Array) => {
const states: GraphicState[] = []; const states: GraphicState[] = [];
const storage = state.PushedDevicesStatus.deserialize(message); const storage = state.PushedDevicesStatus.deserialize(message);

View File

@ -195,7 +195,7 @@
<q-input <q-input
outlined outlined
label="草稿名称" label="草稿名称"
v-model.number="saveAsName" v-model="saveAsName"
:rules="[(val) => val.trim() != '' || '草稿名称不能为空']" :rules="[(val) => val.trim() != '' || '草稿名称不能为空']"
/> />
</q-card-section> </q-card-section>

View File

@ -209,15 +209,15 @@ const columnDefs: QTableColumn[] = [
// align: 'center', // align: 'center',
// }, // },
{ {
name: 'createdAt', name: 'created_at',
label: '创建时间', label: '创建时间',
field: 'createdAt', field: 'created_at',
align: 'center', align: 'center',
}, },
{ {
name: 'updateAt', name: 'update_at',
label: '更新时间', label: '更新时间',
field: 'updateAt', field: 'update_at',
align: 'center', align: 'center',
}, },
{ name: 'operations', label: '操作', field: 'operations', align: 'center' }, { name: 'operations', label: '操作', field: 'operations', align: 'center' },

View File

@ -80,9 +80,9 @@ const columnDefs: QTableColumn[] = [
align: 'center', align: 'center',
}, },
{ {
name: 'publishAt', name: 'publish_at',
label: '发布时间', label: '发布时间',
field: 'publishAt', field: 'publish_at',
align: 'center', align: 'center',
}, },
{ name: 'operations', label: '操作', field: 'operations', align: 'center' }, { name: 'operations', label: '操作', field: 'operations', align: 'center' },

View File

@ -70,7 +70,7 @@ const loginInfo = reactive({
async function doLogin() { async function doLogin() {
try { try {
clearJwtToken(); clearJwtToken();
const token = await login(loginInfo); const { token } = await login(loginInfo);
saveJwtToken(token); saveJwtToken(token);
router.push({ name: 'home' }); router.push({ name: 'home' });
} catch (err) { } catch (err) {

View File

@ -105,9 +105,9 @@ const columnDefs: QTableColumn[] = [
}, },
{ name: 'id', label: '用户ID', field: 'id', align: 'center' }, { name: 'id', label: '用户ID', field: 'id', align: 'center' },
{ {
name: 'registerTime', name: 'register_time',
label: '创建时间', label: '创建时间',
field: 'registerTime', field: 'register_time',
align: 'center', align: 'center',
}, },
{ {
@ -116,7 +116,7 @@ const columnDefs: QTableColumn[] = [
field: 'mobile', field: 'mobile',
align: 'center', align: 'center',
}, },
{ name: 'operations', label: '操作', field: 'operations', align: 'center' }, // { name: 'operations', label: '', field: 'operations', align: 'center' },
]; ];
const operateDisabled = ref(false); const operateDisabled = ref(false);