Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
ed8fe0ac
U
uni-app
项目概览
DCloud
/
uni-app
4 个月 前同步成功
通知
731
Star
38707
Fork
3642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
7
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
7
Issue
7
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
ed8fe0ac
编写于
9月 12, 2019
作者:
fxy060608
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'dev' of
https://github.com/dcloudio/uni-app
into alpha
上级
3bee9826
5e032823
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
190 addition
and
102 deletion
+190
-102
lib/h5/ui.js
lib/h5/ui.js
+24
-0
packages/uni-app-plus-nvue/dist/index.js
packages/uni-app-plus-nvue/dist/index.js
+53
-27
packages/vue-cli-plugin-hbuilderx/build/webpack.nvue.conf.js
packages/vue-cli-plugin-hbuilderx/build/webpack.nvue.conf.js
+7
-5
packages/vue-cli-plugin-uni/lib/configure-webpack.js
packages/vue-cli-plugin-uni/lib/configure-webpack.js
+2
-1
packages/vue-cli-plugin-uni/lib/env.js
packages/vue-cli-plugin-uni/lib/env.js
+3
-10
packages/vue-cli-plugin-uni/util/on-errors.js
packages/vue-cli-plugin-uni/util/on-errors.js
+2
-33
packages/vue-cli-plugin-uni/util/on-warnings.js
packages/vue-cli-plugin-uni/util/on-warnings.js
+11
-0
packages/vue-cli-plugin-uni/util/stringify.js
packages/vue-cli-plugin-uni/util/stringify.js
+33
-0
src/platforms/app-plus/service/api/network/socket.js
src/platforms/app-plus/service/api/network/socket.js
+48
-24
src/platforms/app-plus/service/bridge.js
src/platforms/app-plus/service/bridge.js
+7
-2
未找到文件。
lib/h5/ui.js
0 → 100644
浏览文件 @
ed8fe0ac
import
Vue
from
'
vue
'
// 使用白名单过滤(前期有一批自定义组件使用了 uni-)
import
tags
from
'
uni-helpers/tags
'
const
oldIsReservedTag
=
Vue
.
config
.
isReservedTag
Vue
.
config
.
isReservedTag
=
function
(
tag
)
{
return
tags
.
indexOf
(
tag
)
!==
-
1
||
oldIsReservedTag
(
tag
)
}
Vue
.
config
.
ignoredElements
=
tags
const
oldGetTagNamespace
=
Vue
.
config
.
getTagNamespace
const
conflictTags
=
[
'
switch
'
,
'
image
'
,
'
text
'
,
'
view
'
]
Vue
.
config
.
getTagNamespace
=
function
(
tag
)
{
if
(
~
conflictTags
.
indexOf
(
tag
))
{
// svg 部分标签名称与 uni 标签冲突
return
false
}
return
oldGetTagNamespace
(
tag
)
||
false
}
require
(
'
uni-components
'
)
packages/uni-app-plus-nvue/dist/index.js
浏览文件 @
ed8fe0ac
...
...
@@ -161,7 +161,7 @@ var serviceContext = (function () {
return
false
}
return
page
.
$page
.
meta
.
isTabBar
}
}
const
route
=
__uniRoutes
.
find
(
route
=>
route
.
path
.
slice
(
1
)
===
path
);
return
route
&&
route
.
meta
.
isTabBar
}
catch
(
e
)
{
...
...
@@ -174,6 +174,10 @@ var serviceContext = (function () {
function
base64ToArrayBuffer
(
data
)
{
return
base64Arraybuffer_2
(
data
)
}
function
arrayBufferToBase64
(
data
)
{
return
base64Arraybuffer_1
(
data
)
}
function
callApiSync
(
api
,
args
,
name
,
alias
)
{
...
...
@@ -2025,7 +2029,7 @@ var serviceContext = (function () {
required
:
true
}];
const
arrayBufferToBase64
=
[{
const
arrayBufferToBase64
$1
=
[{
name
:
'
arrayBuffer
'
,
type
:
[
ArrayBuffer
,
Uint8Array
],
required
:
true
...
...
@@ -2033,7 +2037,7 @@ var serviceContext = (function () {
var
require_context_module_0_0
=
/*#__PURE__*/
Object
.
freeze
({
base64ToArrayBuffer
:
base64ToArrayBuffer$1
,
arrayBufferToBase64
:
arrayBufferToBase64
arrayBufferToBase64
:
arrayBufferToBase64
$1
});
const
canIUse
=
[{
...
...
@@ -3713,13 +3717,13 @@ var serviceContext = (function () {
return
base64Arraybuffer_2
(
str
)
}
function
arrayBufferToBase64$
1
(
buffer
)
{
function
arrayBufferToBase64$
2
(
buffer
)
{
return
base64Arraybuffer_1
(
buffer
)
}
var
require_context_module_1_0
=
/*#__PURE__*/
Object
.
freeze
({
base64ToArrayBuffer
:
base64ToArrayBuffer$2
,
arrayBufferToBase64
:
arrayBufferToBase64$
1
arrayBufferToBase64
:
arrayBufferToBase64$
2
});
var
platformSchema
=
{};
...
...
@@ -6079,53 +6083,64 @@ var serviceContext = (function () {
}
}
let
socketTaskId
=
0
;
const
socketTasks
=
{};
const
publishStateChange$2
=
(
res
)
=>
{
publish
(
'
onSocketTaskStateChange
'
,
res
);
};
const
createSocketTaskById
=
function
(
socketTaskId
,
{
url
,
data
,
header
,
method
,
protocols
}
=
{})
{
// fixed by hxy 需要测试是否支持 arraybuffer
const
socket
=
requireNativePlugin
(
'
webSocket
'
);
socket
.
WebSocket
(
url
,
Array
.
isArray
(
protocols
)
?
protocols
.
join
(
'
,
'
)
:
protocols
);
// socket.binaryType = 'arraybuffer'
socketTasks
[
socketTaskId
]
=
socket
;
let
socket
;
function
getSocket
()
{
if
(
socket
)
{
return
socket
}
socket
=
requireNativePlugin
(
'
uni-webSocket
'
);
socket
.
onopen
(
function
(
e
)
{
publishStateChange$2
({
socketTaskId
,
socketTaskId
:
e
.
id
,
state
:
'
open
'
});
});
socket
.
onmessage
(
function
(
e
)
{
const
data
=
e
.
data
;
publishStateChange$2
({
socketTaskId
,
socketTaskId
:
e
.
id
,
state
:
'
message
'
,
data
:
e
.
data
data
:
typeof
data
===
'
object
'
?
base64ToArrayBuffer
(
data
.
base64
)
:
data
});
});
socket
.
onerror
(
function
(
e
)
{
publishStateChange$2
({
socketTaskId
,
socketTaskId
:
e
.
id
,
state
:
'
error
'
,
errMsg
:
e
.
message
errMsg
:
e
.
data
});
});
socket
.
onclose
(
function
(
e
)
{
const
socketTaskId
=
e
.
id
;
delete
socketTasks
[
socketTaskId
];
publishStateChange$2
({
socketTaskId
,
state
:
'
close
'
});
});
return
socket
}
const
createSocketTaskById
=
function
(
socketTaskId
,
{
url
,
data
,
header
,
method
,
protocols
}
=
{})
{
const
socket
=
getSocket
();
socket
.
WebSocket
({
id
:
socketTaskId
,
url
,
protocol
:
Array
.
isArray
(
protocols
)
?
protocols
.
join
(
'
,
'
)
:
protocols
});
socketTasks
[
socketTaskId
]
=
socket
;
return
{
socketTaskId
,
errMsg
:
'
createSocketTask:ok
'
...
...
@@ -6133,13 +6148,14 @@ var serviceContext = (function () {
};
function
createSocketTask
(
args
)
{
return
createSocketTaskById
(
++
socketTaskId
,
args
)
return
createSocketTaskById
(
String
(
Date
.
now
())
,
args
)
}
function
operateSocketTask
(
args
)
{
const
{
operationType
,
code
,
reason
,
data
,
socketTaskId
}
=
unpack
(
args
);
...
...
@@ -6152,13 +6168,23 @@ var serviceContext = (function () {
switch
(
operationType
)
{
case
'
send
'
:
if
(
data
)
{
socket
.
send
(
data
);
socket
.
send
({
id
:
socketTaskId
,
data
:
typeof
data
===
'
object
'
?
{
'
@type
'
:
'
binary
'
,
base64
:
arrayBufferToBase64
(
data
)
}
:
data
});
}
return
{
errMsg
:
'
operateSocketTask:ok
'
}
case
'
close
'
:
socket
.
close
(
code
);
socket
.
close
({
id
:
socketTaskId
,
code
,
reason
});
delete
socketTasks
[
socketTaskId
];
return
{
errMsg
:
'
operateSocketTask:ok
'
...
...
packages/vue-cli-plugin-hbuilderx/build/webpack.nvue.conf.js
浏览文件 @
ed8fe0ac
...
...
@@ -15,6 +15,7 @@ const WebpackErrorsPlugin = require('@dcloudio/vue-cli-plugin-uni/packages/webpa
const
WebpackUniMPPlugin
=
require
(
'
@dcloudio/webpack-uni-mp-loader/lib/plugin/index-new
'
)
const
onErrors
=
require
(
'
@dcloudio/vue-cli-plugin-uni/util/on-errors
'
)
const
onWarnings
=
require
(
'
@dcloudio/vue-cli-plugin-uni/util/on-warnings
'
)
const
cssLoaders
=
require
(
'
./css-loader.conf
'
)
const
vueLoaderOptions
=
require
(
'
./vue-loader.conf
'
)
...
...
@@ -65,7 +66,8 @@ const plugins = [
}),
new
webpack
.
ProvidePlugin
(
provide
),
new
WebpackErrorsPlugin
({
onErrors
onErrors
,
onWarnings
}),
new
WebpackAppPlusNVuePlugin
()
]
...
...
@@ -192,12 +194,12 @@ module.exports = function () {
},
externals
:
{
'
vue
'
:
'
Vue
'
},
performance
:
{
hints
:
false
},
performance
:
{
hints
:
false
},
optimization
:
{
namedModules
:
false
namedModules
:
false
},
output
:
{
path
:
process
.
env
.
UNI_OUTPUT_DIR
,
...
...
packages/vue-cli-plugin-uni/lib/configure-webpack.js
浏览文件 @
ed8fe0ac
...
...
@@ -190,9 +190,10 @@ module.exports = function configureWebpack (platformOptions, manifestPlatformOpt
if
(
runByHBuilderX
)
{
// 使用 HBuilderX 中运行时,调整错误日志输出
const
WebpackErrorsPlugin
=
require
(
'
../packages/webpack-errors-plugin
'
)
const
onErrors
=
require
(
'
../util/on-errors
'
)
const
onWarnings
=
require
(
'
../util/on-warnings
'
)
plugins
.
push
(
new
WebpackErrorsPlugin
({
onErrors
,
onWarnings
:
onErrors
onWarnings
}))
}
...
...
packages/vue-cli-plugin-uni/lib/env.js
浏览文件 @
ed8fe0ac
...
...
@@ -148,16 +148,9 @@ if (
platformOptions
.
uniStatistics
||
{}
)
if
(
uniStatistics
.
enable
!==
false
&&
(
process
.
env
.
NODE_ENV
===
'
production
'
||
uniStatistics
.
enable
===
'
development
'
)
)
{
if
(
process
.
UNI_STAT_CONFIG
.
appid
)
{
process
.
env
.
UNI_USING_STAT
=
true
}
else
{
if
(
uniStatistics
.
enable
!==
false
)
{
process
.
env
.
UNI_USING_STAT
=
true
if
(
!
process
.
UNI_STAT_CONFIG
.
appid
&&
process
.
env
.
NODE_ENV
===
'
production
'
)
{
console
.
log
()
console
.
warn
(
`当前应用未配置Appid,无法使用uni统计,详情参考:https://ask.dcloud.net.cn/article/36303`
)
console
.
log
()
...
...
packages/vue-cli-plugin-uni/util/on-errors.js
浏览文件 @
ed8fe0ac
const
path
=
require
(
'
path
'
)
const
formatErrors
=
require
(
'
./format-errors
'
)
const
stringify
=
require
(
'
./stringify
'
)
module
.
exports
=
function
(
errors
)
{
console
.
error
(
Array
.
from
(
new
Set
(
errors
.
map
(
err
=>
{
const
formatError
=
formatErrors
[
err
.
name
]
if
(
formatError
)
{
const
result
=
formatError
(
err
)
if
(
result
)
{
if
(
typeof
result
===
'
string
'
)
{
return
result
}
else
{
const
file
=
path
.
relative
(
process
.
env
.
UNI_INPUT_DIR
,
err
.
module
.
resource
).
split
(
'
?
'
)[
0
]
if
(
file
===
'
pages.json
'
)
{
result
.
line
=
1
}
return
`
${
result
.
message
}
at
${
file
}
:
${
result
.
line
||
1
}
`
}
}
else
if
(
result
===
false
)
{
return
''
// skip
}
}
return
err
.
message
})
)
)
.
filter
(
msg
=>
!!
msg
)
.
join
(
'
\n
'
)
)
console
.
error
(
stringify
(
errors
))
}
packages/vue-cli-plugin-uni/util/on-warnings.js
0 → 100644
浏览文件 @
ed8fe0ac
const
stringify
=
require
(
'
./stringify
'
)
module
.
exports
=
function
(
errors
)
{
const
{
runByHBuilderX
}
=
require
(
'
@dcloudio/uni-cli-shared
'
)
if
(
runByHBuilderX
)
{
console
.
log
(
stringify
(
errors
))
}
else
{
console
.
warn
(
stringify
(
errors
))
}
}
packages/vue-cli-plugin-uni/util/stringify.js
0 → 100644
浏览文件 @
ed8fe0ac
const
path
=
require
(
'
path
'
)
const
formatErrors
=
require
(
'
./format-errors
'
)
module
.
exports
=
function
stringify
(
errors
)
{
return
(
Array
.
from
(
new
Set
(
errors
.
map
(
err
=>
{
const
formatError
=
formatErrors
[
err
.
name
]
if
(
formatError
)
{
const
result
=
formatError
(
err
)
if
(
result
)
{
if
(
typeof
result
===
'
string
'
)
{
return
result
}
else
{
const
file
=
path
.
relative
(
process
.
env
.
UNI_INPUT_DIR
,
err
.
module
.
resource
).
split
(
'
?
'
)[
0
]
if
(
file
===
'
pages.json
'
)
{
result
.
line
=
1
}
return
`
${
result
.
message
}
at
${
file
}
:
${
result
.
line
||
1
}
`
}
}
else
if
(
result
===
false
)
{
return
''
// skip
}
}
return
err
.
message
})
)
)
.
filter
(
msg
=>
!!
msg
)
.
join
(
'
\n
'
))
}
src/platforms/app-plus/service/api/network/socket.js
浏览文件 @
ed8fe0ac
import
{
unpack
,
publish
,
requireNativePlugin
requireNativePlugin
,
base64ToArrayBuffer
,
arrayBufferToBase64
}
from
'
../../bridge
'
let
socketTaskId
=
0
const
socketTasks
=
{}
const
publishStateChange
=
(
res
)
=>
{
publish
(
'
onSocketTaskStateChange
'
,
res
)
}
const
createSocketTaskById
=
function
(
socketTaskId
,
{
url
,
data
,
header
,
method
,
protocols
}
=
{})
{
// fixed by hxy 需要测试是否支持 arraybuffer
const
socket
=
requireNativePlugin
(
'
webSocket
'
)
socket
.
WebSocket
(
url
,
Array
.
isArray
(
protocols
)
?
protocols
.
join
(
'
,
'
)
:
protocols
)
// socket.binaryType = 'arraybuffer'
socketTasks
[
socketTaskId
]
=
socket
let
socket
function
getSocket
()
{
if
(
socket
)
{
return
socket
}
socket
=
requireNativePlugin
(
'
uni-webSocket
'
)
socket
.
onopen
(
function
(
e
)
{
publishStateChange
({
socketTaskId
,
socketTaskId
:
e
.
id
,
state
:
'
open
'
})
})
socket
.
onmessage
(
function
(
e
)
{
const
data
=
e
.
data
publishStateChange
({
socketTaskId
,
socketTaskId
:
e
.
id
,
state
:
'
message
'
,
data
:
e
.
data
data
:
typeof
data
===
'
object
'
?
base64ToArrayBuffer
(
data
.
base64
)
:
data
})
})
socket
.
onerror
(
function
(
e
)
{
publishStateChange
({
socketTaskId
,
socketTaskId
:
e
.
id
,
state
:
'
error
'
,
errMsg
:
e
.
message
errMsg
:
e
.
data
})
})
socket
.
onclose
(
function
(
e
)
{
const
socketTaskId
=
e
.
id
delete
socketTasks
[
socketTaskId
]
publishStateChange
({
socketTaskId
,
state
:
'
close
'
})
})
return
socket
}
const
createSocketTaskById
=
function
(
socketTaskId
,
{
url
,
data
,
header
,
method
,
protocols
}
=
{})
{
const
socket
=
getSocket
()
socket
.
WebSocket
({
id
:
socketTaskId
,
url
,
protocol
:
Array
.
isArray
(
protocols
)
?
protocols
.
join
(
'
,
'
)
:
protocols
})
socketTasks
[
socketTaskId
]
=
socket
return
{
socketTaskId
,
errMsg
:
'
createSocketTask:ok
'
...
...
@@ -58,13 +71,14 @@ const createSocketTaskById = function (socketTaskId, {
}
export
function
createSocketTask
(
args
)
{
return
createSocketTaskById
(
++
socketTaskId
,
args
)
return
createSocketTaskById
(
String
(
Date
.
now
())
,
args
)
}
export
function
operateSocketTask
(
args
)
{
const
{
operationType
,
code
,
reason
,
data
,
socketTaskId
}
=
unpack
(
args
)
...
...
@@ -77,13 +91,23 @@ export function operateSocketTask (args) {
switch
(
operationType
)
{
case
'
send
'
:
if
(
data
)
{
socket
.
send
(
data
)
socket
.
send
({
id
:
socketTaskId
,
data
:
typeof
data
===
'
object
'
?
{
'
@type
'
:
'
binary
'
,
base64
:
arrayBufferToBase64
(
data
)
}
:
data
})
}
return
{
errMsg
:
'
operateSocketTask:ok
'
}
case
'
close
'
:
socket
.
close
(
code
)
socket
.
close
({
id
:
socketTaskId
,
code
,
reason
})
delete
socketTasks
[
socketTaskId
]
return
{
errMsg
:
'
operateSocketTask:ok
'
...
...
@@ -92,4 +116,4 @@ export function operateSocketTask (args) {
return
{
errMsg
:
'
operateSocketTask:fail
'
}
}
}
src/platforms/app-plus/service/bridge.js
浏览文件 @
ed8fe0ac
import
{
decode
decode
,
encode
}
from
'
base64-arraybuffer
'
export
{
...
...
@@ -56,7 +57,7 @@ export function isTabBarPage (path = '') {
return
false
}
return
page
.
$page
.
meta
.
isTabBar
}
}
const
route
=
__uniRoutes
.
find
(
route
=>
route
.
path
.
slice
(
1
)
===
path
)
return
route
&&
route
.
meta
.
isTabBar
}
catch
(
e
)
{
...
...
@@ -70,3 +71,7 @@ export function isTabBarPage (path = '') {
export
function
base64ToArrayBuffer
(
data
)
{
return
decode
(
data
)
}
export
function
arrayBufferToBase64
(
data
)
{
return
encode
(
data
)
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录