|
|
|
|
@ -9,6 +9,13 @@
|
|
|
|
|
</view>
|
|
|
|
|
<view class="text-grey">{{ translateWithParams('setting.currentLanguage', { language: currentLanguageLabel }) }}</view>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="list-cell list-cell-arrow" @click="openServerDialog">
|
|
|
|
|
<view class="menu-item-box">
|
|
|
|
|
<view class="iconfont icon-global menu-icon"></view>
|
|
|
|
|
<view>{{ t('setting.serverAddress') }}</view>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="text-grey server-address-text">{{ serverAddress || t('setting.serverAddressPlaceholder') }}</view>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="list-cell list-cell-arrow" @click="handleToPwd">
|
|
|
|
|
<view class="menu-item-box">
|
|
|
|
|
<view class="iconfont icon-password menu-icon"></view>
|
|
|
|
|
@ -30,6 +37,20 @@
|
|
|
|
|
@confirm="dialogConfirm" @close="dialogClose">
|
|
|
|
|
</uni-popup-dialog>
|
|
|
|
|
</uni-popup>
|
|
|
|
|
<uni-popup ref="serverPopup" type="dialog">
|
|
|
|
|
<uni-popup-dialog
|
|
|
|
|
mode="input"
|
|
|
|
|
type="info"
|
|
|
|
|
:title="t('setting.serverAddress')"
|
|
|
|
|
:content="t('setting.serverAddressHint')"
|
|
|
|
|
:placeholder="t('setting.serverAddressPlaceholder')"
|
|
|
|
|
:value="serverAddress"
|
|
|
|
|
:confirmText="t('functionCommon.save')"
|
|
|
|
|
:cancelText="t('common.close')"
|
|
|
|
|
@confirm="handleServerAddressSave"
|
|
|
|
|
>
|
|
|
|
|
</uni-popup-dialog>
|
|
|
|
|
</uni-popup>
|
|
|
|
|
</view>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
@ -39,6 +60,8 @@ import { useI18n } from 'vue-i18n'
|
|
|
|
|
import useUserStore from '@/store/modules/user'
|
|
|
|
|
import { getCurrentLocale, setLocale, translateWithParams } from '@/locales'
|
|
|
|
|
import NavBar from '@/components/common/NavBar.vue'
|
|
|
|
|
import { removeToken } from '@/utils/auth'
|
|
|
|
|
import { SERVER_BASE_URL_STORAGE_KEY, getBaseUrl } from '@/utils/request'
|
|
|
|
|
|
|
|
|
|
const userStore = useUserStore()
|
|
|
|
|
const { t } = useI18n()
|
|
|
|
|
@ -46,7 +69,9 @@ const { t } = useI18n()
|
|
|
|
|
const pageTitle = computed(() => t('nav.setting'))
|
|
|
|
|
const windowHeight = ref(uni.getSystemInfoSync().windowHeight);
|
|
|
|
|
const popup = ref(null);
|
|
|
|
|
const serverPopup = ref(null)
|
|
|
|
|
const currentLocale = ref(getCurrentLocale())
|
|
|
|
|
const serverAddress = ref(getBaseUrl())
|
|
|
|
|
const currentLanguageLabel = computed(() => currentLocale.value === 'en-US' ? t('setting.enUS') : t('setting.zhCN'))
|
|
|
|
|
|
|
|
|
|
function handleToPwd() {
|
|
|
|
|
@ -88,6 +113,36 @@ function handleLanguageChange() {
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function openServerDialog() {
|
|
|
|
|
serverPopup.value?.open()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function handleServerAddressSave(value) {
|
|
|
|
|
const nextAddress = value.trim()
|
|
|
|
|
if (!nextAddress) {
|
|
|
|
|
uni.showToast({
|
|
|
|
|
title: t('setting.serverAddressRequired'),
|
|
|
|
|
icon: 'none',
|
|
|
|
|
duration: 1500
|
|
|
|
|
})
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
uni.setStorageSync(SERVER_BASE_URL_STORAGE_KEY, nextAddress)
|
|
|
|
|
serverAddress.value = nextAddress
|
|
|
|
|
uni.showToast({
|
|
|
|
|
title: t('setting.serverAddressSaved'),
|
|
|
|
|
icon: 'none',
|
|
|
|
|
duration: 1200
|
|
|
|
|
})
|
|
|
|
|
removeToken()
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
uni.reLaunch({
|
|
|
|
|
url: '/pages/login'
|
|
|
|
|
})
|
|
|
|
|
}, 1200)
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function handleLogout() {
|
|
|
|
|
popup.value.open();
|
|
|
|
|
};
|
|
|
|
|
@ -120,4 +175,10 @@ function dialogClose() {
|
|
|
|
|
color: #303133;
|
|
|
|
|
font-size: 32rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.server-address-text {
|
|
|
|
|
max-width: 400rpx;
|
|
|
|
|
text-align: right;
|
|
|
|
|
word-break: break-all;
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
|