Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Velpro187
uni-app
提交
45857fef
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,发现更多精彩内容 >>
提交
45857fef
编写于
4月 15, 2021
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: setupApp,setupPage
上级
393322b1
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
29 addition
and
13 deletion
+29
-13
packages/vite-plugin-uni/src/configResolved/plugins/index.ts
packages/vite-plugin-uni/src/configResolved/plugins/index.ts
+1
-1
packages/vite-plugin-uni/src/configResolved/plugins/mainJs.ts
...ages/vite-plugin-uni/src/configResolved/plugins/mainJs.ts
+1
-1
packages/vite-plugin-uni/src/configResolved/plugins/pageVue.ts
...ges/vite-plugin-uni/src/configResolved/plugins/pageVue.ts
+25
-9
packages/vite-plugin-uni/src/configResolved/plugins/pagesJson.ts
...s/vite-plugin-uni/src/configResolved/plugins/pagesJson.ts
+2
-2
未找到文件。
packages/vite-plugin-uni/src/configResolved/plugins/index.ts
浏览文件 @
45857fef
...
...
@@ -106,7 +106,7 @@ export function resolvePlugins(
uniEasycomPlugin
(
Object
.
assign
(
uniEasycomPluginOptions
,
options
)),
'
vite:vue
'
)
addPlugin
(
plugins
,
uniPageVuePlugin
(
{
command
}
),
'
vite:vue
'
)
addPlugin
(
plugins
,
uniPageVuePlugin
(
options
),
'
vite:vue
'
)
addPlugin
(
plugins
,
uniJsonPlugin
(
options
),
'
vite:json
'
,
'
pre
'
)
addPlugin
(
plugins
,
uniStaticPlugin
(
options
,
config
),
'
vite:asset
'
,
'
pre
'
)
if
(
command
===
'
build
'
)
{
...
...
packages/vite-plugin-uni/src/configResolved/plugins/mainJs.ts
浏览文件 @
45857fef
...
...
@@ -13,7 +13,7 @@ export function uniMainJsPlugin(options: VitePluginUniResolvedOptions): Plugin {
transform
(
code
,
id
)
{
if
(
id
===
mainJsPath
||
id
===
mainTsPath
)
{
return
{
code
:
`import { plugin
, setupApp } from '@dcloudio/uni-h5';import '
${
pagesJsonJsPath
}
';function createApp(rootComponent,rootProps){rootComponent && setupApp(rootComponent);
return createVueApp(rootComponent, rootProps).use(plugin)};
${
code
.
replace
(
code
:
`import { plugin
} from '@dcloudio/uni-h5';import '
${
pagesJsonJsPath
}
';function createApp(rootComponent,rootProps){
return createVueApp(rootComponent, rootProps).use(plugin)};
${
code
.
replace
(
'
createApp
'
,
'
createVueApp
'
)}
`
,
...
...
packages/vite-plugin-uni/src/configResolved/plugins/pageVue.ts
浏览文件 @
45857fef
import
fs
from
'
fs
'
import
{
Plugin
,
ResolvedConfig
}
from
'
vite
'
import
path
from
'
path
'
import
slash
from
'
slash
'
import
debug
from
'
debug
'
import
{
Plugin
}
from
'
vite
'
import
{
parseVueRequest
}
from
'
@dcloudio/uni-cli-shared
'
import
{
VitePluginUniResolvedOptions
}
from
'
../..
'
export
function
uniPageVuePlugin
({
command
,
}:
{
command
:
ResolvedConfig
[
'
command
'
]
}):
Plugin
{
const
debugPageVue
=
debug
(
'
uni:page-vue
'
)
export
function
uniPageVuePlugin
(
options
:
VitePluginUniResolvedOptions
):
Plugin
{
const
appVuePath
=
slash
(
path
.
resolve
(
options
.
inputDir
,
'
App.vue
'
))
return
{
name
:
'
vite:uni-page-vue
'
,
load
(
id
)
{
if
(
command
===
'
build
'
)
{
if
(
options
.
command
===
'
build
'
)
{
const
{
filename
,
query
}
=
parseVueRequest
(
id
)
if
(
query
.
mpType
===
'
page
'
)
{
return
fs
.
readFileSync
(
filename
,
'
utf8
'
)
...
...
@@ -18,9 +23,20 @@ export function uniPageVuePlugin({
}
},
transform
(
code
,
id
)
{
const
{
query
}
=
parseVueRequest
(
id
)
const
{
filename
,
query
}
=
parseVueRequest
(
id
)
if
(
filename
===
appVuePath
&&
!
query
.
vue
)
{
debugPageVue
(
filename
)
return
(
code
+
`;import {setupApp} from '@dcloudio/uni-h5';setupApp(_sfc_main);`
)
}
if
(
query
.
mpType
===
'
page
'
)
{
return
code
+
`;_sfc_main.mpType='page'`
debugPageVue
(
filename
)
return
(
code
+
`;import {setupPage} from '@dcloudio/uni-h5';setupPage(_sfc_main);`
)
}
},
}
...
...
packages/vite-plugin-uni/src/configResolved/plugins/pagesJson.ts
浏览文件 @
45857fef
...
...
@@ -67,7 +67,7 @@ import { extend } from '@vue/shared'
import {
${
config
.
define
!
.
__UNI_FEATURE_PAGES__
?
'
defineAsyncComponent,
'
:
''
}
resolveComponent, createVNode, withCtx, openBlock, createBlock } from 'vue'
import {
setupPage,
PageComponent, AsyncLoadingComponent, AsyncErrorComponent } from '@dcloudio/uni-h5'
import { PageComponent, AsyncLoadingComponent, AsyncErrorComponent } from '@dcloudio/uni-h5'
import { appid, debug, networkTimeout, router, async, sdkConfigs, qqMapKey, nvue } from '
${
manifestJsonPath
}
'
${
cssCode
}
${
uniConfigCode
}
...
...
@@ -128,7 +128,7 @@ function generatePageDefineCode(pageOptions: UniApp.PagesJsonPageOptions) {
pageOptions
.
path
)}
= defineAsyncComponent(extend({loader:()=>import('./
${
pageOptions
.
path
}
.vue?mpType=page')
.then(comp=>setupPage(comp))
},AsyncComponentOptions))`
}
.vue?mpType=page')},AsyncComponentOptions))`
}
function
generatePagesDefineCode
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录