Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
anyefeiyu
uni-app
提交
07c9f2a3
U
uni-app
项目概览
anyefeiyu
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
07c9f2a3
编写于
2月 24, 2021
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(i18n): refactor
上级
3f6eac4a
变更
17
展开全部
隐藏空白更改
内联
并排
Showing
17 changed file
with
316 addition
and
342 deletion
+316
-342
build/rollup.config.mp.js
build/rollup.config.mp.js
+4
-2
build/rollup.config.qa.js
build/rollup.config.qa.js
+4
-2
build/rollup.config.service.js
build/rollup.config.service.js
+4
-2
packages/uni-app-plus/dist/index.v3.js
packages/uni-app-plus/dist/index.v3.js
+139
-89
packages/uni-app-plus/dist/view.umd.min.js
packages/uni-app-plus/dist/view.umd.min.js
+2
-2
packages/uni-cli-shared/components/i18n/index.js
packages/uni-cli-shared/components/i18n/index.js
+12
-0
packages/uni-cli-shared/components/unicloud-db.vue
packages/uni-cli-shared/components/unicloud-db.vue
+4
-22
packages/uni-h5/dist/index.umd.min.js
packages/uni-h5/dist/index.umd.min.js
+1
-1
packages/uni-mp-alipay/dist/index.js
packages/uni-mp-alipay/dist/index.js
+1
-5
packages/uni-quickapp-native/dist/vue.dev.js
packages/uni-quickapp-native/dist/vue.dev.js
+1
-1
packages/uni-quickapp-native/dist/vue.prod.js
packages/uni-quickapp-native/dist/vue.prod.js
+1
-1
src/core/helpers/i18n/index.js
src/core/helpers/i18n/index.js
+7
-49
src/core/service/plugins/app/create-app.js
src/core/service/plugins/app/create-app.js
+1
-9
src/core/view/mixins/i18n.js
src/core/view/mixins/i18n.js
+0
-20
src/platforms/app-plus/service/framework/app.js
src/platforms/app-plus/service/framework/app.js
+0
-8
src/platforms/app-plus/view/bridge/subscribe/index.js
src/platforms/app-plus/view/bridge/subscribe/index.js
+2
-2
src/platforms/h5/components/app/popup/actionSheet.vue
src/platforms/h5/components/app/popup/actionSheet.vue
+133
-127
未找到文件。
build/rollup.config.mp.js
浏览文件 @
07c9f2a3
const
path
=
require
(
'
path
'
)
const
path
=
require
(
'
path
'
)
const
json
=
require
(
'
@rollup/plugin-json
'
)
const
alias
=
require
(
'
@rollup/plugin-alias
'
)
const
replace
=
require
(
'
@rollup/plugin-replace
'
)
...
...
@@ -71,7 +72,8 @@ module.exports = {
find
:
'
uni-helpers
'
,
replacement
:
path
.
resolve
(
__dirname
,
'
../src/core/helpers
'
)
}]
}),
}),
json
(),
replace
({
__GLOBAL__
:
platform
.
prefix
,
__PLATFORM_TITLE__
:
platform
.
title
,
...
...
build/rollup.config.qa.js
浏览文件 @
07c9f2a3
const
path
=
require
(
'
path
'
)
const
path
=
require
(
'
path
'
)
const
json
=
require
(
'
@rollup/plugin-json
'
)
const
alias
=
require
(
'
@rollup/plugin-alias
'
)
const
replace
=
require
(
'
@rollup/plugin-replace
'
)
const
nodeResolve
=
require
(
'
@rollup/plugin-node-resolve
'
)
...
...
@@ -56,7 +57,8 @@ alias({
find
:
'
uni-api-protocol
'
,
replacement
:
resolve
(
'
src/core/helpers/protocol
'
)
}]
}),
}),
json
(),
nodeResolve
(),
requireContext
(),
commonjs
(),
...
...
build/rollup.config.service.js
浏览文件 @
07c9f2a3
const
path
=
require
(
'
path
'
)
const
path
=
require
(
'
path
'
)
const
json
=
require
(
'
@rollup/plugin-json
'
)
const
alias
=
require
(
'
@rollup/plugin-alias
'
)
const
replace
=
require
(
'
@rollup/plugin-replace
'
)
...
...
@@ -23,7 +24,8 @@ module.exports = {
replacement
:
path
.
resolve
(
__dirname
,
'
../src/core/helpers
'
)
}
]
}),
}),
json
(),
replace
({
__GLOBAL__
:
'
getGlobalUni()
'
,
__PLATFORM_TITLE__
:
'
app-plus-nvue
'
...
...
packages/uni-app-plus/dist/index.v3.js
浏览文件 @
07c9f2a3
...
...
@@ -2272,10 +2272,6 @@ var serviceContext = (function () {
return compiled;
}
let curLocale = 'en';
let fallbackLocale = 'en';
let curMessages = {};
let messages = {};
const hasOwnProperty$1 = Object.prototype.hasOwnProperty;
const hasOwn$1 = (val, key) => hasOwnProperty$1.call(val, key);
const defaultFormatter = new BaseFormatter();
...
...
@@ -2285,9 +2281,9 @@ var serviceContext = (function () {
function startsWith(str, parts) {
return parts.find((part) => str.indexOf(part) === 0);
}
function normalizeLocale(locale) {
function normalizeLocale(locale
, messages
) {
if (!locale) {
return
fallbackLocale
;
return;
}
locale = locale.trim().replace(/_/g, '-');
if (messages[locale]) {
...
...
@@ -2310,31 +2306,135 @@ var serviceContext = (function () {
if (lang) {
return lang;
}
return fallbackLocale;
}
var index = {
init(options) {
if (options.fallbackLocale) {
fallbackLocale = options.fallbackLocale;
class I18n {
constructor({ locale, fallbackLocale, messages, watcher, formater, }) {
this.locale = 'en';
this.fallbackLocale = 'en';
this.message = {};
this.messages = {};
this.watchers = [];
if (fallbackLocale) {
this.fallbackLocale = fallbackLocale;
}
messages = options.messages;
this.setLocale(options.locale);
},
this.formater = formater || defaultFormatter;
this.messages = messages;
this.setLocale(locale);
if (watcher) {
this.watchLocale(watcher);
}
}
setLocale(locale) {
curLocale = normalizeLocale(locale);
curMessages = messages[curLocale];
},
const oldLocale = this.locale;
this.locale = normalizeLocale(locale, this.messages) || this.fallbackLocale;
this.message = this.messages[this.locale];
this.watchers.forEach((watcher) => {
watcher(this.locale, oldLocale);
});
}
getLocale() {
return curLocale;
},
return this.locale;
}
watchLocale(fn) {
const index = this.watchers.push(fn) - 1;
return () => {
this.watchers.splice(index, 1);
};
}
t(key, values) {
if (!hasOwn$1(
curMessages
, key)) {
if (!hasOwn$1(
this.message
, key)) {
console.warn(`Cannot translate the value of keypath ${key}. Use the value of keypath as default.`);
return key;
}
return defaultFormatter.interpolate(curMessages[key], values).join('');
},
};
return this.formater.interpolate(this.message[key], values).join('');
}
}
function initLocaleWatcher(appVm, i18n) {
appVm.$i18n &&
appVm.$i18n.vm.$watch('locale', (newLocale) => {
i18n.setLocale(newLocale);
}, {
immediate: true,
});
}
function getDefaultLocale() {
if (typeof navigator !== 'undefined') {
return navigator.userLanguage || navigator.language;
}
if (typeof plus !== 'undefined') {
// TODO 待调整为最新的获取语言代码
return plus.os.language;
}
return uni.getSystemInfoSync().language;
}
function initVueI18n(messages, fallbackLocale = 'en', locale) {
const i18n = new I18n({
locale: locale || fallbackLocale,
fallbackLocale,
messages,
});
let t = (key, values) => {
if (typeof getApp !== 'function') {
// app-plus view
/* eslint-disable no-func-assign */
t = function (key, values) {
return i18n.t(key, values);
};
}
else {
const appVm = getApp().$vm;
if (!appVm.$t || !appVm.$i18n) {
if (!locale) {
i18n.setLocale(getDefaultLocale());
}
/* eslint-disable no-func-assign */
t = function (key, values) {
return i18n.t(key, values);
};
}
else {
initLocaleWatcher(appVm, i18n);
/* eslint-disable no-func-assign */
t = function (key, values) {
const $i18n = appVm.$i18n;
const silentTranslationWarn = $i18n.silentTranslationWarn;
$i18n.silentTranslationWarn = true;
const msg = appVm.$t(key, values);
$i18n.silentTranslationWarn = silentTranslationWarn;
if (msg !== key) {
return msg;
}
return i18n.t(key, values);
};
}
}
return t(key, values);
};
return {
t(key, values) {
return t(key, values);
},
setLocale(newLocale) {
return i18n.setLocale(newLocale);
},
mixin: {
beforeCreate() {
const unwatch = i18n.watchLocale(() => {
this.$forceUpdate();
});
this.$once('hook:beforeDestroy', function () {
unwatch();
});
},
methods: {
$$t(key, values) {
return t(key, values);
},
},
},
};
}
var en = {
"uni.showActionSheet.cancel": "cancel",
...
...
@@ -2386,7 +2486,7 @@ var serviceContext = (function () {
"uni.button.feedback.send": "發送"
};
const messages
$1
= {
const messages = {
en,
es,
fr,
...
...
@@ -2394,56 +2494,10 @@ var serviceContext = (function () {
'zh-Hant': zhHant
};
const fallbackLocale
$1
= 'en';
const fallbackLocale = 'en';
function initI18n (locale, onChange) {
index.init({
locale,
fallbackLocale: fallbackLocale$1,
messages: messages$1
});
if (onChange) {
index.watchLocale((newLocale, oldLocale) => {
onChange(newLocale, oldLocale);
});
}
}
function initLocaleWatcher (appVm) {
appVm.$i18n.vm.$watch('locale', (newLocale) => {
index.setLocale(newLocale);
}, {
immediate: true
});
}
function t (key, values) {
if (__VIEW__) {
return index.t(key, values)
}
const appVm = getApp().$vm;
if (!appVm.$t) {
/* eslint-disable no-func-assign */
t = function (key, values) {
return index.t(key, values)
};
} else {
initLocaleWatcher(appVm);
/* eslint-disable no-func-assign */
t = function (key, values) {
const $i18n = appVm.$i18n;
const silentTranslationWarn = $i18n.silentTranslationWarn;
$i18n.silentTranslationWarn = true;
const msg = appVm.$t(key, values);
$i18n.silentTranslationWarn = silentTranslationWarn;
if (msg !== key) {
return msg
}
return index.t(key, values)
};
}
return t(key, values)
}
const i18n = initVueI18n( messages , fallbackLocale);
const t = i18n.t;
const showModal = {
title: {
...
...
@@ -5820,12 +5874,12 @@ var serviceContext = (function () {
}, fail);
}
let index
$1
= 0;
let index = 0;
function saveFile$1 ({
tempFilePath
} = {}, callbackId) {
const errorCallback = warpPlusErrorCallback(callbackId, 'saveFile');
const fileName = `${Date.now()}${index
$1
++}${getExtName(tempFilePath)}`;
const fileName = `${Date.now()}${index++}${getExtName(tempFilePath)}`;
plus.io.resolveLocalFileSystemURL(tempFilePath, entry => { // 读取临时文件 FileEntry
getSavedFileDir(dir => {
...
...
@@ -12323,7 +12377,7 @@ var serviceContext = (function () {
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
var messages$
2
= {
var messages$
1
= {
2: 'need dictionary', /* Z_NEED_DICT 2 */
1: 'stream end', /* Z_STREAM_END 1 */
0: '', /* Z_OK 0 */
...
...
@@ -12458,7 +12512,7 @@ var serviceContext = (function () {
var OS_CODE = 0x03; // Unix :) . Don't detect, use this default.
function err(strm, errorCode) {
strm.msg = messages$
2
[errorCode];
strm.msg = messages$
1
[errorCode];
return errorCode;
}
...
...
@@ -14606,7 +14660,7 @@ var serviceContext = (function () {
);
if (status !== Z_OK$1) {
throw new Error(messages$
2
[status]);
throw new Error(messages$
1
[status]);
}
if (opt.header) {
...
...
@@ -14628,7 +14682,7 @@ var serviceContext = (function () {
status = deflate_1.deflateSetDictionary(this.strm, dict);
if (status !== Z_OK$1) {
throw new Error(messages$
2
[status]);
throw new Error(messages$
1
[status]);
}
this._dict_set = true;
...
...
@@ -14806,7 +14860,7 @@ var serviceContext = (function () {
deflator.push(input, true);
// That will never happens, if you don't cheat with options :)
if (deflator.err) { throw deflator.msg || messages$
2
[deflator.err]; }
if (deflator.err) { throw deflator.msg || messages$
1
[deflator.err]; }
return deflator.result;
}
...
...
@@ -17358,7 +17412,7 @@ var serviceContext = (function () {
);
if (status !== constants.Z_OK) {
throw new Error(messages$
2
[status]);
throw new Error(messages$
1
[status]);
}
this.header = new gzheader();
...
...
@@ -17376,7 +17430,7 @@ var serviceContext = (function () {
if (opt.raw) { //In raw mode we need to set the dictionary early
status = inflate_1.inflateSetDictionary(this.strm, opt.dictionary);
if (status !== constants.Z_OK) {
throw new Error(messages$
2
[status]);
throw new Error(messages$
1
[status]);
}
}
}
...
...
@@ -17606,7 +17660,7 @@ var serviceContext = (function () {
inflator.push(input, true);
// That will never happens, if you don't cheat with options :)
if (inflator.err) { throw inflator.msg || messages$
2
[inflator.err]; }
if (inflator.err) { throw inflator.msg || messages$
1
[inflator.err]; }
return inflator.result;
}
...
...
@@ -20765,7 +20819,6 @@ var serviceContext = (function () {
if (process.env.NODE_ENV !== 'production') {
console.log('[uni-app] registerApp');
}
appVm.$$t = t;
appCtx = appVm;
appCtx.$vm = appVm;
...
...
@@ -20775,9 +20828,6 @@ var serviceContext = (function () {
// merge globalData
appCtx.globalData = Object.assign(globalData, appCtx.globalData);
// TODO
initI18n(plus.os.language);
initOn(UniServiceJSBridge.on, {
getApp: getApp$1,
getCurrentPages: getCurrentPages$1
...
...
@@ -21746,7 +21796,7 @@ var serviceContext = (function () {
UniServiceJSBridge.invokeCallbackHandler = invokeCallbackHandler;
UniServiceJSBridge.removeCallbackHandler = removeCallbackHandler;
var index$
2
= {
var index$
1
= {
__vuePlugin: vuePlugin,
__definePage: definePage,
__registerApp: registerApp,
...
...
@@ -21756,7 +21806,7 @@ var serviceContext = (function () {
getCurrentPages: getCurrentPages$1
};
return index$
2
;
return index$
1
;
}());
...
...
packages/uni-app-plus/dist/view.umd.min.js
浏览文件 @
07c9f2a3
此差异已折叠。
点击以展开。
packages/uni-cli-shared/components/i18n/index.js
0 → 100644
浏览文件 @
07c9f2a3
import
en
from
'
./en.json
'
import
es
from
'
./es.json
'
import
fr
from
'
./fr.json
'
import
zhHans
from
'
./zh-Hans.json
'
import
zhHant
from
'
./zh-Hant.json
'
export
default
{
en
,
es
,
fr
,
'
zh-Hans
'
:
zhHans
,
'
zh-Hant
'
:
zhHant
}
packages/uni-cli-shared/components/unicloud-db.vue
浏览文件 @
07c9f2a3
...
...
@@ -12,28 +12,10 @@
</
template
>
<
script
>
import
defaultMessage
from
'
./i18n/zh-Hans.json
'
function
createTranslate
(
defaultMessage
)
{
let
t
=
(
key
,
values
)
=>
{
const
appVm
=
getApp
().
$vm
if
(
appVm
&&
appVm
.
$t
)
{
t
=
(
key
,
values
)
=>
{
const
msg
=
appVm
.
$t
(
key
,
values
)
if
(
msg
!==
key
)
{
return
msg
}
return
defaultMessage
[
key
]
}
}
else
{
t
=
(
key
,
values
)
=>
{
return
defaultMessage
[
key
]
}
}
return
t
(
key
,
values
)
}
return
t
}
const
t
=
createTranslate
(
defaultMessage
)
import
{
initVueI18n
}
from
'
@dcloudio/uni-i18n
'
import
messages
from
'
./i18n/index
'
const
{
t
}
=
initVueI18n
(
messages
)
const
events
=
{
load
:
'
load
'
,
...
...
packages/uni-h5/dist/index.umd.min.js
浏览文件 @
07c9f2a3
此差异已折叠。
点击以展开。
packages/uni-mp-alipay/dist/index.js
浏览文件 @
07c9f2a3
...
...
@@ -907,11 +907,6 @@ const protocols = { // 需要做转换的 API 列表
text
:
'
data
'
}
},
pageScrollTo
:
{
args
:
{
duration
:
false
}
},
login
:
{
name
:
'
getAuthCode
'
,
returnValue
(
result
)
{
...
...
@@ -1011,6 +1006,7 @@ const protocols = { // 需要做转换的 API 列表
result
.
userName
=
info
.
fullname
;
result
.
provinceName
=
info
.
prov
;
result
.
cityName
=
info
.
city
;
result
.
countyName
=
info
.
area
;
result
.
detailInfo
=
info
.
address
;
result
.
telNumber
=
info
.
mobilePhone
;
result
.
errMsg
=
result
.
resultStatus
;
...
...
packages/uni-quickapp-native/dist/vue.dev.js
浏览文件 @
07c9f2a3
此差异已折叠。
点击以展开。
packages/uni-quickapp-native/dist/vue.prod.js
浏览文件 @
07c9f2a3
此差异已折叠。
点击以展开。
src/core/helpers/i18n/index.js
浏览文件 @
07c9f2a3
import
i18n
from
'
@dcloudio/uni-i18n
'
import
{
initVueI18n
}
from
'
@dcloudio/uni-i18n
'
import
en
from
'
./en.json
'
import
es
from
'
./es.json
'
...
...
@@ -16,51 +18,7 @@ const messages = {
const
fallbackLocale
=
'
en
'
export
function
initI18n
(
locale
,
onChange
)
{
i18n
.
init
({
locale
,
fallbackLocale
,
messages
})
if
(
onChange
)
{
i18n
.
watchLocale
((
newLocale
,
oldLocale
)
=>
{
onChange
(
newLocale
,
oldLocale
)
})
}
}
function
initLocaleWatcher
(
appVm
)
{
appVm
.
$i18n
.
vm
.
$watch
(
'
locale
'
,
(
newLocale
)
=>
{
i18n
.
setLocale
(
newLocale
)
},
{
immediate
:
true
})
}
export
function
t
(
key
,
values
)
{
if
(
__VIEW__
)
{
return
i18n
.
t
(
key
,
values
)
}
const
appVm
=
getApp
().
$vm
if
(
!
appVm
.
$t
)
{
/* eslint-disable no-func-assign */
t
=
function
(
key
,
values
)
{
return
i18n
.
t
(
key
,
values
)
}
}
else
{
initLocaleWatcher
(
appVm
)
/* eslint-disable no-func-assign */
t
=
function
(
key
,
values
)
{
const
$i18n
=
appVm
.
$i18n
const
silentTranslationWarn
=
$i18n
.
silentTranslationWarn
$i18n
.
silentTranslationWarn
=
true
const
msg
=
appVm
.
$t
(
key
,
values
)
$i18n
.
silentTranslationWarn
=
silentTranslationWarn
if
(
msg
!==
key
)
{
return
msg
}
return
i18n
.
t
(
key
,
values
)
}
}
return
t
(
key
,
values
)
}
const
i18n
=
initVueI18n
(
__PLATFORM__
===
'
app-plus
'
||
__PLATFORM__
===
'
h5
'
?
messages
:
{},
fallbackLocale
)
export
const
t
=
i18n
.
t
export
const
i18nMixin
=
i18n
.
mixin
export
const
setLocale
=
i18n
.
setLocale
src/core/service/plugins/app/create-app.js
浏览文件 @
07c9f2a3
import
{
t
,
initI18n
}
from
'
uni-core/helpers/i18n
'
import
initRouterGuard
from
'
./router-guard
'
let
appVm
=
false
...
...
@@ -69,13 +64,10 @@ export function getCurrentPages (isAll = false, ignoreError = false) {
}
export
default
function
createApp
(
vm
,
routes
)
{
appVm
=
vm
appVm
=
vm
appVm
.
$vm
=
vm
appVm
.
$$t
=
t
appVm
.
globalData
=
appVm
.
$options
.
globalData
||
{}
// h5
initI18n
(
navigator
.
userLanguage
||
navigator
.
language
)
// initEvents(appVm)
initRouterGuard
(
appVm
,
routes
)
}
src/core/view/mixins/i18n.js
已删除
100644 → 0
浏览文件 @
3f6eac4a
import
i18n
from
'
@dcloudio/uni-i18n
'
import
{
t
}
from
'
uni-core/helpers/i18n
'
export
default
{
beforeCreate
()
{
const
unwatch
=
i18n
.
watchLocale
(()
=>
{
this
.
$forceUpdate
()
})
this
.
$once
(
'
hook:beforeDestroy
'
,
function
()
{
unwatch
()
})
},
methods
:
{
$$t
(
key
,
values
)
{
return
t
(
key
,
values
)
}
}
}
src/platforms/app-plus/service/framework/app.js
浏览文件 @
07c9f2a3
import
{
t
,
initI18n
}
from
'
uni-core/helpers/i18n
'
import
{
callAppHook
}
from
'
uni-core/service/plugins/util
'
...
...
@@ -210,7 +206,6 @@ export function registerApp (appVm) {
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
console
.
log
(
'
[uni-app] registerApp
'
)
}
appVm
.
$$t
=
t
appCtx
=
appVm
appCtx
.
$vm
=
appVm
...
...
@@ -220,9 +215,6 @@ export function registerApp (appVm) {
// merge globalData
appCtx
.
globalData
=
Object
.
assign
(
globalData
,
appCtx
.
globalData
)
// TODO
initI18n
(
plus
.
os
.
language
)
initOn
(
UniServiceJSBridge
.
on
,
{
getApp
,
getCurrentPages
...
...
src/platforms/app-plus/view/bridge/subscribe/index.js
浏览文件 @
07c9f2a3
...
...
@@ -3,7 +3,7 @@ import {
}
from
'
uni-shared
'
import
{
initI18n
setLocale
}
from
'
uni-core/helpers/i18n
'
import
{
...
...
@@ -57,7 +57,7 @@ function onPageCreate ({
onPageReachBottom
,
onReachBottomDistance
},
pageId
)
{
initI18n
(
locale
)
setLocale
(
locale
)
onCssVar
({
statusbarHeight
,
...
...
src/platforms/h5/components/app/popup/actionSheet.vue
浏览文件 @
07c9f2a3
<
template
>
<uni-actionsheet
@
touchmove.prevent
>
<transition
name=
"uni-fade"
>
<div
v-show=
"visible"
class=
"uni-mask uni-actionsheet__mask"
@
click=
"_close(-1)"
<div
v-show=
"visible"
class=
"uni-mask uni-actionsheet__mask"
@
click=
"_close(-1)"
/>
</transition>
<div
:class=
"
{ 'uni-actionsheet_toggle': visible }"
:style="popupStyle.content"
class="uni-actionsheet"
<div
:class=
"
{ 'uni-actionsheet_toggle': visible }"
:style="popupStyle.content"
class="uni-actionsheet"
>
<div
ref=
"main"
class=
"uni-actionsheet__menu"
@
wheel=
"_handleWheel"
<div
ref=
"main"
class=
"uni-actionsheet__menu"
@
wheel=
"_handleWheel"
>
<!-- title占位 -->
<div
v-if=
"title"
class=
"uni-actionsheet__cell"
:style=
"
{height:`${titleHeight}px`}"
<div
v-if=
"title"
class=
"uni-actionsheet__cell"
:style=
"
{height:`${titleHeight}px`}"
/>
<div
v-if=
"title"
class=
"uni-actionsheet__title"
<div
v-if=
"title"
class=
"uni-actionsheet__title"
>
{{
title
}}
</div>
<div
:style=
"
{maxHeight:`${HEIGHT}px`,overflow:'hidden'}"
>
<div
ref=
"content"
>
<div
v-for=
"(itemTitle, index) in itemList"
:key=
"index"
:style=
"
{ color: itemColor }"
<div
:style=
"
{maxHeight:`${HEIGHT}px`,overflow:'hidden'}">
<div
ref=
"content"
>
<div
v-for=
"(itemTitle, index) in itemList"
:key=
"index"
:style=
"
{ color: itemColor }"
class="uni-actionsheet__cell"
@click="_close(index)"
@click="_close(index)"
>
{{
itemTitle
}}
</div>
...
...
@@ -48,26 +44,28 @@
</div>
</div>
<div
class=
"uni-actionsheet__action"
>
<div
:style=
"
{ color: itemColor }"
class="uni-actionsheet__cell"
@click="_close(-1)"
<div
:style=
"
{ color: itemColor }"
class="uni-actionsheet__cell"
@click="_close(-1)"
>
{{
$$t
(
'
uni.showActionSheet.cancel
'
)
}}
</div>
</div>
<div
:style=
"popupStyle.triangle"
/>
</div>
<keypress
:disable=
"!visible"
@
esc=
"_close(-1)"
<keypress
:disable=
"!visible"
@
esc=
"_close(-1)"
/>
</uni-actionsheet>
</
template
>
<
script
>
import
popup
from
'
./mixins/popup
'
import
keypress
from
'
../../../helpers/keypress
'
import
i18n
from
'
uni-mixins/i18n
'
import
keypress
from
'
../../../helpers/keypress
'
import
{
i18nMixin
}
from
'
uni-core/helpers/i18n
'
import
touchtrack
from
'
uni-mixins/touchtrack
'
import
scroller
from
'
uni-mixins/scroller/index
'
import
{
...
...
@@ -110,8 +108,10 @@ function initClick (dom) {
export
default
{
name
:
'
ActionSheet
'
,
components
:
{
keypress
},
mixins
:
[
i18n
,
popup
,
touchtrack
,
scroller
],
components
:
{
keypress
},
mixins
:
[
i18nMixin
,
popup
,
touchtrack
,
scroller
],
props
:
{
title
:
{
type
:
String
,
...
...
@@ -150,7 +150,9 @@ export default {
if
(
newValue
)
{
this
.
$nextTick
(()
=>
{
// title 占位
if
(
this
.
title
)
{
this
.
titleHeight
=
document
.
querySelector
(
'
.uni-actionsheet__title
'
).
offsetHeight
}
if
(
this
.
title
)
{
this
.
titleHeight
=
document
.
querySelector
(
'
.uni-actionsheet__title
'
).
offsetHeight
}
// 滚动条更新
this
.
_scroller
.
update
()
// 获取contentHeight 滚动时使用
...
...
@@ -222,54 +224,54 @@ export default {
}
</
script
>
<
style
>
uni-actionsheet
{
display
:
block
;
box-sizing
:
border-box
;
}
uni-actionsheet
{
display
:
block
;
box-sizing
:
border-box
;
}
uni-actionsheet
.uni-actionsheet
{
position
:
fixed
;
left
:
6px
;
right
:
6px
;
bottom
:
6px
;
transform
:
translate
(
0
,
100%
);
backface-visibility
:
hidden
;
z-index
:
999
;
visibility
:
hidden
;
transition
:
transform
0.3s
,
visibility
0.3s
;
}
uni-actionsheet
.uni-actionsheet
{
position
:
fixed
;
left
:
6px
;
right
:
6px
;
bottom
:
6px
;
transform
:
translate
(
0
,
100%
);
backface-visibility
:
hidden
;
z-index
:
999
;
visibility
:
hidden
;
transition
:
transform
0.3s
,
visibility
0.3s
;
}
uni-actionsheet
.uni-actionsheet.uni-actionsheet_toggle
{
visibility
:
visible
;
transform
:
translate
(
0
,
0
);
}
uni-actionsheet
.uni-actionsheet.uni-actionsheet_toggle
{
visibility
:
visible
;
transform
:
translate
(
0
,
0
);
}
uni-actionsheet
.uni-actionsheet
*
{
box-sizing
:
border-box
;
}
uni-actionsheet
.uni-actionsheet
*
{
box-sizing
:
border-box
;
}
uni-actionsheet
.uni-actionsheet__menu
,
uni-actionsheet
.uni-actionsheet__action
{
border-radius
:
5px
;
background-color
:
#fcfcfd
;
}
uni-actionsheet
.uni-actionsheet__menu
,
uni-actionsheet
.uni-actionsheet__action
{
border-radius
:
5px
;
background-color
:
#fcfcfd
;
}
uni-actionsheet
.uni-actionsheet__action
{
margin-top
:
6px
;
}
uni-actionsheet
.uni-actionsheet__action
{
margin-top
:
6px
;
}
uni-actionsheet
.uni-actionsheet__cell
,
uni-actionsheet
.uni-actionsheet__title
{
position
:
relative
;
padding
:
10px
6px
;
text-align
:
center
;
font-size
:
18px
;
text-overflow
:
ellipsis
;
overflow
:
hidden
;
cursor
:
pointer
;
}
uni-actionsheet
.uni-actionsheet__cell
,
uni-actionsheet
.uni-actionsheet__title
{
position
:
relative
;
padding
:
10px
6px
;
text-align
:
center
;
font-size
:
18px
;
text-overflow
:
ellipsis
;
overflow
:
hidden
;
cursor
:
pointer
;
}
uni-actionsheet
.uni-actionsheet__title
{
uni-actionsheet
.uni-actionsheet__title
{
position
:
absolute
;
top
:
0
;
right
:
0
;
...
...
@@ -278,52 +280,56 @@ uni-actionsheet .uni-actionsheet__title{
background-color
:
#fff
;
border-radius
:
5px
5px
0
0
;
border-bottom
:
1px
solid
#e5e5e5
;
}
uni-actionsheet
.uni-actionsheet__cell
:before
{
content
:
" "
;
position
:
absolute
;
left
:
0
;
top
:
0
;
right
:
0
;
height
:
1px
;
border-top
:
1px
solid
#e5e5e5
;
color
:
#e5e5e5
;
transform-origin
:
0
0
;
transform
:
scaleY
(
0.5
);
}
uni-actionsheet
.uni-actionsheet__cell
:active
{
background-color
:
#ececec
;
}
uni-actionsheet
.uni-actionsheet__cell
:first-child:before
{
display
:
none
;
}
@media
screen
and
(
min-width
:
500px
)
and
(
min-height
:
500px
)
{
.uni-mask.uni-actionsheet__mask
{
background
:
none
;
}
uni-actionsheet
.uni-actionsheet
{
width
:
300px
;
left
:
50%
;
right
:
auto
;
top
:
50%
;
bottom
:
auto
;
transform
:
translate
(
-50%
,
-50%
);
opacity
:
0
;
transition
:
opacity
0.3s
,
visibility
0.3s
;
}
uni-actionsheet
.uni-actionsheet.uni-actionsheet_toggle
{
opacity
:
1
;
transform
:
translate
(
-50%
,
-50%
);
uni-actionsheet
.uni-actionsheet__cell
:before
{
content
:
" "
;
position
:
absolute
;
left
:
0
;
top
:
0
;
right
:
0
;
height
:
1px
;
border-top
:
1px
solid
#e5e5e5
;
color
:
#e5e5e5
;
transform-origin
:
0
0
;
transform
:
scaleY
(
0.5
);
}
uni-actionsheet
.uni-actionsheet__menu
{
box-shadow
:
0px
0
20px
5px
rgba
(
0
,
0
,
0
,
0.3
);
uni-actionsheet
.uni-actionsheet__cell
:active
{
background-color
:
#ececec
;
}
uni-actionsheet
.uni-actionsheet__action
{
uni-actionsheet
.uni-actionsheet__cell
:first-child:before
{
display
:
none
;
}
}
</
style
>
@media
screen
and
(
min-width
:
500px
)
and
(
min-height
:
500px
)
{
.uni-mask.uni-actionsheet__mask
{
background
:
none
;
}
uni-actionsheet
.uni-actionsheet
{
width
:
300px
;
left
:
50%
;
right
:
auto
;
top
:
50%
;
bottom
:
auto
;
transform
:
translate
(
-50%
,
-50%
);
opacity
:
0
;
transition
:
opacity
0.3s
,
visibility
0.3s
;
}
uni-actionsheet
.uni-actionsheet.uni-actionsheet_toggle
{
opacity
:
1
;
transform
:
translate
(
-50%
,
-50%
);
}
uni-actionsheet
.uni-actionsheet__menu
{
box-shadow
:
0px
0
20px
5px
rgba
(
0
,
0
,
0
,
0.3
);
}
uni-actionsheet
.uni-actionsheet__action
{
display
:
none
;
}
}
</
style
>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录