App.vue 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <template>
  2. <vant-config-provider :theme="store.isDark ? 'dark' : 'light'">
  3. <ion-app>
  4. <ion-router-outlet />
  5. </ion-app>
  6. </vant-config-provider>
  7. <!-- <img id="btn-customer" src="@/assets/icon_custumer.png" @click="onClick" /> -->
  8. </template>
  9. <script setup>
  10. import { ConfigProvider as VantConfigProvider, showConfirmDialog } from 'vant'
  11. import { useBackButton, useIonRouter } from '@ionic/vue'
  12. import { onMounted, onBeforeUnmount } from 'vue'
  13. import { useRoute } from 'vue-router'
  14. import { useSystemStore } from './stores/system'
  15. import { App } from '@capacitor/app'
  16. import { useSettingsStore } from '@/stores/settings'
  17. import { useI18n } from 'vue-i18n'
  18. import { emitter } from '@/utils/eventBus'
  19. import taost from '@/utils/toast'
  20. const store = useSettingsStore()
  21. const { t } = useI18n()
  22. const ionRouter = useIonRouter()
  23. const route = useRoute()
  24. const promptLogin = async () => {
  25. const confirm = await showConfirmDialog({
  26. title: t('common.alert'),
  27. message: t('user.notLogin')
  28. }).catch(() => {})
  29. if (confirm) {
  30. ionRouter.push({ name: 'login' })
  31. }
  32. }
  33. const promptExit = () => {
  34. taost(t('common.exitApp'))
  35. }
  36. useBackButton(-1, () => {
  37. if (route.matched[0].name === 'index') {
  38. promptExit()
  39. } else if (!ionRouter.canGoBack()) {
  40. promptExit()
  41. }
  42. })
  43. onMounted(() => {
  44. useSystemStore().getSysConfigs()
  45. emitter.on('promptLogin', promptLogin)
  46. })
  47. onBeforeUnmount(() => {
  48. emitter.off('promptLogin', promptLogin)
  49. })
  50. </script>
  51. <style lang="less" scoped>
  52. .consult {
  53. width: 50px;
  54. height: 50px;
  55. border-radius: 25px;
  56. display: inherit;
  57. -webkit-box-align: center;
  58. align-items: center;
  59. -webkit-box-pack: center;
  60. justify-content: center;
  61. pointer-events: initial;
  62. background-size: 130% 130%;
  63. transition: all 0.2s ease-in-out 0s;
  64. position: relative;
  65. color: white;
  66. background: linear-gradient(135deg, rgb(64, 29, 186), rgb(130, 91, 240));
  67. box-shadow: rgb(64 29 186 / 50%) 0px 4px 24px;
  68. position: fixed;
  69. right: 16px;
  70. bottom: 56px;
  71. ion-icon {
  72. font-size: 24px;
  73. }
  74. }
  75. #btn-customer {
  76. position: fixed;
  77. right: 10px;
  78. width: 48px;
  79. height: 48px;
  80. bottom: calc(var(--ion-safe-area-bottom) + 68px);
  81. }
  82. </style>