Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Velpro187
uni-app
提交
f3901790
U
uni-app
项目概览
Velpro187
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
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,发现更多精彩内容 >>
提交
f3901790
编写于
11月 10, 2021
作者:
雪洛
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: page-meta-head
上级
3ab5bf88
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
26 addition
and
7 deletion
+26
-7
packages/uni-cli-shared/src/vue/transforms/transformPageHead.ts
...es/uni-cli-shared/src/vue/transforms/transformPageHead.ts
+2
-2
packages/uni-components/lib/page-meta-head/page-meta-head.vue
...ages/uni-components/lib/page-meta-head/page-meta-head.vue
+1
-1
packages/uni-h5-vite/lib/ssr/entry-server.js
packages/uni-h5-vite/lib/ssr/entry-server.js
+2
-2
packages/uni-h5-vite/src/plugin/index.ts
packages/uni-h5-vite/src/plugin/index.ts
+6
-1
packages/uni-h5-vite/src/plugin/transforms/transformPageHead.ts
...es/uni-h5-vite/src/plugin/transforms/transformPageHead.ts
+10
-0
packages/uni-shared/src/tags.ts
packages/uni-shared/src/tags.ts
+5
-1
未找到文件。
packages/uni-cli-shared/src/vue/transforms/transformPageHead.ts
浏览文件 @
f3901790
...
...
@@ -2,8 +2,8 @@ import { NodeTransform } from '@vue/compiler-core'
import
{
checkElementNodeTag
}
from
'
../../utils
'
export
const
transformPageHead
:
NodeTransform
=
(
node
,
context
)
=>
{
// 发现是page-meta下的
page-meta-
head,直接remove该节点
checkElementNodeTag
(
node
,
'
page-meta-
head
'
)
&&
// 发现是page-meta下的head,直接remove该节点
checkElementNodeTag
(
node
,
'
head
'
)
&&
checkElementNodeTag
(
context
.
parent
,
'
page-meta
'
)
&&
context
.
removeNode
(
node
)
}
packages/uni-components/lib/page-meta-head/page-meta-head.vue
浏览文件 @
f3901790
<
template
>
<teleport
to=
"
__head__
"
>
<teleport
to=
"
head
"
>
<slot
/>
</teleport>
</
template
>
...
...
packages/uni-h5-vite/lib/ssr/entry-server.js
浏览文件 @
f3901790
...
...
@@ -84,10 +84,10 @@ function renderAppContext(ctx) {
}
function
renderHeadMeta
(
ctx
)
{
if
(
!
ctx
.
__teleportBuffers
||
!
ctx
.
__teleportBuffers
.
__head__
)
{
if
(
!
ctx
.
__teleportBuffers
||
!
ctx
.
__teleportBuffers
.
head
)
{
return
''
}
return
ctx
.
__teleportBuffers
.
__head__
return
ctx
.
__teleportBuffers
.
head
.
map
((
buffer
)
=>
buffer
.
toString
())
.
join
(
'
\n
'
)
}
packages/uni-h5-vite/src/plugin/index.ts
浏览文件 @
f3901790
...
...
@@ -10,6 +10,7 @@ import {
}
from
'
@dcloudio/uni-cli-shared
'
import
{
createHandleHotUpdate
}
from
'
./handleHotUpdate
'
import
{
createTransformIndexHtml
}
from
'
./transformIndexHtml
'
import
{
transformPageHead
}
from
'
./transforms/transformPageHead
'
import
{
createDefine
}
from
'
../utils/features
'
import
{
isSsr
}
from
'
../utils
'
import
{
esbuildPrePlugin
}
from
'
./esbuild/esbuildPrePlugin
'
...
...
@@ -25,7 +26,11 @@ export const UniH5Plugin: UniVitePlugin = {
compilerOptions
:
{
isNativeTag
:
isH5NativeTag
,
isCustomElement
:
isH5CustomElement
,
nodeTransforms
:
[
transformTapToClick
,
transformMatchMedia
],
nodeTransforms
:
[
transformTapToClick
,
transformMatchMedia
,
transformPageHead
,
],
},
},
config
(
config
,
env
)
{
...
...
packages/uni-h5-vite/src/plugin/transforms/transformPageHead.ts
0 → 100644
浏览文件 @
f3901790
import
{
NodeTransform
,
ElementNode
,
ElementTypes
}
from
'
@vue/compiler-core
'
import
{
checkElementNodeTag
}
from
'
@dcloudio/uni-cli-shared
'
export
const
transformPageHead
:
NodeTransform
=
(
node
,
context
)
=>
{
// 发现是page-meta下的head,替换为page-meta-head
checkElementNodeTag
(
node
,
'
head
'
)
&&
checkElementNodeTag
(
context
.
parent
,
'
page-meta
'
)
&&
(((
node
as
ElementNode
).
tag
=
'
page-meta-head
'
),
((
node
as
ElementNode
).
tagType
=
ElementTypes
.
COMPONENT
))
}
packages/uni-shared/src/tags.ts
浏览文件 @
f3901790
...
...
@@ -76,7 +76,11 @@ export function isH5CustomElement(tag: string) {
}
export
function
isH5NativeTag
(
tag
:
string
)
{
return
(
isHTMLTag
(
tag
)
||
isSVGTag
(
tag
))
&&
!
isBuiltInComponent
(
tag
)
return
(
tag
!==
'
head
'
&&
(
isHTMLTag
(
tag
)
||
isSVGTag
(
tag
))
&&
!
isBuiltInComponent
(
tag
)
)
}
export
function
isNativeTag
(
tag
:
string
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录