Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
一把秋刀鱼
uni-app
提交
6288bb20
U
uni-app
项目概览
一把秋刀鱼
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
4
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,发现更多精彩内容 >>
提交
6288bb20
编写于
12月 12, 2019
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(v3): uni-migration :host
上级
e967ae6a
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
23 addition
and
15 deletion
+23
-15
packages/uni-migration/__tests__/demo.js
packages/uni-migration/__tests__/demo.js
+1
-1
packages/uni-migration/__tests__/wxml.spec.js
packages/uni-migration/__tests__/wxml.spec.js
+4
-0
packages/uni-migration/lib/mp-weixin/transform/file-transformer.js
...uni-migration/lib/mp-weixin/transform/file-transformer.js
+11
-1
packages/uni-migration/lib/mp-weixin/transform/script-transformer.js
...i-migration/lib/mp-weixin/transform/script-transformer.js
+1
-11
packages/uni-migration/lib/mp-weixin/transform/style-transformer.js
...ni-migration/lib/mp-weixin/transform/style-transformer.js
+1
-0
packages/uni-migration/lib/mp-weixin/transform/template-transformer/transform/generate.js
...ixin/transform/template-transformer/transform/generate.js
+4
-1
packages/uni-migration/lib/mp-weixin/transform/template-transformer/transform/traverse.js
...ixin/transform/template-transformer/transform/traverse.js
+1
-1
未找到文件。
packages/uni-migration/__tests__/demo.js
浏览文件 @
6288bb20
...
...
@@ -13,7 +13,7 @@ migrate('/Users/fxy/Downloads/wa-vantui_1.1')
// transformTemplate
// } = require('../lib/mp-weixin/transform/template-transformer')
// console.log(transformTemplate(
// `<
uni-transition bind:click="click" bindtouchstart="startDrag" catchtouchmove="{{ catchMove ? 'noop' : ''
}}"/>`, {
// `<
view wx:for="{{ columns }}" wx:for-item="item" wx:key="{{item.value
}}"/>`, {
// filename: 'index'
// }
// ))
packages/uni-migration/__tests__/wxml.spec.js
浏览文件 @
6288bb20
...
...
@@ -40,6 +40,10 @@ describe('wxml:compiler', () => {
assertCodegen
(
'
<view wx:for="{{ columns }}" wx:for-item="index" wx:key="*this"/>
'
,
`<uni-shadow-root><view v-for="(index,___i___) in (columns)" :key="index"></view></uni-shadow-root>`
)
assertCodegen
(
'
<view wx:for="{{ columns }}" wx:for-item="item" wx:key="{{item.value}}"/>
'
,
`<uni-shadow-root><view v-for="(item,index) in (columns)" :key="item.value"></view></uni-shadow-root>`
)
})
it
(
'
generate root element
'
,
()
=>
{
...
...
packages/uni-migration/lib/mp-weixin/transform/file-transformer.js
浏览文件 @
6288bb20
...
...
@@ -13,6 +13,10 @@ const {
transformScriptFile
}
=
require
(
'
./script-transformer
'
)
const
{
normalizePath
}
=
require
(
'
../../util
'
)
const
pkg
=
require
(
'
../../../package.json
'
)
module
.
exports
=
function
transformFile
(
input
,
options
)
{
...
...
@@ -32,6 +36,12 @@ module.exports = function transformFile(input, options) {
options
.
isComponent
=
isComponent
options
.
filepath
=
filepath
options
.
filename
=
path
.
basename
(
filepath
)
if
(
options
.
base
)
{
options
.
route
=
normalizePath
(
path
.
relative
(
options
.
base
,
filepath
))
}
else
{
options
.
route
=
options
.
filename
}
options
.
shadowRootHost
=
options
.
route
.
replace
(
/
\/
/g
,
'
-
'
)
const
[
templateCode
,
wxsCode
=
''
,
wxsFiles
=
[]]
=
transformTemplateFile
(
filepath
+
templateExtname
,
options
)
...
...
@@ -39,7 +49,7 @@ module.exports = function transformFile(input, options) {
const
scriptCode
=
transformScriptFile
(
filepath
+
'
.js
'
,
jsCode
,
options
,
deps
)
return
[
`<!-- @dcloudio/uni-migration@
${
pkg
.
version
}
-->
`<!-- @dcloudio/uni-migration@
${
pkg
.
version
}
-->
<!--
${
new
Date
().
toLocaleString
()}
-->
<template>
${
templateCode
}
...
...
packages/uni-migration/lib/mp-weixin/transform/script-transformer.js
浏览文件 @
6288bb20
const
fs
=
require
(
'
fs
'
)
const
path
=
require
(
'
path
'
)
const
{
normalizePath
}
=
require
(
'
../../util
'
)
function
transformScript
(
content
,
route
,
code
)
{
return
`
${
code
}
...
...
@@ -24,11 +19,6 @@ Component({})
content
=
fs
.
readFileSync
(
filepath
,
'
utf8
'
).
toString
().
trim
()
deps
.
push
(
filepath
)
}
let
route
=
normalizePath
(
filepath
)
if
(
options
.
base
)
{
route
=
normalizePath
(
path
.
relative
(
options
.
base
,
filepath
))
}
route
=
route
.
replace
(
'
.js
'
,
''
)
return
transformScript
(
content
,
route
,
code
,
options
)
return
transformScript
(
content
,
options
.
route
,
code
,
options
)
}
}
packages/uni-migration/lib/mp-weixin/transform/style-transformer.js
浏览文件 @
6288bb20
...
...
@@ -2,6 +2,7 @@ const fs = require('fs')
function
transformStyle
(
content
,
options
)
{
return
content
.
replace
(
new
RegExp
(
`\
\$
{options.extname.style}`
,
'
g
'
),
'
.css
'
)
.
replace
(
'
:host
'
,
'
.
'
+
options
.
shadowRootHost
)
}
module
.
exports
=
{
...
...
packages/uni-migration/lib/mp-weixin/transform/template-transformer/transform/generate.js
浏览文件 @
6288bb20
...
...
@@ -58,5 +58,8 @@ function genWxs(wxs, state) {
}
module
.
exports
=
function
generate
(
node
,
state
)
{
return
[
`<uni-shadow-root>
${
genChildren
(
node
).
trim
()}
</uni-shadow-root>`
,
...
genWxs
(
state
.
wxs
,
state
)]
return
[
`<uni-shadow-root class="
${
state
.
shadowRootHost
}
">
${
genChildren
(
node
).
trim
()}
</uni-shadow-root>`
,
...
genWxs
(
state
.
wxs
,
state
)
]
}
packages/uni-migration/lib/mp-weixin/transform/template-transformer/transform/traverse.js
浏览文件 @
6288bb20
...
...
@@ -127,7 +127,7 @@ function transformFor(attribs) {
if
(
vKey
)
{
if
(
vKey
===
'
*this
'
)
{
vKey
=
vItem
}
else
if
(
vKey
!==
vItem
)
{
}
else
if
(
vKey
!==
vItem
&&
vKey
.
indexOf
(
'
.
'
)
===-
1
)
{
// wx:for-key="{{item.value}}"
vKey
=
vItem
+
'
.
'
+
vKey
}
attribs
[
'
:key
'
]
=
vKey
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录