|
@@ -1,3 +1,4 @@
|
|
|
+
|
|
|
<template>
|
|
|
<div class="xtx-confirm">
|
|
|
<div class="wrapper" ref="target">
|
|
@@ -30,16 +31,16 @@
|
|
|
</div>
|
|
|
<div class="footer">
|
|
|
<!-- <button @click="cancelCallback" size="mini" type="gray">取消</button> -->
|
|
|
- <button @click="confirmCallback" size="mini" type="primary">{{t('confirm')}}</button>
|
|
|
+ <button @click="confirmCallback" size="mini" type="primary">{{confirm}}</button>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
+
|
|
|
<script lang="ts">
|
|
|
// 注意:当前组件不是在 #app 下进行渲染,无法使用 #app 下的环境(全局组件,全局指令,原型属性函数)
|
|
|
import { ref } from 'vue'
|
|
|
-import { useI18n } from 'vue-i18n'
|
|
|
// import { onClickOutside } from '@vueuse/core'
|
|
|
export default {
|
|
|
name: 'showConfirm',
|
|
@@ -72,8 +73,17 @@ export default {
|
|
|
},
|
|
|
setup(props) {
|
|
|
// 点击 target 目标元素外部相当于点击了取消
|
|
|
- const { t } = useI18n()
|
|
|
const target = ref(null)
|
|
|
+ let current = (localStorage && localStorage.getItem('language'))
|
|
|
+ if (!current) {
|
|
|
+ current = window.navigator.language || window.navigator.userLanguage || null
|
|
|
+ if (current && !/^zh/.test(current)) {
|
|
|
+ console.log('自动获取浏览器语言:' + current)
|
|
|
+ current = 'en'
|
|
|
+ }else{
|
|
|
+ current = 'zh'
|
|
|
+ }
|
|
|
+ }
|
|
|
// onClickOutside(target, () => {
|
|
|
// props.cancelCallback()
|
|
|
// })
|
|
@@ -84,7 +94,7 @@ export default {
|
|
|
props.options.callback()
|
|
|
props.close()
|
|
|
}
|
|
|
- return { options:props.options,target,confirmCallback,cancelCallback, t }
|
|
|
+ return { options:props.options,target,confirmCallback,cancelCallback,confirm:current=='en'?'confirm':'确认' }
|
|
|
}
|
|
|
}
|
|
|
</script>
|