Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
touchx
uni-app
提交
25c5d70a
U
uni-app
项目概览
touchx
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
25c5d70a
编写于
12月 22, 2022
作者:
Q
qiang
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'dev' into alpha
上级
029a07aa
e141fd37
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
107 addition
and
96 deletion
+107
-96
packages/uni-cli-shared/lib/index.js
packages/uni-cli-shared/lib/index.js
+5
-1
packages/uni-cli-shared/lib/util.js
packages/uni-cli-shared/lib/util.js
+23
-1
packages/uni-stat/dist/uni-cloud-stat.cjs.js
packages/uni-stat/dist/uni-cloud-stat.cjs.js
+5
-3
packages/uni-stat/dist/uni-cloud-stat.es.js
packages/uni-stat/dist/uni-cloud-stat.es.js
+5
-3
packages/uni-stat/dist/uni-stat.cjs.js
packages/uni-stat/dist/uni-stat.cjs.js
+5
-3
packages/uni-stat/dist/uni-stat.es.js
packages/uni-stat/dist/uni-stat.es.js
+5
-3
packages/vue-cli-plugin-uni/lib/mp/index.js
packages/vue-cli-plugin-uni/lib/mp/index.js
+47
-46
packages/webpack-uni-mp-loader/lib/plugin/index-new.js
packages/webpack-uni-mp-loader/lib/plugin/index-new.js
+3
-2
packages/webpack-uni-mp-loader/lib/shared.js
packages/webpack-uni-mp-loader/lib/shared.js
+3
-20
packages/webpack-uni-pages-loader/lib/platforms/mp.js
packages/webpack-uni-pages-loader/lib/platforms/mp.js
+6
-14
未找到文件。
packages/uni-cli-shared/lib/index.js
浏览文件 @
25c5d70a
...
...
@@ -32,7 +32,9 @@ const {
normalizePath
,
getComponentName
,
convertStaticStyle
,
getTemplatePath
getTemplatePath
,
createSource
,
deleteAsset
}
=
require
(
'
./util
'
)
const
{
...
...
@@ -108,6 +110,8 @@ module.exports = {
getComponentName
,
convertStaticStyle
,
getTemplatePath
,
createSource
,
deleteAsset
,
jsPreprocessOptions
,
cssPreprocessOptions
,
htmlPreprocessOptions
,
...
...
packages/uni-cli-shared/lib/util.js
浏览文件 @
25c5d70a
...
...
@@ -4,6 +4,7 @@ const hash = require('hash-sum')
const
crypto
=
require
(
'
crypto
'
)
const
escapeStringRegexp
=
require
(
'
escape-string-regexp
'
)
const
escapeGlob
=
require
(
'
glob-escape
'
)
const
webpack
=
require
(
'
webpack
'
)
const
isWin
=
/^win/
.
test
(
process
.
platform
)
...
...
@@ -159,6 +160,25 @@ function isNormalPage (pagePath) {
return
!
pagePath
.
startsWith
(
'
ext://
'
)
}
function
createSource
(
content
)
{
return
webpack
.
version
[
0
]
>
4
?
new
webpack
.
sources
.
RawSource
(
content
)
:
{
size
()
{
return
Buffer
.
byteLength
(
content
,
'
utf8
'
)
},
source
()
{
return
content
}
}
}
function
deleteAsset
(
compilation
,
name
)
{
if
(
'
deleteAsset
'
in
compilation
)
{
compilation
.
deleteAsset
(
name
)
}
else
{
delete
compilation
.
assets
[
name
]
}
}
module
.
exports
=
{
isNormalPage
,
isInHBuilderX
,
...
...
@@ -198,5 +218,7 @@ module.exports = {
}),
getTemplatePath
()
{
return
path
.
join
(
__dirname
,
'
../template
'
)
}
},
createSource
,
deleteAsset
}
packages/uni-stat/dist/uni-cloud-stat.cjs.js
浏览文件 @
25c5d70a
...
...
@@ -698,7 +698,9 @@ const FIRST_TIME = '__first_time';
* 设置页面首次访问时间,用户获取页面/应用停留时常
*/
const
set_first_time
=
()
=>
{
const
time
=
new
Date
().
getTime
();
// 获取当前时间 ,以下代码获取到是毫秒级时间戳 ,实际上用到是秒级时间戳,所以需要除以1000
// const time = new Date().getTime()
let
time
=
get_time
();
const
timeStorge
=
dbSet
(
FIRST_TIME
,
time
);
return
timeStorge
};
...
...
@@ -722,8 +724,8 @@ const get_residence_time = (type) => {
if
(
first_time
!==
0
)
{
residenceTime
=
last_time
-
first_time
;
}
residenceTime
=
parseInt
(
residenceTime
/
1000
);
// 将毫秒级时间戳转换为秒级时间戳,因为直接获取的是秒级时间戳,所以不需要转换
// residenceTime = parseInt(residenceTime / 1000)
residenceTime
=
residenceTime
<
1
?
1
:
residenceTime
;
if
(
type
===
'
app
'
)
{
let
overtime
=
residenceTime
>
APP_PVER_TIME
?
true
:
false
;
...
...
packages/uni-stat/dist/uni-cloud-stat.es.js
浏览文件 @
25c5d70a
...
...
@@ -696,7 +696,9 @@ const FIRST_TIME = '__first_time';
* 设置页面首次访问时间,用户获取页面/应用停留时常
*/
const
set_first_time
=
()
=>
{
const
time
=
new
Date
().
getTime
();
// 获取当前时间 ,以下代码获取到是毫秒级时间戳 ,实际上用到是秒级时间戳,所以需要除以1000
// const time = new Date().getTime()
let
time
=
get_time
();
const
timeStorge
=
dbSet
(
FIRST_TIME
,
time
);
return
timeStorge
};
...
...
@@ -720,8 +722,8 @@ const get_residence_time = (type) => {
if
(
first_time
!==
0
)
{
residenceTime
=
last_time
-
first_time
;
}
residenceTime
=
parseInt
(
residenceTime
/
1000
);
// 将毫秒级时间戳转换为秒级时间戳,因为直接获取的是秒级时间戳,所以不需要转换
// residenceTime = parseInt(residenceTime / 1000)
residenceTime
=
residenceTime
<
1
?
1
:
residenceTime
;
if
(
type
===
'
app
'
)
{
let
overtime
=
residenceTime
>
APP_PVER_TIME
?
true
:
false
;
...
...
packages/uni-stat/dist/uni-stat.cjs.js
浏览文件 @
25c5d70a
...
...
@@ -666,7 +666,9 @@ const FIRST_TIME = '__first_time';
* 设置页面首次访问时间,用户获取页面/应用停留时常
*/
const
set_first_time
=
()
=>
{
const
time
=
new
Date
().
getTime
();
// 获取当前时间 ,以下代码获取到是毫秒级时间戳 ,实际上用到是秒级时间戳,所以需要除以1000
// const time = new Date().getTime()
let
time
=
get_time
();
const
timeStorge
=
dbSet
(
FIRST_TIME
,
time
);
return
timeStorge
};
...
...
@@ -690,8 +692,8 @@ const get_residence_time = (type) => {
if
(
first_time
!==
0
)
{
residenceTime
=
last_time
-
first_time
;
}
residenceTime
=
parseInt
(
residenceTime
/
1000
);
// 将毫秒级时间戳转换为秒级时间戳,因为直接获取的是秒级时间戳,所以不需要转换
// residenceTime = parseInt(residenceTime / 1000)
residenceTime
=
residenceTime
<
1
?
1
:
residenceTime
;
if
(
type
===
'
app
'
)
{
let
overtime
=
residenceTime
>
APP_PVER_TIME
?
true
:
false
;
...
...
packages/uni-stat/dist/uni-stat.es.js
浏览文件 @
25c5d70a
...
...
@@ -664,7 +664,9 @@ const FIRST_TIME = '__first_time';
* 设置页面首次访问时间,用户获取页面/应用停留时常
*/
const
set_first_time
=
()
=>
{
const
time
=
new
Date
().
getTime
();
// 获取当前时间 ,以下代码获取到是毫秒级时间戳 ,实际上用到是秒级时间戳,所以需要除以1000
// const time = new Date().getTime()
let
time
=
get_time
();
const
timeStorge
=
dbSet
(
FIRST_TIME
,
time
);
return
timeStorge
};
...
...
@@ -688,8 +690,8 @@ const get_residence_time = (type) => {
if
(
first_time
!==
0
)
{
residenceTime
=
last_time
-
first_time
;
}
residenceTime
=
parseInt
(
residenceTime
/
1000
);
// 将毫秒级时间戳转换为秒级时间戳,因为直接获取的是秒级时间戳,所以不需要转换
// residenceTime = parseInt(residenceTime / 1000)
residenceTime
=
residenceTime
<
1
?
1
:
residenceTime
;
if
(
type
===
'
app
'
)
{
let
overtime
=
residenceTime
>
APP_PVER_TIME
?
true
:
false
;
...
...
packages/vue-cli-plugin-uni/lib/mp/index.js
浏览文件 @
25c5d70a
...
...
@@ -9,7 +9,9 @@ const {
getPlatformCssnano
,
getPlatformStat
,
getPlatformPush
,
getPlatformUniCloud
getPlatformUniCloud
,
createSource
,
deleteAsset
}
=
require
(
'
@dcloudio/uni-cli-shared
'
)
const
WebpackUniAppPlugin
=
require
(
'
../../packages/webpack-uni-app-loader/plugin/index
'
)
...
...
@@ -26,7 +28,7 @@ function createUniMPPlugin () {
}
const
createWxMpIndependentPlugins
=
require
(
'
@dcloudio/uni-mp-weixin/lib/createIndependentPlugin
'
)
const
UniTips
=
require
(
'
./tips
'
)
function
getProvides
()
{
...
...
@@ -77,62 +79,61 @@ function getProvides () {
return
provides
}
function
processWxss
(
name
,
assets
)
{
function
processWxss
(
compilation
,
name
,
assets
)
{
const
dirname
=
path
.
dirname
(
name
)
const
mainWxssCode
=
`@import "
${
normalizePath
(
path
.
relative
(
dirname
,
'
common/main.wxss
'
))}
";`
const
code
=
`
${
mainWxssCode
}
`
+
assets
[
name
].
source
().
toString
()
assets
[
name
]
=
{
size
()
{
return
Buffer
.
byteLength
(
code
,
'
utf8
'
)
},
source
()
{
return
code
}
}
compilation
.
updateAsset
(
name
,
createSource
(
code
))
}
const
parseRequirePath
=
path
=>
path
.
startsWith
(
'
common
'
)
?
`./
${
path
}
`
:
path
function
procssJs
(
name
,
assets
,
hasVendor
)
{
function
procssJs
(
compilation
,
name
,
assets
,
hasVendor
)
{
const
dirname
=
path
.
dirname
(
name
)
const
runtimeJsCode
=
`require('
${
normalizePath
(
parseRequirePath
(
path
.
relative
(
dirname
,
'
common/runtime.js
'
)))}
');`
const
vendorJsCode
=
hasVendor
?
`require('
${
normalizePath
(
parseRequirePath
(
path
.
relative
(
dirname
,
'
common/vendor.js
'
)))}
');`
:
''
const
mainJsCode
=
`require('
${
normalizePath
(
parseRequirePath
(
path
.
relative
(
dirname
,
'
common/main.js
'
)))}
');`
const
code
=
`
${
runtimeJsCode
}${
vendorJsCode
}${
mainJsCode
}
`
+
assets
[
name
].
source
().
toString
()
assets
[
name
]
=
{
size
()
{
return
Buffer
.
byteLength
(
code
,
'
utf8
'
)
},
source
()
{
return
code
compilation
.
updateAsset
(
name
,
createSource
(
code
))
}
function
processAssets
(
compilation
)
{
const
assets
=
compilation
.
assets
const
hasMainWxss
=
assets
[
'
common/main.wxss
'
]
const
hasVendor
=
assets
[
'
common/vendor.js
'
]
Object
.
keys
(
assets
).
forEach
(
name
=>
{
if
(
name
.
startsWith
(
'
common
'
))
{
return
}
}
const
extname
=
path
.
extname
(
name
)
if
(
extname
===
'
.wxss
'
&&
hasMainWxss
&&
process
.
UNI_ENTRY
[
name
.
replace
(
extname
,
''
)])
{
processWxss
(
compilation
,
name
,
assets
)
}
else
if
(
extname
===
'
.js
'
)
{
procssJs
(
compilation
,
name
,
assets
,
hasVendor
)
}
})
// delete assets['common/main.js']
deleteAsset
(
compilation
,
'
app.js
'
)
deleteAsset
(
compilation
,
'
app.json
'
)
deleteAsset
(
compilation
,
'
app.wxss
'
)
deleteAsset
(
compilation
,
'
project.config.json
'
)
}
class
PreprocessAssetsPlugin
{
apply
(
compiler
)
{
compiler
.
hooks
.
emit
.
tap
(
'
PreprocessAssetsPlugin
'
,
compilation
=>
{
const
assets
=
compilation
.
assets
const
hasMainWxss
=
assets
[
'
common/main.wxss
'
]
const
hasVendor
=
assets
[
'
common/vendor.js
'
]
Object
.
keys
(
assets
).
forEach
(
name
=>
{
if
(
name
.
startsWith
(
'
common
'
))
{
return
}
const
extname
=
path
.
extname
(
name
)
if
(
extname
===
'
.wxss
'
&&
hasMainWxss
&&
process
.
UNI_ENTRY
[
name
.
replace
(
extname
,
''
)])
{
processWxss
(
name
,
assets
)
}
else
if
(
extname
===
'
.js
'
)
{
procssJs
(
name
,
assets
,
hasVendor
)
}
if
(
webpack
.
version
[
0
]
>
4
)
{
compiler
.
hooks
.
compilation
.
tap
(
'
PreprocessAssetsPlugin
'
,
compilation
=>
{
compilation
.
hooks
.
processAssets
.
tap
({
name
:
'
PreprocessAssetsPlugin
'
,
stage
:
webpack
.
Compilation
.
PROCESS_ASSETS_STAGE_ADDITIONAL
},
(
_
)
=>
{
processAssets
(
compilation
)
})
})
// delete assets['common/main.js']
delete
assets
[
'
app.js
'
]
delete
assets
[
'
app.json
'
]
delete
assets
[
'
app.wxss
'
]
delete
assets
[
'
project.config.json
'
]
})
}
else
{
compiler
.
hooks
.
emit
.
tap
(
'
PreprocessAssetsPlugin
'
,
(
compilation
)
=>
processAssets
(
compilation
))
}
}
}
...
...
@@ -143,7 +144,7 @@ function initSubpackageConfig (webpackConfig, vueOptions) {
}
vueOptions
.
outputDir
=
process
.
env
.
UNI_OUTPUT_DIR
webpackConfig
.
output
.
path
(
process
.
env
.
UNI_OUTPUT_DIR
)
webpackConfig
.
output
.
jsonpFunction
(
'
webpackJsonp_
'
+
(
process
.
env
.
UNI_SUBPACKGE
||
process
.
env
.
UNI_MP_PLUGIN
))
webpackConfig
.
output
.
set
(
webpack
.
version
[
0
]
>
4
?
'
chunkLoadingGlobal
'
:
'
jsonpFunction
'
,
'
webpackJsonp_
'
+
(
process
.
env
.
UNI_SUBPACKGE
||
process
.
env
.
UNI_MP_PLUGIN
))
}
function
addToUniEntry
(
fileName
)
{
...
...
@@ -192,7 +193,7 @@ module.exports = {
if
((
process
.
env
.
UNI_SUBPACKGE
||
process
.
env
.
UNI_MP_PLUGIN
)
&&
process
.
env
.
UNI_SUBPACKGE
!==
'
main
'
)
{
plugins
.
push
(
new
PreprocessAssetsPlugin
())
}
}
{
const
globalEnv
=
process
.
env
.
UNI_PLATFORM
===
'
mp-alipay
'
?
'
my
'
:
'
wx
'
;
...
...
@@ -230,11 +231,11 @@ ${globalEnv}.__webpack_require_UNI_MP_PLUGIN__ = __webpack_require__;`
}
if
(
process
.
env
.
NODE_ENV
===
'
production
'
||
process
.
env
.
UNI_MINIMIZE
===
'
true
'
)
{
output
.
pathinfo
=
false
}
if
(
process
.
env
.
UNI_PLATFORM
===
'
mp-weixin
'
&&
process
.
env
.
NODE_ENV
===
'
production
'
)
{
plugins
.
push
(
new
UniTips
())
}
}
if
(
process
.
env
.
UNI_PLATFORM
===
'
mp-weixin
'
&&
process
.
env
.
NODE_ENV
===
'
production
'
)
{
plugins
.
push
(
new
UniTips
())
}
return
{
mode
:
process
.
env
.
NODE_ENV
===
'
production
'
?
'
production
'
:
'
development
'
,
...
...
packages/webpack-uni-mp-loader/lib/plugin/index-new.js
浏览文件 @
25c5d70a
...
...
@@ -10,7 +10,7 @@ const {
pagesJsonJsFileName
}
=
require
(
'
@dcloudio/uni-cli-shared/lib/pages
'
)
const
{
createSource
}
=
require
(
'
../shared
'
)
const
{
createSource
,
getModuleId
}
=
require
(
'
../shared
'
)
const
generateApp
=
require
(
'
./generate-app
'
)
const
generateJson
=
require
(
'
./generate-json
'
)
...
...
@@ -65,7 +65,8 @@ function addMPPluginRequire (compilation) {
const
orignalSource
=
compilation
.
getAsset
(
name
).
source
.
source
()
const
globalEnv
=
process
.
env
.
UNI_PLATFORM
===
'
mp-alipay
'
?
'
my
'
:
'
wx
'
const
filePath
=
normalizePath
(
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
name
))
const
uniModuleId
=
modules
.
find
(
module
=>
module
.
resource
&&
normalizePath
(
module
.
resource
)
===
filePath
).
id
const
uniModule
=
modules
.
find
(
module
=>
module
.
resource
&&
normalizePath
(
module
.
resource
)
===
filePath
)
const
uniModuleId
=
getModuleId
(
compilation
,
uniModule
)
const
source
=
orignalSource
+
`\nmodule.exports =
${
globalEnv
}
.__webpack_require_UNI_MP_PLUGIN__('
${
uniModuleId
}
');\n`
...
...
packages/webpack-uni-mp-loader/lib/shared.js
浏览文件 @
25c5d70a
...
...
@@ -2,7 +2,9 @@ const webpack = require('webpack')
const
{
removeExt
,
getPlatformExts
,
getPlatformTarget
getPlatformTarget
,
createSource
,
deleteAsset
}
=
require
(
'
@dcloudio/uni-cli-shared
'
)
const
{
...
...
@@ -40,25 +42,6 @@ function restoreNodeModules (str) {
return
str
}
function
createSource
(
content
)
{
return
webpack
.
version
[
0
]
>
4
?
new
webpack
.
sources
.
RawSource
(
content
)
:
{
size
()
{
return
Buffer
.
byteLength
(
content
,
'
utf8
'
)
},
source
()
{
return
content
}
}
}
function
deleteAsset
(
compilation
,
name
)
{
if
(
'
deleteAsset
'
in
compilation
)
{
compilation
.
deleteAsset
(
name
)
}
else
{
delete
compilation
.
assets
[
name
]
}
}
function
getIssuer
(
compilation
,
module
)
{
return
webpack
.
version
[
0
]
>
4
?
compilation
.
moduleGraph
.
getIssuer
(
module
)
:
module
.
issuer
}
...
...
packages/webpack-uni-pages-loader/lib/platforms/mp.js
浏览文件 @
25c5d70a
...
...
@@ -266,10 +266,14 @@ module.exports = function (pagesJson, manifestJson, project = {}) {
const
projectName
=
getPlatformProject
()
const
p
rojectPath
=
const
rootP
rojectPath
=
projectName
&&
path
.
resolve
(
process
.
env
.
VUE_CLI_CONTEXT
||
process
.
cwd
(),
projectName
)
const
srcProjectPath
=
projectName
&&
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
projectName
)
const
projectPath
=
rootProjectPath
&&
fs
.
existsSync
(
rootProjectPath
)
?
rootProjectPath
:
srcProjectPath
if
(
projectPath
&&
fs
.
existsSync
(
projectPath
))
{
// 自定义 project.config.json
const
platform
=
process
.
env
.
UNI_PLATFORM
...
...
@@ -290,18 +294,6 @@ module.exports = function (pagesJson, manifestJson, project = {}) {
})
}
if
(
process
.
env
.
UNI_PLATFORM
===
'
mp-weixin
'
||
process
.
env
.
UNI_PLATFORM
===
'
mp-qq
'
)
{
// 微信不需要生成,其他平台做拷贝
return
{
app
:
{
name
:
'
app
'
,
content
:
trimMPJson
(
app
)
}
}
}
return
{
app
:
{
name
:
'
app
'
,
...
...
@@ -331,7 +323,7 @@ module.exports = function (pagesJson, manifestJson, project = {}) {
Object
.
keys
(
platformJson
).
forEach
(
key
=>
{
if
(
!
projectKeys
.
includes
(
key
)
&&
[
'
usingComponents
'
,
'
optimization
'
].
indexOf
(
key
)
===
-
1
!
projectKeys
.
includes
(
key
)
&&
!
NON_APP_JSON_KEYS
.
includes
(
key
)
)
{
// usingComponents 是编译模式开关,需要过滤,不能拷贝到 app
app
[
key
]
=
platformJson
[
key
]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录