相同用户操作判断调整

This commit is contained in:
joylink_fanyuhong 2024-10-08 18:04:32 +08:00
parent 53335d35ba
commit 04caf21f2f
5 changed files with 48 additions and 16 deletions

View File

@ -3,7 +3,30 @@
</template>
<script setup lang="ts">
import { watch, onMounted } from 'vue';
import { useRoute } from 'vue-router';
import { useAuthStore } from 'src/stores/auth-store';
import { getLoginUserInfo } from 'src/api/UserApi';
import { saveJwtToken } from 'src/configs/TokenManage';
defineOptions({
name: 'App'
name: 'App',
});
const route = useRoute();
const authStore = useAuthStore();
watch(
() => route.params.token,
async () => {
if (route.params.token) {
saveJwtToken(route.params.token as string);
const res = await getLoginUserInfo();
authStore.setUserId(res.loginUserInfo.id);
}
}
);
onMounted(async () => {
const res = await getLoginUserInfo();
authStore.setUserId(res.loginUserInfo.id);
});
</script>

View File

@ -25,6 +25,7 @@ import { getJwt } from 'src/api/UserApi';
import { fromUint8Array, toUint8Array } from 'js-base64';
import { getWebsocketUrl } from 'src/configs/UrlManage';
import { sync_data_message } from 'src/protos/sync_data_message';
import { useAuthStore } from 'src/stores/auth-store';
// import { getOnlyToken } from 'src/configs/TokenManage';
let drawApp: IDrawApp | null = null;
@ -87,6 +88,11 @@ function handleSubscribe(app: IDrawApp) {
destination: `/rtss_simulation/draft/iscs/${drawStore.draftId}`,
messageHandle: (message: Uint8Array) => {
const syncData = sync_data_message.SyncData.deserialize(message);
console.log(syncData.userId, useAuthStore().userId, 'userID');
if (syncData.userId === useAuthStore().userId) {
console.info('当前用户操作');
return;
}
if (
syncData.submenu === drawStore.selectSubmenuAndStation.submenu &&
syncData.station === drawStore.selectSubmenuAndStation.station

View File

@ -257,6 +257,7 @@ import { successNotify } from 'src/utils/CommonNotify';
import { saveDrawDatas } from 'src/drawApp/iscsApp';
import { saveDrawToServer } from 'src/drawApp/commonApp';
import { sync_data_message } from 'src/protos/sync_data_message';
import { useAuthStore } from 'src/stores/auth-store';
const $q = useQuasar();
const route = useRoute();
@ -533,6 +534,7 @@ function handleRecordData(op) {
datas: [],
submenu: drawStore.selectSubmenuAndStation.submenu,
station: drawStore.selectSubmenuAndStation.station,
userId: useAuthStore().userId,
};
op.obj.forEach((g) => {
const gData = g.saveData();
@ -545,7 +547,7 @@ function handleRecordData(op) {
);
});
drawApp.publishMessage(
'/rtss_simulation/draft/iscs/7',
`/rtss_simulation/draft/iscs/${drawStore.draftId}`,
new sync_data_message.SyncData({ ...syncData }).serialize()
);
}

View File

@ -121,24 +121,24 @@
</template>
<script setup lang="ts">
import { ref, reactive, onMounted } from 'vue';
import { ref, reactive } from 'vue';
import SysMenu from 'src/components/SysMenu.vue';
import { useRoute } from 'vue-router';
import { clearJwtToken, saveJwtToken } from 'src/configs/TokenManage';
// import { useRoute } from 'vue-router';
import { clearJwtToken } from 'src/configs/TokenManage';
import { Dialog } from 'quasar';
import { getLoginUserInfo } from 'src/api/UserApi';
import { useAuthStore } from 'src/stores/auth-store';
// import { getLoginUserInfo } from 'src/api/UserApi';
// import { useAuthStore } from 'src/stores/auth-store';
const route = useRoute();
const authStore = useAuthStore();
// const route = useRoute();
// const authStore = useAuthStore();
onMounted(async () => {
if (route.params.token) {
saveJwtToken(route.params.token as string);
const res = await getLoginUserInfo();
authStore.setUserId(res.loginUserInfo.id);
}
});
// onMounted(async () => {
// if (route.params.token) {
// saveJwtToken(route.params.token as string);
// const res = await getLoginUserInfo();
// authStore.setUserId(res.loginUserInfo.id);
// }
// });
const leftDrawerOpen = ref(false);
function toggleLeftDrawer() {

View File

@ -6,6 +6,7 @@ export const useAuthStore = defineStore('auth', {
}),
actions: {
setUserId(id: number | null) {
console.log(id, '----');
this.userId = id;
},
},