Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
57c54d96
U
uni-app
项目概览
DCloud
/
uni-app
通知
698
Star
38702
Fork
3641
代码
文件
提交
分支
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看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
57c54d96
编写于
2月 22, 2024
作者:
Y
yurj26
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(mp-weixin): styleIsolation兼容glass-easel框架 (question/178062)
上级
c1f58e38
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
27 addition
and
6 deletion
+27
-6
packages/uni-cli-shared/lib/cache.js
packages/uni-cli-shared/lib/cache.js
+25
-4
packages/webpack-uni-mp-loader/lib/script-new.js
packages/webpack-uni-mp-loader/lib/script-new.js
+2
-2
未找到文件。
packages/uni-cli-shared/lib/cache.js
浏览文件 @
57c54d96
...
...
@@ -153,7 +153,16 @@ function updateUsingAutoImportComponents (name, usingAutoImportComponents) {
}
}
function
updateUsingComponents
(
name
,
usingComponents
,
type
)
{
const
styleIsolationRE
=
/export
\s
+default
\s
+
[\s\S]
*
?
styleIsolation
\s
*:
\s
*
[
'|"
](
isolated|apply-shared|shared
)[
'|"
]
/
function
parseComponentStyleIsolation
(
content
)
{
const
matches
=
content
.
match
(
styleIsolationRE
)
if
(
matches
)
{
return
matches
[
1
]
}
}
function
updateUsingComponents
(
name
,
usingComponents
,
type
,
content
=
''
)
{
if
(
type
===
'
Component
'
)
{
componentSet
.
add
(
name
)
}
...
...
@@ -168,9 +177,21 @@ function updateUsingComponents (name, usingComponents, type) {
if
(
type
===
'
Component
'
)
{
jsonObj
.
component
=
true
if
(
process
.
env
.
UNI_PLATFORM
===
'
mp-alipay
'
)
{
const
manifestConfig
=
process
.
UNI_MANIFEST
const
alipayConfig
=
manifestConfig
[
'
mp-alipay
'
]
||
{}
jsonObj
.
styleIsolation
=
alipayConfig
.
styleIsolation
||
'
apply-shared
'
const
alipayConfig
=
process
.
UNI_MANIFEST
[
'
mp-alipay
'
]
||
{}
jsonObj
.
styleIsolation
=
parseComponentStyleIsolation
(
content
)
||
alipayConfig
.
styleIsolation
||
'
apply-shared
'
}
// 微信小程序json文件中的styleIsolation优先级比options中的高,为了兼容旧版本,不能设置默认值,并且只有在manifest.json中配置styleIsolation才会静态分析组件的styleIsolation
if
(
process
.
env
.
UNI_PLATFORM
===
'
mp-weixin
'
)
{
const
weixinConfig
=
process
.
UNI_MANIFEST
[
'
mp-weixin
'
]
||
{}
if
(
weixinConfig
.
styleIsolation
)
{
jsonObj
.
styleIsolation
=
parseComponentStyleIsolation
(
content
)
||
weixinConfig
.
styleIsolation
}
}
}
else
if
(
type
===
'
Page
'
)
{
if
(
process
.
env
.
UNI_PLATFORM
===
'
mp-baidu
'
)
{
...
...
packages/webpack-uni-mp-loader/lib/script-new.js
浏览文件 @
57c54d96
...
...
@@ -101,7 +101,7 @@ module.exports = function (content, map) {
return
}
// 防止组件从有到无,App.vue 中不支持使用组件
updateUsingComponents
(
resourcePath
,
Object
.
create
(
null
),
type
)
updateUsingComponents
(
resourcePath
,
Object
.
create
(
null
),
type
,
content
)
callback
(
null
,
content
,
map
)
return
}
...
...
@@ -148,7 +148,7 @@ module.exports = function (content, map) {
}
addDynamicImport
(
babelLoader
,
resourcePath
,
dynamicImports
)
updateUsingComponents
(
resourcePath
,
usingComponents
,
type
)
updateUsingComponents
(
resourcePath
,
usingComponents
,
type
,
content
)
callback
(
null
,
content
,
map
)
}
},
err
=>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录