提交 856d6033 编写于 作者: fxy060608's avatar fxy060608

wip(i18n): remove pullToRefresh

上级 470a06e1
......@@ -22,9 +22,13 @@ export const onLocaleChange = defineOnApi(API_ON_LOCALE_CHANGE, () => {})
export const setLocale = defineSyncApi<typeof uni.setLocale>(
API_SET_LOCALE,
(locale) => {
const oldLocale = getApp().$vm.$locale
const app = getApp()
if (!app) {
return false
}
const oldLocale = app.$vm.$locale
if (oldLocale !== locale) {
getApp().$vm.$locale = locale
app.$vm.$locale = locale
if (__PLATFORM__ === 'app') {
const pages = getCurrentPages()
pages.forEach((page) => {
......
......@@ -1484,9 +1484,18 @@ var serviceContext = (function (vue) {
const ignoreVueI18n = true;
function watchAppLocale(appVm, i18n) {
appVm.$watch(() => appVm.$locale, (newLocale) => {
i18n.setLocale(newLocale);
});
// 需要保证 watch 的触发在组件渲染之前
if (appVm.$watchLocale) {
// vue2
appVm.$watchLocale((newLocale) => {
i18n.setLocale(newLocale);
});
}
else {
appVm.$watch(() => appVm.$locale, (newLocale) => {
i18n.setLocale(newLocale);
});
}
}
function initVueI18n(locale, messages = {}, fallbackLocale, watcher) {
// 兼容旧版本入参
......@@ -4402,11 +4411,13 @@ var serviceContext = (function (vue) {
});
const onLocaleChange = defineOnApi(API_ON_LOCALE_CHANGE, () => { });
const setLocale = defineSyncApi(API_SET_LOCALE, (locale) => {
const oldLocale = getApp().$vm.$locale;
const app = getApp();
if (!app) {
return false;
}
const oldLocale = app.$vm.$locale;
if (oldLocale !== locale) {
getApp().$vm.$locale = locale;
// 执行 uni.onLocaleChange
UniServiceJSBridge.invokeOnCallback(API_ON_LOCALE_CHANGE, { locale });
app.$vm.$locale = locale;
{
const pages = getCurrentPages();
pages.forEach((page) => {
......@@ -4414,6 +4425,8 @@ var serviceContext = (function (vue) {
});
weex.requireModule('plus').setLanguage(locale);
}
// 执行 uni.onLocaleChange
UniServiceJSBridge.invokeOnCallback(API_ON_LOCALE_CHANGE, { locale });
return true;
}
return false;
......
因为 它太大了无法显示 source diff 。你可以改为 查看blob
......@@ -141,16 +141,6 @@ function initNavigationBarI18n(navigationBar) {
]);
}
}
function initPullToRefreshI18n(pullToRefresh) {
if (isEnableLocale()) {
const CAPTION = "caption";
return defineI18nProperties(pullToRefresh, [
["contentdown", CAPTION],
["contentover", CAPTION],
["contentrefresh", CAPTION]
]);
}
}
const E = function() {
};
E.prototype = {
......@@ -6684,7 +6674,6 @@ function normalizePageMeta(pageMeta) {
pullToRefresh.offset += uniShared.NAVBAR_HEIGHT + 0;
}
pageMeta.pullToRefresh = pullToRefresh;
__UNI_FEATURE_I18N_LOCALE__ && initPullToRefreshI18n(pullToRefresh);
}
}
if (__UNI_FEATURE_NAVIGATIONBAR__) {
......
......@@ -234,16 +234,6 @@ function initNavigationBarI18n(navigationBar) {
]);
}
}
function initPullToRefreshI18n(pullToRefresh) {
if (isEnableLocale()) {
const CAPTION = "caption";
return defineI18nProperties(pullToRefresh, [
["contentdown", CAPTION],
["contentover", CAPTION],
["contentrefresh", CAPTION]
]);
}
}
const E = function() {
};
E.prototype = {
......@@ -4349,9 +4339,13 @@ const getLocale = /* @__PURE__ */ defineSyncApi(API_GET_LOCALE, () => {
const onLocaleChange = /* @__PURE__ */ defineOnApi(API_ON_LOCALE_CHANGE, () => {
});
const setLocale = /* @__PURE__ */ defineSyncApi(API_SET_LOCALE, (locale) => {
const oldLocale = getApp().$vm.$locale;
const app = getApp();
if (!app) {
return false;
}
const oldLocale = app.$vm.$locale;
if (oldLocale !== locale) {
getApp().$vm.$locale = locale;
app.$vm.$locale = locale;
UniServiceJSBridge.invokeOnCallback(API_ON_LOCALE_CHANGE, { locale });
return true;
}
......@@ -13379,7 +13373,6 @@ function normalizePageMeta(pageMeta) {
pullToRefresh.offset += NAVBAR_HEIGHT + out.top;
}
pageMeta.pullToRefresh = pullToRefresh;
__UNI_FEATURE_I18N_LOCALE__ && initPullToRefreshI18n(pullToRefresh);
}
}
if (__UNI_FEATURE_NAVIGATIONBAR__) {
......
......@@ -5,7 +5,6 @@ import { useRoute } from 'vue-router'
import { NAVBAR_HEIGHT, parseQuery } from '@dcloudio/uni-shared'
import {
initNavigationBarI18n,
initPullToRefreshI18n,
initRouteMeta,
normalizePullToRefreshRpx,
PolySymbol,
......@@ -89,8 +88,6 @@ function normalizePageMeta(pageMeta: UniApp.PageRouteMeta) {
NAVBAR_HEIGHT + (__NODE_JS__ ? 0 : safeAreaInsets.top)
}
pageMeta.pullToRefresh = pullToRefresh
__UNI_FEATURE_I18N_LOCALE__ && initPullToRefreshI18n(pullToRefresh)
}
}
if (__UNI_FEATURE_NAVIGATIONBAR__) {
......
......@@ -736,9 +736,13 @@ const getLocale = () => {
return uni.getSystemInfoSync().language || 'zh-Hans';
};
const setLocale = (locale) => {
const oldLocale = getApp().$vm.$locale;
const app = getApp();
if (!app) {
return false;
}
const oldLocale = app.$vm.$locale;
if (oldLocale !== locale) {
getApp().$vm.$locale = locale;
app.$vm.$locale = locale;
onLocaleChangeCallbacks.forEach((fn) => fn({ locale }));
return true;
}
......
......@@ -736,9 +736,13 @@ const getLocale = () => {
return uni.getSystemInfoSync().language || 'zh-Hans';
};
const setLocale = (locale) => {
const oldLocale = getApp().$vm.$locale;
const app = getApp();
if (!app) {
return false;
}
const oldLocale = app.$vm.$locale;
if (oldLocale !== locale) {
getApp().$vm.$locale = locale;
app.$vm.$locale = locale;
onLocaleChangeCallbacks.forEach((fn) => fn({ locale }));
return true;
}
......
......@@ -8,9 +8,13 @@ export const getLocale: typeof uni.getLocale = () => {
}
export const setLocale: typeof uni.setLocale = (locale) => {
const oldLocale = getApp().$vm.$locale
const app = getApp()
if (!app) {
return false
}
const oldLocale = app.$vm.$locale
if (oldLocale !== locale) {
getApp().$vm.$locale = locale
app.$vm.$locale = locale
onLocaleChangeCallbacks.forEach((fn) => fn({ locale }))
return true
}
......
......@@ -736,9 +736,13 @@ const getLocale = () => {
return uni.getSystemInfoSync().language || 'zh-Hans';
};
const setLocale = (locale) => {
const oldLocale = getApp().$vm.$locale;
const app = getApp();
if (!app) {
return false;
}
const oldLocale = app.$vm.$locale;
if (oldLocale !== locale) {
getApp().$vm.$locale = locale;
app.$vm.$locale = locale;
onLocaleChangeCallbacks.forEach((fn) => fn({ locale }));
return true;
}
......
......@@ -736,9 +736,13 @@ const getLocale = () => {
return uni.getSystemInfoSync().language || 'zh-Hans';
};
const setLocale = (locale) => {
const oldLocale = getApp().$vm.$locale;
const app = getApp();
if (!app) {
return false;
}
const oldLocale = app.$vm.$locale;
if (oldLocale !== locale) {
getApp().$vm.$locale = locale;
app.$vm.$locale = locale;
onLocaleChangeCallbacks.forEach((fn) => fn({ locale }));
return true;
}
......
......@@ -736,9 +736,13 @@ const getLocale = () => {
return uni.getSystemInfoSync().language || 'zh-Hans';
};
const setLocale = (locale) => {
const oldLocale = getApp().$vm.$locale;
const app = getApp();
if (!app) {
return false;
}
const oldLocale = app.$vm.$locale;
if (oldLocale !== locale) {
getApp().$vm.$locale = locale;
app.$vm.$locale = locale;
onLocaleChangeCallbacks.forEach((fn) => fn({ locale }));
return true;
}
......
......@@ -700,9 +700,13 @@ const getLocale = () => {
return uni.getSystemInfoSync().language || 'zh-Hans';
};
const setLocale = (locale) => {
const oldLocale = getApp().$vm.$locale;
const app = getApp();
if (!app) {
return false;
}
const oldLocale = app.$vm.$locale;
if (oldLocale !== locale) {
getApp().$vm.$locale = locale;
app.$vm.$locale = locale;
onLocaleChangeCallbacks.forEach((fn) => fn({ locale }));
return true;
}
......
......@@ -736,9 +736,13 @@ const getLocale = () => {
return uni.getSystemInfoSync().language || 'zh-Hans';
};
const setLocale = (locale) => {
const oldLocale = getApp().$vm.$locale;
const app = getApp();
if (!app) {
return false;
}
const oldLocale = app.$vm.$locale;
if (oldLocale !== locale) {
getApp().$vm.$locale = locale;
app.$vm.$locale = locale;
onLocaleChangeCallbacks.forEach((fn) => fn({ locale }));
return true;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册