Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
18dd1b72
U
uni-app
项目概览
DCloud
/
uni-app
6 个月 前同步成功
通知
750
Star
38709
Fork
3642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
8
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
8
Issue
8
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
18dd1b72
编写于
6月 18, 2024
作者:
fxy060608
提交者:
qiang
6月 21, 2024
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
wip(harmony): 支持 nvue=> vue
上级
20b25f10
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
54 addition
and
53 deletion
+54
-53
packages/shims-uni-app.d.ts
packages/shims-uni-app.d.ts
+2
-0
packages/uni-app-harmony/dist/uni-app-view.umd.js
packages/uni-app-harmony/dist/uni-app-view.umd.js
+10
-44
packages/uni-app-harmony/dist/uni.runtime.esm.js
packages/uni-app-harmony/dist/uni.runtime.esm.js
+9
-3
packages/uni-app-harmony/src/service/framework/page/register.ts
...es/uni-app-harmony/src/service/framework/page/register.ts
+4
-0
packages/uni-app-harmony/src/view/framework/dom/page.ts
packages/uni-app-harmony/src/view/framework/dom/page.ts
+6
-0
packages/uni-app-vite/src/vue/plugins/pagesJson.ts
packages/uni-app-vite/src/vue/plugins/pagesJson.ts
+1
-1
packages/uni-cli-shared/src/json/app/pages/definePage.ts
packages/uni-cli-shared/src/json/app/pages/definePage.ts
+6
-3
packages/uni-cli-shared/src/json/app/pages/index.ts
packages/uni-cli-shared/src/json/app/pages/index.ts
+5
-2
packages/uni-cli-shared/src/json/pages.ts
packages/uni-cli-shared/src/json/pages.ts
+9
-0
packages/uni-shared/src/vdom/Action.ts
packages/uni-shared/src/vdom/Action.ts
+2
-0
未找到文件。
packages/shims-uni-app.d.ts
浏览文件 @
18dd1b72
...
...
@@ -250,6 +250,8 @@ declare namespace UniNamespace {
leftWindow
?:
boolean
rightWindow
?:
boolean
eventChannel
?:
any
// 目前 app-harmony 专用
isNVueStyle
?:
boolean
}
interface
PagesJsonPageOptions
{
...
...
packages/uni-app-harmony/dist/uni-app-view.umd.js
浏览文件 @
18dd1b72
...
...
@@ -11659,38 +11659,8 @@
var pako = {};
assign(pako, deflate, inflate, constants);
var pako_1 = pako;
var index$1 = 0;
function saveImage(dataURL, dirname, callback) {
var id2 = "".concat(Date.now()).concat(index$1++);
var array = dataURL.split(",");
var scheme = array[0];
var base64 = array[1];
var format = (scheme.match(/data:image\/(\S+?);/) || ["", "png"])[1].replace("jpeg", "jpg");
var fileName = "".concat(id2, ".").concat(format);
var tempFilePath = "".concat(dirname, "/").concat(fileName);
var i2 = dirname.indexOf("/");
var basePath = dirname.substring(0, i2);
var dirPath = dirname.substring(i2 + 1);
plus.io.resolveLocalFileSystemURL(basePath, function(entry) {
entry.getDirectory(dirPath, {
create: true,
exclusive: false
}, function(entry2) {
entry2.getFile(fileName, {
create: true,
exclusive: false
}, function(entry3) {
entry3.createWriter(function(writer) {
writer.onwrite = function() {
callback(null, tempFilePath);
};
writer.onerror = callback;
writer.seek(0);
writer.writeAsBinary(base64);
}, callback);
}, callback);
}, callback);
}, callback);
throw new Error("TODO: Implement");
}
function getSameOriginUrl(url) {
var a2 = document.createElement("a");
...
...
@@ -14084,9 +14054,9 @@
if (image) {
c2d.drawImage.apply(
c2d,
// @ts-
expect-error
// @ts-
ignore
[image].concat(
// @ts-
expect-error
// @ts-
ignore
[...otherData.slice(4, 8)],
[...otherData.slice(0, 4)]
)
...
...
@@ -14319,16 +14289,7 @@
});
return;
}
saveImage(res.data, dirname, (error, tempFilePath) => {
var errMsg = "toTempFilePath:".concat(error ? "fail" : "ok");
if (error) {
errMsg += " ".concat(error.message);
}
resolve({
errMsg,
tempFilePath
});
});
saveImage(res.data);
}
var methods = {
actionsChanged,
...
...
@@ -21741,7 +21702,8 @@
// onReachBottomDistance,
statusbarHeight,
windowTop,
windowBottom
windowBottom,
nvueFlexDirection
} = _ref;
initPageInfo(route);
initSystemInfo(platform, pixelRatio2, windowWidth);
...
...
@@ -21753,6 +21715,10 @@
if (disableScroll) {
document.addEventListener("touchmove", disableScrollListener);
}
if (nvueFlexDirection) {
document.body.setAttribute("nvue", "");
document.body.setAttribute("nvue-dir-".concat(nvueFlexDirection), "");
}
if (css) {
initPageCss(route);
} else {
...
...
packages/uni-app-harmony/dist/uni.runtime.esm.js
浏览文件 @
18dd1b72
...
...
@@ -10931,7 +10931,7 @@ const createCanvasContext = defineSyncApi(API_CREATE_CANVAS_CONTEXT, (canvasId,
UniServiceJSBridge
.
emit
(
ON_ERROR
,
'
createCanvasContext:fail
'
);
}
},
CreateCanvasContextProtocol
);
defineAsyncApi
(
API_CANVAS_GET_IMAGE_DATA
,
({
canvasId
,
x
,
y
,
width
,
height
},
{
resolve
,
reject
})
=>
{
const
canvasGetImageData
=
defineAsyncApi
(
API_CANVAS_GET_IMAGE_DATA
,
({
canvasId
,
x
,
y
,
width
,
height
},
{
resolve
,
reject
})
=>
{
const
pageId
=
getPageIdByVm
(
getCurrentPageVm
());
if
(
!
pageId
)
{
reject
();
...
...
@@ -10959,7 +10959,7 @@ defineAsyncApi(API_CANVAS_GET_IMAGE_DATA, ({ canvasId, x, y, width, height }, {
height
,
},
callback
);
},
CanvasGetImageDataProtocol
,
CanvasGetImageDataOptions
);
defineAsyncApi
(
API_CANVAS_PUT_IMAGE_DATA
,
({
canvasId
,
data
,
x
,
y
,
width
,
height
},
{
resolve
,
reject
})
=>
{
const
canvasPutImageData
=
defineAsyncApi
(
API_CANVAS_PUT_IMAGE_DATA
,
({
canvasId
,
data
,
x
,
y
,
width
,
height
},
{
resolve
,
reject
})
=>
{
var
pageId
=
getPageIdByVm
(
getCurrentPageVm
());
if
(
!
pageId
)
{
reject
();
...
...
@@ -10989,7 +10989,7 @@ defineAsyncApi(API_CANVAS_PUT_IMAGE_DATA, ({ canvasId, data, x, y, width, height
}
operate
();
},
CanvasPutImageDataProtocol
,
CanvasPutImageDataOptions
);
defineAsyncApi
(
API_CANVAS_TO_TEMP_FILE_PATH
,
({
x
=
0
,
y
=
0
,
width
,
height
,
destWidth
,
destHeight
,
canvasId
,
fileType
,
quality
,
},
{
resolve
,
reject
})
=>
{
const
canvasToTempFilePath
=
defineAsyncApi
(
API_CANVAS_TO_TEMP_FILE_PATH
,
({
x
=
0
,
y
=
0
,
width
,
height
,
destWidth
,
destHeight
,
canvasId
,
fileType
,
quality
,
},
{
resolve
,
reject
})
=>
{
var
pageId
=
getPageIdByVm
(
getCurrentPageVm
());
if
(
!
pageId
)
{
reject
();
...
...
@@ -12871,6 +12871,9 @@ function initPageOptions({ meta }) {
windowTop
:
0
,
// TODO tabBar.cover
windowBottom
:
0
,
nvueFlexDirection
:
meta
.
isNVueStyle
&&
__uniConfig
.
nvue
?
__uniConfig
.
nvue
[
'
flex-direction
'
]
:
undefined
,
};
}
...
...
@@ -13278,6 +13281,9 @@ function requireUTSPlugin(name) {
var
uni$1
=
{
__proto__
:
null
,
canIUse
:
canIUse
,
canvasGetImageData
:
canvasGetImageData
,
canvasPutImageData
:
canvasPutImageData
,
canvasToTempFilePath
:
canvasToTempFilePath
,
createCanvasContext
:
createCanvasContext
,
createSelectorQuery
:
createSelectorQuery
,
getLocale
:
getLocale
,
...
...
packages/uni-app-harmony/src/service/framework/page/register.ts
浏览文件 @
18dd1b72
...
...
@@ -89,5 +89,9 @@ function initPageOptions({ meta }: UniApp.UniRoute): PageNodeOptions {
windowTop
:
0
,
// TODO tabBar.cover
windowBottom
:
0
,
nvueFlexDirection
:
meta
.
isNVueStyle
&&
__uniConfig
.
nvue
?
__uniConfig
.
nvue
[
'
flex-direction
'
]
:
undefined
,
}
}
packages/uni-app-harmony/src/view/framework/dom/page.ts
浏览文件 @
18dd1b72
...
...
@@ -93,6 +93,7 @@ export function onPageCreate({
statusbarHeight
,
windowTop
,
windowBottom
,
nvueFlexDirection
,
}:
PageCreateData
)
{
initPageInfo
(
route
)
initSystemInfo
(
platform
,
pixelRatio
,
windowWidth
)
...
...
@@ -109,6 +110,11 @@ export function onPageCreate({
document
.
addEventListener
(
'
touchmove
'
,
disableScrollListener
)
}
if
(
nvueFlexDirection
)
{
document
.
body
.
setAttribute
(
'
nvue
'
,
''
)
document
.
body
.
setAttribute
(
`nvue-dir-
${
nvueFlexDirection
}
`
,
''
)
}
if
(
css
)
{
initPageCss
(
route
)
}
else
{
...
...
packages/uni-app-vite/src/vue/plugins/pagesJson.ts
浏览文件 @
18dd1b72
...
...
@@ -48,7 +48,7 @@ export function uniPagesJsonPlugin(): Plugin {
return
{
code
:
`import './
${
MANIFEST_JSON_JS
}
'\n`
+
normalizeAppPagesJson
(
pagesJson
),
normalizeAppPagesJson
(
pagesJson
,
process
.
env
.
UNI_PLATFORM
),
map
:
{
mappings
:
''
},
}
},
...
...
packages/uni-cli-shared/src/json/app/pages/definePage.ts
浏览文件 @
18dd1b72
import
{
normalizeIdentifier
,
normalizePagePath
}
from
'
../../../utils
'
export
function
definePageCode
(
pagesJson
:
Record
<
string
,
any
>
)
{
export
function
definePageCode
(
pagesJson
:
Record
<
string
,
any
>
,
platform
:
UniApp
.
PLATFORM
=
'
app
'
)
{
const
importPagesCode
:
string
[]
=
[]
const
definePagesCode
:
string
[]
=
[]
pagesJson
.
pages
.
forEach
((
page
:
UniApp
.
PagesJsonPageOptions
)
=>
{
if
(
page
.
style
.
isNVue
)
{
if
(
p
latform
===
'
app
'
&&
p
age
.
style
.
isNVue
)
{
return
}
const
pagePath
=
page
.
path
const
pageIdentifier
=
normalizeIdentifier
(
pagePath
)
const
pagePathWithExtname
=
normalizePagePath
(
pagePath
,
'
app
'
)
const
pagePathWithExtname
=
normalizePagePath
(
pagePath
,
platform
)
if
(
pagePathWithExtname
)
{
if
(
process
.
env
.
UNI_APP_CODE_SPLITING
)
{
// 拆分页面
...
...
packages/uni-cli-shared/src/json/app/pages/index.ts
浏览文件 @
18dd1b72
...
...
@@ -3,8 +3,11 @@ import { defineNVuePageCode, definePageCode } from './definePage'
import
{
normalizeAppUniConfig
}
from
'
./uniConfig
'
import
{
normalizeAppUniRoutes
}
from
'
./uniRoutes
'
export
function
normalizeAppPagesJson
(
pagesJson
:
Record
<
string
,
any
>
)
{
return
definePageCode
(
pagesJson
)
export
function
normalizeAppPagesJson
(
pagesJson
:
Record
<
string
,
any
>
,
platform
:
UniApp
.
PLATFORM
=
'
app
'
)
{
return
definePageCode
(
pagesJson
,
platform
)
}
export
function
normalizeAppNVuePagesJson
(
pagesJson
:
Record
<
string
,
any
>
)
{
...
...
packages/uni-cli-shared/src/json/pages.ts
浏览文件 @
18dd1b72
...
...
@@ -184,6 +184,15 @@ function normalizePages(
)
{
pages
.
forEach
((
page
)
=>
{
page
.
style
=
normalizePageStyle
(
page
.
path
,
page
.
style
!
,
platform
)
if
(
platform
===
'
app-harmony
'
)
{
// 鸿蒙下强制 isNVue 为 false,增加额外的 isNVueStyle 来标记样式处理
// 因为已有的代码里太多根据 isNVue 来处理的逻辑,这些逻辑在鸿蒙都不适用
// 鸿蒙仅需要将 nvue 当做 vue,并补充 css 即可
if
(
page
.
style
.
isNVue
)
{
page
.
style
.
isNVue
=
false
;(
page
.
style
as
any
).
isNVueStyle
=
true
}
}
})
if
(
platform
!==
'
app
'
)
{
return
...
...
packages/uni-shared/src/vdom/Action.ts
浏览文件 @
18dd1b72
...
...
@@ -31,6 +31,8 @@ export interface PageNodeOptions {
statusbarHeight
:
number
windowTop
:
number
windowBottom
:
number
// 仅限 app-harmony 使用
nvueFlexDirection
?:
string
}
export
interface
PageCreateData
extends
PageNodeOptions
{}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录