App.vue 3.6 KB

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