Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
yangkaifeng
uni-app
提交
5a711a24
U
uni-app
项目概览
yangkaifeng
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
3
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
5a711a24
编写于
7月 13, 2021
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(app): TextNode
上级
1c13206d
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
177 addition
and
14 deletion
+177
-14
packages/uni-app-plus/dist/uni-app-view.umd.js
packages/uni-app-plus/dist/uni-app-view.umd.js
+2
-1
packages/uni-app-plus/src/view/framework/dom/elements/UniTextNode.ts
...i-app-plus/src/view/framework/dom/elements/UniTextNode.ts
+7
-1
packages/uni-cli-shared/src/constants.ts
packages/uni-cli-shared/src/constants.ts
+7
-2
packages/uni-cli-shared/src/hbx/console.ts
packages/uni-cli-shared/src/hbx/console.ts
+95
-0
packages/uni-cli-shared/src/hbx/index.ts
packages/uni-cli-shared/src/hbx/index.ts
+0
-0
packages/uni-cli-shared/src/json/app/pages/definePage.ts
packages/uni-cli-shared/src/json/app/pages/definePage.ts
+8
-5
packages/uni-cli-shared/src/utils.ts
packages/uni-cli-shared/src/utils.ts
+16
-0
packages/uni-cli-shared/src/vite/plugins/console.ts
packages/uni-cli-shared/src/vite/plugins/console.ts
+23
-0
packages/uni-h5-vite/dist/plugins/pagesJson.js
packages/uni-h5-vite/dist/plugins/pagesJson.js
+5
-1
packages/uni-h5-vite/src/plugins/pagesJson.ts
packages/uni-h5-vite/src/plugins/pagesJson.ts
+6
-1
packages/vite-plugin-uni/src/config/index.ts
packages/vite-plugin-uni/src/config/index.ts
+8
-1
packages/vite-plugin-uni/src/configResolved/index.ts
packages/vite-plugin-uni/src/configResolved/index.ts
+0
-2
未找到文件。
packages/uni-app-plus/dist/uni-app-view.umd.js
浏览文件 @
5a711a24
...
...
@@ -14179,8 +14179,9 @@
}
}
class
UniTextNode
extends
UniNode
{
constructor
(
id2
,
parentNodeId
)
{
constructor
(
id2
,
parentNodeId
,
nodeJson
)
{
super
(
id2
,
"
#text
"
,
parentNodeId
,
document
.
createTextNode
(
""
));
this
.
init
(
nodeJson
);
}
}
var
view
=
"
uni-view {
\n
display: block;
\n
}
\n
uni-view[hidden] {
\n
display: none;
\n
}
\n
"
;
...
...
packages/uni-app-plus/src/view/framework/dom/elements/UniTextNode.ts
浏览文件 @
5a711a24
import
{
UniNodeJSON
}
from
'
@dcloudio/uni-shared
'
import
{
UniNode
}
from
'
./UniNode
'
export
class
UniTextNode
extends
UniNode
{
constructor
(
id
:
number
,
parentNodeId
:
number
)
{
constructor
(
id
:
number
,
parentNodeId
:
number
,
nodeJson
:
Partial
<
UniNodeJSON
>
)
{
super
(
id
,
'
#text
'
,
parentNodeId
,
document
.
createTextNode
(
''
))
this
.
init
(
nodeJson
)
}
}
packages/uni-cli-shared/src/constants.ts
浏览文件 @
5a711a24
export
const
PUBLIC_DIR
=
'
static
'
export
const
EXTNAME_JS
=
[
'
.js
'
,
'
.ts
'
]
export
const
EXTNAME_VUE
=
[
'
.vue
'
,
'
.nvue
'
,
'
.fvue
'
]
export
const
EXTNAME_VUE_RE
=
/
\.(
vue|nvue|fvue
)
$/
export
const
EXTNAME_VUE
=
[
'
.vue
'
,
'
.nvue
'
]
export
const
EXTNAME_VUE_RE
=
/
\.(
vue|nvue
)
$/
// APP 平台解析页面后缀的优先级
export
const
PAGE_EXTNAME_APP
=
[
'
.nvue
'
,
'
.vue
'
]
// 其他平台解析页面后缀的优先级
export
const
PAGE_EXTNAME
=
[
'
.vue
'
,
'
.nvue
'
]
export
const
H5_API_STYLE_PATH
=
'
@dcloudio/uni-h5/style/api/
'
export
const
H5_FRAMEWORK_STYLE_PATH
=
'
@dcloudio/uni-h5/style/framework/
'
...
...
packages/uni-cli-shared/src/hbx/console.ts
0 → 100644
浏览文件 @
5a711a24
function
typof
(
v
:
unknown
)
{
var
s
=
Object
.
prototype
.
toString
.
call
(
v
)
return
s
.
substring
(
8
,
s
.
length
-
1
)
}
function
isDebugMode
()
{
// @ts-expect-error
return
typeof
__channelId__
===
'
string
'
&&
__channelId__
}
function
jsonStringifyReplacer
(
key
:
string
,
value
:
unknown
)
{
switch
(
typof
(
value
))
{
case
'
Function
'
:
return
'
function() { [native code] }
'
default
:
return
value
}
}
type
LogType
=
'
log
'
|
'
info
'
|
'
warn
'
|
'
error
'
// export function log(type: LogType) {
// for (
// var _len = arguments.length,
// args = new Array(_len > 1 ? _len - 1 : 0),
// _key = 1;
// _key < _len;
// _key++
// ) {
// args[_key - 1] = arguments[_key]
// }
// console[type].apply(console, args)
// }
export
default
function
formatLog
()
{
for
(
var
_len
=
arguments
.
length
,
args
=
new
Array
(
_len
),
_key
=
0
;
_key
<
_len
;
_key
++
)
{
args
[
_key
]
=
arguments
[
_key
]
}
var
type
=
args
.
shift
()
as
LogType
if
(
isDebugMode
())
{
args
.
push
(
args
.
pop
().
replace
(
'
at
'
,
'
uni-app:///
'
))
return
console
[
type
].
apply
(
console
,
args
)
}
var
msgs
=
args
.
map
(
function
(
v
)
{
var
type
=
Object
.
prototype
.
toString
.
call
(
v
).
toLowerCase
()
if
(
type
===
'
[object object]
'
||
type
===
'
[object array]
'
)
{
try
{
v
=
'
---BEGIN:JSON---
'
+
JSON
.
stringify
(
v
,
jsonStringifyReplacer
)
+
'
---END:JSON---
'
}
catch
(
e
)
{
v
=
type
}
}
else
{
if
(
v
===
null
)
{
v
=
'
---NULL---
'
}
else
if
(
v
===
undefined
)
{
v
=
'
---UNDEFINED---
'
}
else
{
var
vType
=
typof
(
v
).
toUpperCase
()
if
(
vType
===
'
NUMBER
'
||
vType
===
'
BOOLEAN
'
)
{
v
=
'
---BEGIN:
'
+
vType
+
'
---
'
+
v
+
'
---END:
'
+
vType
+
'
---
'
}
else
{
v
=
String
(
v
)
}
}
}
return
v
})
var
msg
=
''
if
(
msgs
.
length
>
1
)
{
var
lastMsg
=
msgs
.
pop
()
msg
=
msgs
.
join
(
'
---COMMA---
'
)
if
(
lastMsg
.
indexOf
(
'
at
'
)
===
0
)
{
msg
+=
lastMsg
}
else
{
msg
+=
'
---COMMA---
'
+
lastMsg
}
}
else
{
msg
=
msgs
[
0
]
}
console
[
type
](
msg
)
}
packages/uni-cli-shared/src/hbx.ts
→
packages/uni-cli-shared/src/hbx
/index
.ts
浏览文件 @
5a711a24
文件已移动
packages/uni-cli-shared/src/json/app/pages/definePage.ts
浏览文件 @
5a711a24
import
{
normalizeIdentifier
}
from
'
../../../utils
'
import
{
normalizeIdentifier
,
normalizePagePath
}
from
'
../../../utils
'
export
function
definePageCode
(
pagesJson
:
Record
<
string
,
any
>
)
{
const
importPagesCode
:
string
[]
=
[]
...
...
@@ -6,10 +6,13 @@ export function definePageCode(pagesJson: Record<string, any>) {
pagesJson
.
pages
.
forEach
((
page
:
UniApp
.
UniRoute
)
=>
{
const
pagePath
=
page
.
path
const
pageIdentifier
=
normalizeIdentifier
(
pagePath
)
importPagesCode
.
push
(
`import
${
pageIdentifier
}
from './
${
pagePath
}
.vue?mpType=page'`
)
definePagesCode
.
push
(
`__definePage('
${
pagePath
}
',
${
pageIdentifier
}
)`
)
const
pagePathWithExtname
=
normalizePagePath
(
pagePath
,
'
app
'
)
if
(
pagePathWithExtname
)
{
importPagesCode
.
push
(
`import
${
pageIdentifier
}
from './
${
pagePathWithExtname
}
?mpType=page'`
)
definePagesCode
.
push
(
`__definePage('
${
pagePath
}
',
${
pageIdentifier
}
)`
)
}
})
return
importPagesCode
.
join
(
'
\n
'
)
+
'
\n
'
+
definePagesCode
.
join
(
'
\n
'
)
}
packages/uni-cli-shared/src/utils.ts
浏览文件 @
5a711a24
...
...
@@ -4,6 +4,7 @@ import path from 'path'
import
slash
from
'
slash
'
import
{
camelize
,
capitalize
}
from
'
@vue/shared
'
import
{
once
}
from
'
@dcloudio/uni-shared
'
import
{
PAGE_EXTNAME
,
PAGE_EXTNAME_APP
}
from
'
./constants
'
const
isWindows
=
os
.
platform
()
===
'
win32
'
export
function
normalizePath
(
id
:
string
):
string
{
return
path
.
posix
.
normalize
(
isWindows
?
slash
(
id
)
:
id
)
...
...
@@ -24,3 +25,18 @@ export function resolveBuiltIn(path: string) {
export
function
normalizeIdentifier
(
str
:
string
)
{
return
capitalize
(
camelize
(
str
.
replace
(
/
\/
/g
,
'
-
'
)))
}
export
function
normalizePagePath
(
pagePath
:
string
,
platform
:
UniApp
.
PLATFORM
)
{
const
absoltePagePath
=
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
pagePath
)
let
extnames
=
PAGE_EXTNAME
if
(
platform
===
'
app
'
)
{
extnames
=
PAGE_EXTNAME_APP
}
for
(
let
i
=
0
;
i
<
extnames
.
length
;
i
++
)
{
const
extname
=
extnames
[
i
]
if
(
fs
.
existsSync
(
absoltePagePath
+
extname
))
{
return
pagePath
+
extname
}
}
console
.
error
(
`
${
pagePath
}
not found`
)
}
packages/uni-cli-shared/src/vite/plugins/console.ts
0 → 100644
浏览文件 @
5a711a24
// import path from 'path'
// import slash from 'slash'
import
{
Plugin
}
from
'
vite
'
import
{
createFilter
,
FilterPattern
}
from
'
@rollup/pluginutils
'
export
interface
ConsoleOptions
{
include
?:
FilterPattern
exclude
?:
FilterPattern
}
export
function
uniConsolePlugin
(
options
:
ConsoleOptions
):
Plugin
{
const
filter
=
createFilter
(
options
.
include
,
options
.
exclude
)
return
{
name
:
'
vite:uni-app-console
'
,
transform
(
code
,
id
)
{
if
(
!
filter
(
id
))
return
null
if
(
!
code
.
includes
(
'
console.
'
))
{
return
null
}
},
}
}
packages/uni-h5-vite/dist/plugins/pagesJson.js
浏览文件 @
5a711a24
...
...
@@ -137,8 +137,12 @@ function generateLayoutComponentsCode(globalName, pagesJson) {
};
}
function
generatePageDefineCode
(
pageOptions
)
{
const
pagePathWithExtname
=
uni_cli_shared_1
.
normalizePagePath
(
pageOptions
.
path
,
'
h5
'
);
if
(
!
pagePathWithExtname
)
{
return
''
;
}
const
pageIdent
=
uni_cli_shared_1
.
normalizeIdentifier
(
pageOptions
.
path
);
return
`const
${
pageIdent
}
Loader = ()=>import('./
${
page
Options
.
path
}
?mpType=page')
return
`const
${
pageIdent
}
Loader = ()=>import('./
${
page
PathWithExtname
}
?mpType=page')
const
${
pageIdent
}
= defineAsyncComponent(extend({loader:
${
pageIdent
}
Loader},AsyncComponentOptions))`
;
}
function
generatePagesDefineCode
(
pagesJson
,
_config
)
{
...
...
packages/uni-h5-vite/src/plugins/pagesJson.ts
浏览文件 @
5a711a24
...
...
@@ -10,6 +10,7 @@ import {
normalizePagesJson
,
defineUniPagesJsonPlugin
,
normalizePagesRoute
,
normalizePagePath
,
}
from
'
@dcloudio/uni-cli-shared
'
const
pkg
=
require
(
'
@dcloudio/vite-plugin-uni/package.json
'
)
...
...
@@ -164,8 +165,12 @@ function generateLayoutComponentsCode(
}
function
generatePageDefineCode
(
pageOptions
:
UniApp
.
PagesJsonPageOptions
)
{
const
pagePathWithExtname
=
normalizePagePath
(
pageOptions
.
path
,
'
h5
'
)
if
(
!
pagePathWithExtname
)
{
return
''
}
const
pageIdent
=
normalizeIdentifier
(
pageOptions
.
path
)
return
`const
${
pageIdent
}
Loader = ()=>import('./
${
page
Options
.
path
}
?mpType=page')
return
`const
${
pageIdent
}
Loader = ()=>import('./
${
page
PathWithExtname
}
?mpType=page')
const
${
pageIdent
}
= defineAsyncComponent(extend({loader:
${
pageIdent
}
Loader},AsyncComponentOptions))`
}
...
...
packages/vite-plugin-uni/src/config/index.ts
浏览文件 @
5a711a24
import
path
from
'
path
'
import
{
Plugin
,
UserConfig
}
from
'
vite
'
import
{
normalizePath
,
parseManifestJsonOnce
}
from
'
@dcloudio/uni-cli-shared
'
import
{
initPreContext
,
normalizePath
,
parseManifestJsonOnce
,
}
from
'
@dcloudio/uni-cli-shared
'
import
{
VitePluginUniResolvedOptions
}
from
'
..
'
import
{
createCss
}
from
'
./css
'
...
...
@@ -32,6 +36,9 @@ export function createConfig(
options
.
command
=
env
.
command
options
.
platform
=
(
process
.
env
.
UNI_PLATFORM
as
UniApp
.
PLATFORM
)
||
'
h5
'
options
.
inputDir
=
normalizeInputDir
(
config
)
initPreContext
(
options
.
platform
)
let
base
=
config
.
base
if
(
!
base
)
{
const
{
h5
}
=
parseManifestJsonOnce
(
options
.
inputDir
)
...
...
packages/vite-plugin-uni/src/configResolved/index.ts
浏览文件 @
5a711a24
import
{
Plugin
}
from
'
vite
'
import
{
initPreContext
/*,checkUpdate*/
}
from
'
@dcloudio/uni-cli-shared
'
import
{
VitePluginUniResolvedOptions
}
from
'
..
'
import
{
initEnv
}
from
'
./env
'
...
...
@@ -12,7 +11,6 @@ export function createConfigResolved(options: VitePluginUniResolvedOptions) {
initOptions
(
options
,
config
)
initPlugins
(
config
,
options
)
initCheckUpdate
()
initPreContext
(
options
.
platform
)
})
as
Plugin
[
'
configResolved
'
]
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录