LanguageDialog.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <div v-show="isModalVisible" class="language-setting-popup">
  3. <div class="wrapper">
  4. <div className="header-container">
  5. <span class="title"></span>
  6. <Button className="close-button" :onClick="handleClose"><CloseModal /></Button>
  7. </div>
  8. <div class="content">
  9. <div class="title">{{ $t('header.language') }}</div>
  10. <div class="item" @click="selectLanguage('en')">
  11. <Circled v-if="selectedLanguage === 'en'" />
  12. <Circle v-else />
  13. English
  14. </div>
  15. <div class="item" @click="selectLanguage('zh-CN')">
  16. <Circled v-if="selectedLanguage === 'zh-CN'" />
  17. <Circle v-else />
  18. 简体中文
  19. </div>
  20. <span class="set-btn" @click="handleLanguage">{{ $t('ok') }}</span>
  21. </div>
  22. </div>
  23. </div>
  24. </template>
  25. <script setup>
  26. import { computed, ref } from 'vue'
  27. import { useI18n } from 'vue-i18n'
  28. import { useViewerStore } from '@/stores/modules/viewer'
  29. const { locale } = useI18n()
  30. const useViewer = useViewerStore()
  31. const selectedLanguage = ref(locale.value)
  32. const isModalVisible = computed(() => useViewer.isElementOpen('languageDialog'))
  33. const handleClose = () => {
  34. useViewer.closeElement('languageDialog')
  35. selectedLanguage.value = locale.value
  36. }
  37. const selectLanguage = (language) => {
  38. selectedLanguage.value = language
  39. }
  40. const handleLanguage = () => {
  41. locale.value = selectedLanguage.value
  42. useViewer.closeElement('languageDialog')
  43. }
  44. </script>
  45. <style lang="scss">
  46. .language-setting-popup {
  47. position: fixed;
  48. left: 0;
  49. bottom: 0;
  50. z-index: 100;
  51. width: 100%;
  52. height: 100%;
  53. background-color: rgba(0, 0, 0, 0.3);
  54. display: flex;
  55. justify-content: center;
  56. align-items: center;
  57. .wrapper {
  58. width: 100%;
  59. max-width: 252px;
  60. padding: 20px 16px;
  61. background-color: var(--c-header-bg);
  62. box-shadow: 0px 4px 32px 0px rgba(129, 149, 200, 0.32);
  63. border-radius: 4px;
  64. }
  65. .header-container {
  66. display: flex;
  67. justify-content: space-between;
  68. margin-bottom: 10px;
  69. button {
  70. margin-right: 0;
  71. }
  72. }
  73. .content {
  74. display: flex;
  75. flex-direction: column;
  76. .title {
  77. margin-bottom: 16px;
  78. font-weight: bold;
  79. font-size: 16px;
  80. line-height: 24px;
  81. }
  82. .item {
  83. display: flex;
  84. align-items: center;
  85. font-size: 14px;
  86. line-height: 20px;
  87. cursor: pointer;
  88. & + .item {
  89. margin-top: 6px;
  90. }
  91. svg {
  92. margin-right: 9px;
  93. }
  94. }
  95. }
  96. .set-btn {
  97. display: flex;
  98. width: 100%;
  99. justify-content: center;
  100. align-items: center;
  101. margin-top: 24px;
  102. padding: 12px 0;
  103. font-size: 14px;
  104. line-height: 16px;
  105. font-weight: bold;
  106. border-radius: 4px;
  107. color: #FFF;
  108. cursor: pointer;
  109. background-color: var(--c-popup-bg-active);
  110. }
  111. }
  112. </style>