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

wip(i18n): titleText and pullToRefresh

上级 f0e1196f
......@@ -10382,8 +10382,47 @@ var serviceContext = (function (vue) {
const pullToRefresh = normalizePullToRefreshRpx(extend({}, plus.os.name === 'Android'
? defaultAndroidPullToRefresh
: defaultPullToRefresh, routeMeta.pullToRefresh));
initPullToRefreshI18n(pullToRefresh);
webviewStyle.pullToRefresh = pullToRefresh;
webviewStyle.pullToRefresh = initWebviewPullToRefreshI18n(pullToRefresh, routeMeta);
}
function initWebviewPullToRefreshI18n(pullToRefresh, routeMeta) {
const i18nResult = initPullToRefreshI18n(pullToRefresh);
if (!i18nResult) {
return pullToRefresh;
}
const [contentdownI18n, contentoverI18n, contentrefreshI18n] = i18nResult;
if (contentdownI18n || contentoverI18n || contentrefreshI18n) {
uni.onLocaleChange(() => {
const webview = plus.webview.getWebviewById(routeMeta.id + '');
if (!webview) {
return;
}
const newPullToRefresh = {
support: true,
};
if (contentdownI18n) {
newPullToRefresh.contentdown = {
caption: pullToRefresh.contentdown.caption,
};
}
if (contentoverI18n) {
newPullToRefresh.contentover = {
caption: pullToRefresh.contentover.caption,
};
}
if (contentrefreshI18n) {
newPullToRefresh.contentrefresh = {
caption: pullToRefresh.contentrefresh.caption,
};
}
if ((process.env.NODE_ENV !== 'production')) {
console.log(formatLog('updateWebview', webview.id, newPullToRefresh));
}
webview.setStyle({
pullToRefresh: newPullToRefresh,
});
});
}
return pullToRefresh;
}
const defaultAndroidPullToRefresh = { support: true, style: 'circle' };
const defaultPullToRefresh = {
......@@ -10442,16 +10481,28 @@ var serviceContext = (function (vue) {
if (!i18nResult) {
return titleNView;
}
const [titleTextI18n, _searchInputPlaceholderI18n] = i18nResult;
if (titleTextI18n) {
const [titleTextI18n, searchInputPlaceholderI18n] = i18nResult;
if (titleTextI18n || searchInputPlaceholderI18n) {
uni.onLocaleChange(() => {
const webview = plus.webview.getWebviewById(routeMeta.id + '');
webview &&
webview.setStyle({
titleNView: {
titleText: titleNView.titleText,
},
});
if (!webview) {
return;
}
const newTitleNView = {};
if (titleTextI18n) {
newTitleNView.titleText = titleNView.titleText;
}
if (searchInputPlaceholderI18n) {
newTitleNView.searchInput = {
placeholder: titleNView.searchInput.placeholder,
};
}
if ((process.env.NODE_ENV !== 'production')) {
console.log(formatLog('updateWebview', webview.id, newTitleNView));
}
webview.setStyle({
titleNView: newTitleNView,
});
});
}
return titleNView;
......
......@@ -2,6 +2,7 @@ import {
initPullToRefreshI18n,
normalizePullToRefreshRpx,
} from '@dcloudio/uni-core'
import { formatLog } from '@dcloudio/uni-shared'
import { extend } from '@vue/shared'
export function initPullToRefresh(
......@@ -20,8 +21,55 @@ export function initPullToRefresh(
routeMeta.pullToRefresh
)
) as unknown as PlusWebviewWebviewPullToRefreshStyles
initPullToRefreshI18n(pullToRefresh)
webviewStyle.pullToRefresh = pullToRefresh
webviewStyle.pullToRefresh = initWebviewPullToRefreshI18n(
pullToRefresh,
routeMeta
)
}
function initWebviewPullToRefreshI18n(
pullToRefresh: PlusWebviewWebviewPullToRefreshStyles,
routeMeta: UniApp.PageRouteMeta
) {
const i18nResult = initPullToRefreshI18n(pullToRefresh)
if (!i18nResult) {
return pullToRefresh
}
const [contentdownI18n, contentoverI18n, contentrefreshI18n] = i18nResult
if (contentdownI18n || contentoverI18n || contentrefreshI18n) {
uni.onLocaleChange(() => {
const webview = plus.webview.getWebviewById(routeMeta.id + '')
if (!webview) {
return
}
const newPullToRefresh: PlusWebviewWebviewPullToRefreshStyles = {
support: true,
}
if (contentdownI18n) {
newPullToRefresh.contentdown = {
caption: pullToRefresh.contentdown!.caption,
}
}
if (contentoverI18n) {
newPullToRefresh.contentover = {
caption: pullToRefresh.contentover!.caption,
}
}
if (contentrefreshI18n) {
newPullToRefresh.contentrefresh = {
caption: pullToRefresh.contentrefresh!.caption,
}
}
if (__DEV__) {
console.log(formatLog('updateWebview', webview.id, newPullToRefresh))
}
webview.setStyle({
pullToRefresh: newPullToRefresh,
})
})
}
return pullToRefresh
}
const defaultAndroidPullToRefresh = { support: true, style: 'circle' }
......
import { isArray } from '@vue/shared'
import {
BACKGROUND_COLOR,
formatLog,
ON_NAVIGATION_BAR_BUTTON_TAP,
} from '@dcloudio/uni-shared'
import { isColor } from './utils'
......@@ -52,16 +53,28 @@ function initTitleNViewI18n(
if (!i18nResult) {
return titleNView
}
const [titleTextI18n, _searchInputPlaceholderI18n] = i18nResult
if (titleTextI18n) {
const [titleTextI18n, searchInputPlaceholderI18n] = i18nResult
if (titleTextI18n || searchInputPlaceholderI18n) {
uni.onLocaleChange(() => {
const webview = plus.webview.getWebviewById(routeMeta.id + '')
webview &&
webview.setStyle({
titleNView: {
titleText: titleNView.titleText,
},
})
if (!webview) {
return
}
const newTitleNView: PlusWebviewWebviewTitleNViewStyles = {}
if (titleTextI18n) {
newTitleNView.titleText = titleNView.titleText
}
if (searchInputPlaceholderI18n) {
newTitleNView.searchInput = {
placeholder: titleNView.searchInput!.placeholder,
}
}
if (__DEV__) {
console.log(formatLog('updateWebview', webview.id, newTitleNView))
}
webview.setStyle({
titleNView: newTitleNView,
})
})
}
return titleNView
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册