App.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <template>
  2. <div id="app">
  3. <router-view />
  4. </div>
  5. </template>
  6. <script>
  7. import {getVersionJson} from "@/api/other";
  8. import {getStore, setStore} from "@/util/store";
  9. export default {
  10. name: "app",
  11. data() {
  12. return {};
  13. },
  14. watch: {},
  15. created() {},
  16. mounted() {
  17. //生产环境下,检测更新
  18. if (process.env.NODE_ENV === 'production') {
  19. this.getVersionJsonApi()
  20. setInterval(() => {
  21. this.getVersionJsonApi()
  22. }, 1000 * 60)
  23. }
  24. },
  25. methods: {
  26. //获取版本更新信息
  27. async getVersionJsonApi() {
  28. const cache_version = getStore({name: 'version'})
  29. const {data} = await getVersionJson()
  30. const version = data.value
  31. setStore({name: 'version', content: version})
  32. if (cache_version && cache_version !== version) {
  33. this.$confirm('检测到有新版本更新,请点击更新,或手动刷新网页更新,如果不更新,将无法使用相关功能', '更新提醒', {
  34. confirmButtonText: '立即更新',
  35. cancelButtonText: '暂不更新',
  36. type: 'warning'
  37. }).then(() => {
  38. //刷新页面
  39. window.location.reload()
  40. });
  41. }
  42. },
  43. },
  44. computed: {},
  45. };
  46. </script>
  47. <style lang="scss">
  48. #app {
  49. width: 100%;
  50. height: 100%;
  51. overflow: hidden;
  52. }
  53. .avue--detail .el-col {
  54. margin-bottom: 0;
  55. }
  56. .boxswai {
  57. box-sizing: border-box;
  58. padding: 0px 14px 10px 14px;
  59. width: 100%;
  60. height: 100%;
  61. color: #303133;
  62. .boxnei {
  63. box-sizing: border-box;
  64. width: 100%;
  65. height: 100%;
  66. background-color: #fff;
  67. padding: 14px;
  68. border: 1px solid #ebeef5;
  69. border-radius: 4px;
  70. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.2);
  71. overflow: auto;
  72. }
  73. }
  74. </style>