App.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <template>
  2. <router-view />
  3. </template>
  4. <script lang="ts">
  5. import { defineComponent, watch } from 'vue';
  6. import { useStore } from 'src/store';
  7. export default defineComponent({
  8. name: 'App',
  9. setup() {
  10. const $store = useStore();
  11. void (async () => $store.dispatch('simulationSetup/loadScattnlay'))();
  12. void $store.dispatch('guiRuntime/activateMaterial', 'main/Ag/McPeak.yml');
  13. void $store.dispatch('guiRuntime/activateMaterial', 'main/Au/McPeak.yml');
  14. void $store.dispatch('guiRuntime/activateMaterial', 'main/Al/McPeak.yml');
  15. void $store.dispatch('guiRuntime/activateMaterial', 'main/Cu/McPeak.yml');
  16. void $store.dispatch(
  17. 'guiRuntime/activateMaterial',
  18. 'main/Si/Green-2008.yml'
  19. );
  20. void $store.dispatch('guiRuntime/activateMaterial', 'main/SiO2/Gao.yml');
  21. void $store.dispatch('guiRuntime/activateMaterial', 'main/TiO2/Sarkar.yml');
  22. let isPlotInitialToggle = false;
  23. watch($store.state.guiRuntime.activatedMaterials, () => {
  24. if (!isPlotInitialToggle) {
  25. const indexToToggle =
  26. $store.state.guiRuntime.activatedMaterials.findIndex(
  27. (val) => val.name == 'Ag_McPeak'
  28. );
  29. // Materials are activated in async actions, so toggle Ag_McPeak to be plotted as soon as it is loaded.
  30. if (indexToToggle != -1) {
  31. $store.commit(
  32. 'guiRuntime/toggleIsPlot',
  33. $store.state.guiRuntime.activatedMaterials[indexToToggle].name
  34. );
  35. isPlotInitialToggle = true;
  36. }
  37. }
  38. });
  39. },
  40. });
  41. </script>