提交 8b2cdb0c 编写于 作者: 雪洛's avatar 雪洛

feat(harmony): 支持i18n

上级 51bd87e7
......@@ -16,11 +16,11 @@
"__VUE_PROD_HYDRATION_MISMATCH_DETAILS__": "false",
"__UNI_FEATURE_WX__": "true",
"__UNI_FEATURE_PROMISE__": "false",
"__UNI_FEATURE_I18N_EN__": "false",
"__UNI_FEATURE_I18N_ES__": "false",
"__UNI_FEATURE_I18N_FR__": "false",
"__UNI_FEATURE_I18N_ZH_HANS__": "false",
"__UNI_FEATURE_I18N_ZH_HANT__": "false",
"__UNI_FEATURE_I18N_EN__": "true",
"__UNI_FEATURE_I18N_ES__": "true",
"__UNI_FEATURE_I18N_FR__": "true",
"__UNI_FEATURE_I18N_ZH_HANS__": "true",
"__UNI_FEATURE_I18N_ZH_HANT__": "true",
"plus.os.name": "'Harmony'",
"plus.os.version": "''"
},
......
......@@ -6,7 +6,12 @@ import {
NavigateBackProtocol,
defineAsyncApi,
} from '@dcloudio/uni-api'
import { getCurrentPage, invokeHook } from '@dcloudio/uni-core'
import {
getCurrentPage,
initI18nAppMsgsOnce,
invokeHook,
useI18n,
} from '@dcloudio/uni-core'
import { ON_BACK_PRESS, ON_SHOW } from '@dcloudio/uni-shared'
import {
......@@ -60,11 +65,10 @@ export const navigateBack = defineAsyncApi<API_TYPE_NAVIGATE_BACK>(
let firstBackTime = 0
function quit() {
// TODO initI18nAppMsgsOnce()
initI18nAppMsgsOnce()
if (!firstBackTime) {
firstBackTime = Date.now()
// TODO useI18n
plus.nativeUI.toast('再按一次退出應用')
plus.nativeUI.toast(useI18n().t('uni.app.quit'))
setTimeout(() => {
firstBackTime = 0
}, 2000)
......
import type { ComponentPublicInstance } from 'vue'
import { extend } from '@vue/shared'
import { formatLog } from '@dcloudio/uni-shared'
import { defineGlobalData, initService } from '@dcloudio/uni-core'
import { defineGlobalData, initAppVm, initService } from '@dcloudio/uni-core'
import { initVueApp } from '@dcloudio/uni-app-plus/service/framework/app/vueApp'
import { initSubscribeHandlers } from './subscriber'
import { initGlobalEvent } from './initGlobalEvent'
......@@ -12,10 +12,18 @@ const defaultApp = {
globalData: {},
}
function initAppVm(appVm: ComponentPublicInstance) {
appVm.$vm = appVm
appVm.$mpType = 'app'
// TODO useI18n
export function getApp({ allowDefault = false } = {}) {
if (appCtx) {
// 真实的 App 已初始化
return appCtx
}
if (allowDefault) {
// 返回默认实现
return defaultApp
}
console.error(
'[warn]: getApp() failed. Learn more: https://uniapp.dcloud.io/collocation/frame/window?id=getapp.'
)
}
export function registerApp(appVm: ComponentPublicInstance) {
......
import * as uni from './api/index'
import { UniServiceJSBridge } from './bridge'
import { registerApp as __registerApp } from './framework/app'
import { registerApp as __registerApp, getApp } from './framework/app'
import { definePage as __definePage } from '@dcloudio/uni-app-plus/service/framework/page'
import { getCurrentPages } from '@dcloudio/uni-app-plus/service/framework/page'
export default {
uni,
getApp,
getCurrentPages,
__definePage,
__registerApp,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册