App.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <template>
  2. <div class="fit row">
  3. <Api ref="api" v-model="accessGranted" />
  4. <Notify ref="notify" />
  5. <StdDialog ref="stdDialog" />
  6. <router-view v-if="accessGranted" v-slot="{ Component }">
  7. <keep-alive>
  8. <component :is="Component" class="col" />
  9. </keep-alive>
  10. </router-view>
  11. </div>
  12. </template>
  13. <script>
  14. //-----------------------------------------------------------------------------
  15. import vueComponent from './vueComponent.js';
  16. //import * as utils from '../share/utils';
  17. import Notify from './share/Notify.vue';
  18. import StdDialog from './share/StdDialog.vue';
  19. import Api from './Api/Api.vue';
  20. import Search from './Search/Search.vue';
  21. const componentOptions = {
  22. components: {
  23. Api,
  24. Notify,
  25. StdDialog,
  26. Search,
  27. },
  28. watch: {
  29. },
  30. };
  31. class App {
  32. _options = componentOptions;
  33. accessGranted = false;
  34. created() {
  35. this.commit = this.$store.commit;
  36. //root route
  37. let cachedRoute = '';
  38. let cachedPath = '';
  39. this.$root.getRootRoute = () => {
  40. if (this.$route.path != cachedPath) {
  41. cachedPath = this.$route.path;
  42. const m = cachedPath.match(/^(\/[^/]*).*$/i);
  43. cachedRoute = (m ? m[1] : this.$route.path);
  44. }
  45. return cachedRoute;
  46. }
  47. this.$root.isMobileDevice = /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent);
  48. this.$root.setAppTitle = this.setAppTitle;
  49. //global keyHooks
  50. this.keyHooks = [];
  51. this.keyHook = (event) => {
  52. for (const hook of this.keyHooks)
  53. hook(event);
  54. }
  55. this.$root.addKeyHook = (hook) => {
  56. if (this.keyHooks.indexOf(hook) < 0)
  57. this.keyHooks.push(hook);
  58. }
  59. this.$root.removeKeyHook = (hook) => {
  60. const i = this.keyHooks.indexOf(hook);
  61. if (i >= 0)
  62. this.keyHooks.splice(i, 1);
  63. }
  64. document.addEventListener('keyup', (event) => {
  65. this.keyHook(event);
  66. });
  67. document.addEventListener('keypress', (event) => {
  68. this.keyHook(event);
  69. });
  70. document.addEventListener('keydown', (event) => {
  71. this.keyHook(event);
  72. });
  73. }
  74. mounted() {
  75. this.$root.api = this.$refs.api;
  76. this.$root.notify = this.$refs.notify;
  77. this.$root.stdDialog = this.$refs.stdDialog;
  78. this.setAppTitle();
  79. }
  80. get config() {
  81. return this.$store.state.config;
  82. }
  83. get rootRoute() {
  84. return this.$root.getRootRoute();
  85. }
  86. setAppTitle(title) {
  87. if (title) {
  88. document.title = title;
  89. }
  90. }
  91. }
  92. export default vueComponent(App);
  93. //-----------------------------------------------------------------------------
  94. </script>
  95. <style scoped>
  96. </style>
  97. <style>
  98. body, html, #app {
  99. margin: 0;
  100. padding: 0;
  101. width: 100%;
  102. height: 100%;
  103. font: normal 13px Web Default;
  104. }
  105. .dborder {
  106. border: 2px solid yellow;
  107. }
  108. .icon-rotate {
  109. vertical-align: middle;
  110. animation: rotating 2s linear infinite;
  111. }
  112. .q-dialog__inner--minimized {
  113. padding: 10px !important;
  114. }
  115. .q-dialog__inner--minimized > div {
  116. max-height: 100% !important;
  117. max-width: 800px !important;
  118. }
  119. @keyframes rotating {
  120. from {
  121. transform: rotate(0deg);
  122. } to {
  123. transform: rotate(360deg);
  124. }
  125. }
  126. @font-face {
  127. font-family: 'Web Default';
  128. src: url('fonts/web-default.ttf') format('truetype');
  129. }
  130. @font-face {
  131. font-family: 'Verdana';
  132. font-weight: bold;
  133. src: url('fonts/web-default-bold.ttf') format('truetype');
  134. }
  135. </style>