index.tsx 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import { onMounted, defineComponent,onUnmounted } from 'vue';
  2. import MessageCard from './MessageCard';
  3. import './index.scss';
  4. import {
  5. useCommonStore,
  6. useIncidentStore,
  7. useMarkerStore,
  8. } from '@/store';
  9. import { IncidentListResponse } from '@/api/incident';
  10. import { useRouter } from 'vue-router';
  11. export default defineComponent({
  12. name: 'HomePage',
  13. provide: {},
  14. setup() {
  15. const store = useIncidentStore();
  16. const commonStore = useCommonStore();
  17. const router = useRouter();
  18. const markerStore = useMarkerStore();
  19. var ss = null;
  20. onMounted(async () => {
  21. commonStore.getGlobalDict('zhdd_incident_level');
  22. commonStore.getGlobalDict('zhdd_incident_type');
  23. commonStore.getGlobalDict('zhdd_incident_source');
  24. commonStore.getGlobalDict('zhdd_car_type');
  25. await store.getIncidentList({
  26. // 事件等级1,2的事件
  27. level: 1,
  28. })
  29. ss = setInterval(async () => {
  30. if ((store.incidents.data ?? []).length > 0) {
  31. var item = store.incidents.data![0];
  32. markerStore.currentIncident = item;
  33. item.id && (await store.getIncidentItem(item.id));
  34. router.push(`/incidentDetail?id=${item.id}`);
  35. }
  36. },1000)
  37. });
  38. onUnmounted(() => {
  39. clearInterval(ss);
  40. });
  41. return () => (
  42. <div class="home-page-container">
  43. <MessageCard />
  44. </div>
  45. );
  46. },
  47. });