index.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <template>
  2. <div class="flex-column-page-wrap pageWrap">
  3. Home
  4. <div class="common_title">多语言 使用</div>
  5. <div class="content">
  6. <el-button size="small" @click="switchLang">
  7. lang: 切换
  8. <LeIcon icon-class="le-frozen" />
  9. <LeIcon icon-class="le-warning" />
  10. {{ $i18n.locale }}
  11. </el-button>
  12. <div>local文字: {{ $t('route.dashboard') }}</div>
  13. <div>src/locale 文字(携带 le前缀做区分): {{ $t('le.btn.add') }}</div>
  14. </div>
  15. <SearchGroup2Popover v-if="false" />
  16. <LeSelectDemo v-if="true" />
  17. <InputNumberDemo v-if="true" />
  18. <LeDraggableNestDemo v-if="true" />
  19. <div class="common_title">le-iconfont && LeIcon</div>
  20. <div class="content">
  21. <!-- 单色样式类 -->
  22. <!--也可拼接 对应icon文件夹注入的icon 文件-->
  23. <SvgIcon icon-class="logo" />
  24. <LeIcon icon-class="icon-logo" />
  25. <span class="le-iconfont le-review"></span>
  26. <LeIcon icon-class="le-checkbox_checked"></LeIcon>
  27. <span class="le-iconfont le-checkbox_checked"></span>
  28. <LeIcon icon-class="le-checkbox"></LeIcon>
  29. <span class="le-iconfont le-checkbox"></span>
  30. <LeIcon icon-class="le-radio_checked"></LeIcon>
  31. <span class="le-iconfont le-radio_checked"></span>
  32. <LeIcon icon-class="le-radio"></LeIcon>
  33. <span class="le-iconfont le-radio"></span>
  34. <!-- svg -->
  35. <LeIcon icon-class="le-frozen" @click="testHandler"></LeIcon>
  36. <!--Table 操作 用: Icon按钮-->
  37. <el-tooltip placement="top" :content="$t('le.btn.search')">
  38. <el-button class="le-icon-button" @click="testHandler('row')">
  39. <LeIcon icon-class="le-view"></LeIcon>
  40. </el-button>
  41. </el-tooltip>
  42. </div>
  43. <!-- <div class="common_title">下拉Dropdown LeDropdown</div>
  44. <div class="content">
  45. <LeDropdown v-model="dropdownValue" :options="dropdownOptions" clearable modelValue>
  46. &lt;!&ndash; <template #btn="{ selectOption, showClear }">
  47. <span class="le-dropdown-link">
  48. {{$log(showClear, 'showClear')}}
  49. {{selectOption.label}}
  50. <i :class="['action el-icon-arrow-down']" />
  51. </span>
  52. </template>&ndash;&gt;
  53. </LeDropdown>
  54. <LeDropdown v-model="dropdownValue" :options="dropdownOptions" @command="$log($event, 'command 测试')">
  55. <template #btn="testHandler">
  56. <span class="le-dropdown-link">
  57. {{testHandler}}
  58. <i :class="['action el-icon-arrow-down']" />
  59. </span>
  60. </template>
  61. <template slot="options">
  62. <el-dropdown-item
  63. v-for="opt in dropdownOptions"
  64. :key="opt.value"
  65. :command="opt.value"
  66. :disabled="opt.disabled"
  67. >
  68. -&#45;&#45;{{ opt.label }}&#45;&#45;&#45;&#45; label
  69. </el-dropdown-item>
  70. </template>
  71. </LeDropdown>
  72. </div>-->
  73. <div class="common_title">暂无数据 LeNoData</div>
  74. <div class="content">
  75. <LeNoData :message="`<div style='background: var(--el-color-danger);'>test: lang: ${$i18n.locale}</div>`" @click="$log('test....')">
  76. <template #extraContent>no data</template>
  77. </LeNoData>
  78. </div>
  79. <!-- <div class="common_title">ElCard Style</div>
  80. <div class="content">...</div>
  81. <div class="common_title">iconfont && LeIcon</div>
  82. <div class="content">
  83. <el-card shadow="never" class="le-card-bg picking-list" header="Picking List">
  84. <template slot="header">
  85. Picking List&#45;&#45;&#45;&#45;
  86. <el-button type="text">Clear</el-button>
  87. </template>
  88. 123456
  89. </el-card>
  90. </div>-->
  91. </div>
  92. </template>
  93. <script setup name="home" lang="tsx">
  94. import { ref } from 'vue'
  95. import SearchGroup2Popover from './components/SearchGroup2Popover'
  96. import LeSelectDemo from './components/LeSelectDemo'
  97. import InputNumberDemo from './components/InputNumberDemo'
  98. import LeDraggableNestDemo from './components/LeDraggableNestDemo'
  99. import useStore from '@/store/index'
  100. import { useI18n } from 'vue-i18n'
  101. // import i18n from '@/lang'
  102. const dropdownValue = ref()
  103. const dropdownOptions = ref([
  104. {
  105. label: 'in',
  106. value: 0
  107. },
  108. {
  109. label: 'cm',
  110. value: 1
  111. }
  112. ])
  113. const testHandler = () => {
  114. console.error('testHandler...')
  115. }
  116. const { locale } = useI18n()
  117. const switchLang = () => {
  118. // let lang = this.$i18n.locale
  119. // let lang = i18n.global.locale.value
  120. let lang = locale.value
  121. if (lang === 'en') {
  122. lang = 'zh-cn'
  123. } else {
  124. lang = 'en'
  125. }
  126. // console.error(lang, 'lang')
  127. locale.value = lang
  128. const { app } = useStore()
  129. app.setLanguage(lang)
  130. // i18n.global.setLocaleMessage(lang)
  131. // this.$i18n.locale = lang
  132. // this.$i18n.fallbackLocale = lang
  133. }
  134. </script>
  135. <style lang="scss" scoped>
  136. .pageWrap {
  137. padding: 10px 12px;
  138. overflow: auto;
  139. }
  140. .le-iconfont {
  141. color: #0d84ff;
  142. }
  143. </style>