Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
4d22a82c
U
uni-app
项目概览
DCloud
/
uni-app
3 个月 前同步成功
通知
725
Star
38705
Fork
3642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
7
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
7
Issue
7
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4d22a82c
编写于
5月 26, 2021
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore(ssr): add log
上级
22345850
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
70 addition
and
27 deletion
+70
-27
packages/uni-cloud/lib/uni.plugin.js
packages/uni-cloud/lib/uni.plugin.js
+25
-8
packages/uni-h5/dist/uni-h5.es.js
packages/uni-h5/dist/uni-h5.es.js
+17
-17
packages/vite-plugin-uni/src/cli/build.ts
packages/vite-plugin-uni/src/cli/build.ts
+28
-2
未找到文件。
packages/uni-cloud/lib/uni.plugin.js
浏览文件 @
4d22a82c
...
...
@@ -5,8 +5,8 @@ const { uniInjectPlugin } = require('@dcloudio/vite-plugin-uni')
*/
const
UniCloudPlugin
=
{
name
:
'
vite:uni-cloud
'
,
config
()
{
initUniCloudEnv
()
config
(
config
)
{
initUniCloudEnv
(
config
)
return
{
define
:
{
'
process.env.UNI_CLOUD_PROVIDER
'
:
JSON
.
stringify
(
...
...
@@ -19,7 +19,7 @@ const UniCloudPlugin = {
}
},
configureServer
(
server
)
{
server
.
httpServer
&&
if
(
server
.
httpServer
)
{
server
.
httpServer
.
on
(
'
listening
'
,
()
=>
{
if
(
!
process
.
UNI_CLOUD
)
{
return
...
...
@@ -28,6 +28,18 @@ const UniCloudPlugin = {
initUniCloudWarningOnce
()
})
})
}
else
{
initUniCloudWarningOnce
()
}
},
closeBundle
()
{
if
(
process
.
env
.
UNI_PLATFORM
===
'
h5
'
&&
!
process
.
env
.
UNI_SSR_CLIENT
)
{
console
.
log
()
console
.
log
(
'
欢迎将H5站部署到uniCloud前端网页托管平台,高速、免费、安全、省心,详见:
'
)
console
.
log
(
'
https://uniapp.dcloud.io/uniCloud/hosting
'
)
}
},
}
...
...
@@ -37,7 +49,7 @@ const initUniCloudWarningOnce = once(() => {
)
})
function
initUniCloudEnv
()
{
function
initUniCloudEnv
(
config
)
{
process
.
UNI_CLOUD
=
false
process
.
UNI_CLOUD_TCB
=
false
process
.
UNI_CLOUD_ALIYUN
=
false
...
...
@@ -46,6 +58,7 @@ function initUniCloudEnv() {
if
(
!
process
.
env
.
UNI_CLOUD_SPACES
)
{
return
}
const
silent
=
config
.
build
&&
config
.
build
.
ssr
?
true
:
false
try
{
const
spaces
=
JSON
.
parse
(
process
.
env
.
UNI_CLOUD_SPACES
)
if
(
Array
.
isArray
(
spaces
))
{
...
...
@@ -54,7 +67,10 @@ function initUniCloudEnv() {
process
.
UNI_CLOUD_ALIYUN
=
!!
spaces
.
find
((
space
)
=>
space
.
clientSecret
)
if
(
spaces
.
length
===
1
)
{
const
space
=
spaces
[
0
]
console
.
log
(
`本项目的uniCloud使用的默认服务空间spaceId为:
${
space
.
id
}
`
)
!
silent
&&
console
.
log
(
`本项目的uniCloud使用的默认服务空间spaceId为:
${
space
.
id
}
`
)
}
process
.
env
.
UNI_CLOUD_PROVIDER
=
JSON
.
stringify
(
spaces
.
map
((
space
)
=>
{
...
...
@@ -83,9 +99,10 @@ function initUniCloudEnv() {
process
.
env
.
UNI_PLATFORM
===
'
h5
'
&&
process
.
env
.
NODE_ENV
===
'
production
'
)
{
console
.
warn
(
'
发布H5,需要在uniCloud后台操作,绑定安全域名,否则会因为跨域问题而无法访问。教程参考:https://uniapp.dcloud.io/uniCloud/quickstart?id=useinh5
'
)
!
silent
&&
console
.
warn
(
'
发布H5,需要在uniCloud后台操作,绑定安全域名,否则会因为跨域问题而无法访问。教程参考:https://uniapp.dcloud.io/uniCloud/quickstart?id=useinh5
'
)
}
}
...
...
packages/uni-h5/dist/uni-h5.es.js
浏览文件 @
4d22a82c
...
...
@@ -485,7 +485,7 @@ var safeAreaInsets = {
onChange,
offChange
};
var
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out = safeAreaInsets;
var out = safeAreaInsets;
const onEventPrevent = /* @__PURE__ */ withModifiers(() => {
}, ["prevent"]);
const onEventStop = /* @__PURE__ */ withModifiers(() => {
...
...
@@ -497,10 +497,10 @@ function getWindowOffset() {
const left = parseInt(style.getPropertyValue("--window-left"));
const right = parseInt(style.getPropertyValue("--window-right"));
return {
top: top ? top +
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.top : 0,
bottom: bottom ? bottom +
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.bottom : 0,
left: left ? left +
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.left : 0,
right: right ? right +
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.right : 0
top: top ? top + out.top : 0,
bottom: bottom ? bottom + out.bottom : 0,
left: left ? left + out.left : 0,
right: right ? right + out.right : 0
};
}
function updateCssVar(cssVars) {
...
...
@@ -12860,7 +12860,7 @@ function normalizePageMeta(pageMeta) {
let offset = rpx2px(refreshOptions.offset);
const {type} = navigationBar;
if (type !== "transparent" && type !== "none") {
offset += NAVBAR_HEIGHT +
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.top;
offset += NAVBAR_HEIGHT + out.top;
}
refreshOptions.offset = offset;
refreshOptions.height = rpx2px(refreshOptions.height);
...
...
@@ -15051,7 +15051,7 @@ const getSystemInfoSync = /* @__PURE__ */ defineSyncApi("getSystemInfoSync", ()
const windowWidth = getWindowWidth(screenWidth);
let windowHeight = window.innerHeight;
const language = navigator.language;
const statusBarHeight =
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.top;
const statusBarHeight = out.top;
let osname;
let osversion;
let model;
...
...
@@ -15164,12 +15164,12 @@ const getSystemInfoSync = /* @__PURE__ */ defineSyncApi("getSystemInfoSync", ()
const system = `${osname} ${osversion}`;
const platform = osname.toLocaleLowerCase();
const safeArea = {
left:
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.left,
right: windowWidth -
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.right,
top:
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.top,
bottom: windowHeight -
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.bottom,
width: windowWidth -
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.left - D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.right,
height: windowHeight -
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.top - D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.bottom
left: out.left,
right: windowWidth - out.right,
top: out.top,
bottom: windowHeight - out.bottom,
width: windowWidth -
out.left -
out.right,
height: windowHeight -
out.top -
out.bottom
};
const {top: windowTop, bottom: windowBottom} = getWindowOffset();
windowHeight -= windowTop;
...
...
@@ -15189,10 +15189,10 @@ const getSystemInfoSync = /* @__PURE__ */ defineSyncApi("getSystemInfoSync", ()
model,
safeArea,
safeAreaInsets: {
top:
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.top,
right:
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.right,
bottom:
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.bottom,
left:
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.left
top: out.top,
right: out.right,
bottom: out.bottom,
left: out.left
}
};
});
...
...
packages/vite-plugin-uni/src/cli/build.ts
浏览文件 @
4d22a82c
import
fs
from
'
fs-extra
'
import
path
from
'
path
'
import
{
build
as
buildByVite
,
BuildOptions
}
from
'
vite
'
import
{
CliOptions
}
from
'
.
'
...
...
@@ -14,27 +15,52 @@ export async function build(options: CliOptions) {
export
async
function
buildSSR
(
options
:
CliOptions
)
{
const
outputDir
=
process
.
env
.
UNI_OUTPUT_DIR
process
.
env
.
UNI_OUTPUT_DIR
=
path
.
resolve
(
outputDir
,
'
client
'
)
const
ssrClientDir
=
path
.
resolve
(
outputDir
,
'
client
'
)
process
.
env
.
UNI_OUTPUT_DIR
=
ssrClientDir
const
ssrBuildClientOptions
:
BuildOptions
=
cleanOptions
(
options
)
ssrBuildClientOptions
.
ssrManifest
=
true
ssrBuildClientOptions
.
outDir
=
process
.
env
.
UNI_OUTPUT_DIR
process
.
env
.
UNI_SSR_CLIENT
=
'
true
'
await
buildByVite
({
root
:
process
.
env
.
VITE_ROOT_DIR
,
logLevel
:
options
.
logLevel
,
clearScreen
:
options
.
clearScreen
,
build
:
ssrBuildClientOptions
,
})
process
.
env
.
UNI_OUTPUT_DIR
=
path
.
resolve
(
outputDir
,
'
server
'
)
const
ssrServerDir
=
path
.
resolve
(
outputDir
,
'
server
'
)
process
.
env
.
UNI_OUTPUT_DIR
=
ssrServerDir
const
ssrBuildServerOptions
:
BuildOptions
=
cleanOptions
(
options
)
ssrBuildServerOptions
.
ssr
=
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
'
entry-server.js
'
)
ssrBuildServerOptions
.
outDir
=
process
.
env
.
UNI_OUTPUT_DIR
ssrBuildServerOptions
.
rollupOptions
=
{
onwarn
(
warning
,
warn
)
{
if
(
warning
.
code
===
'
UNUSED_EXTERNAL_IMPORT
'
)
{
const
{
message
}
=
warning
// ignore
if
(
message
.
includes
(
'
"resolveComponent"
'
))
{
return
}
}
warn
(
warning
)
},
}
process
.
env
.
UNI_SSR_CLIENT
=
''
process
.
env
.
UNI_SSR_SERVER
=
'
true
'
await
buildByVite
({
root
:
process
.
env
.
VITE_ROOT_DIR
,
logLevel
:
options
.
logLevel
,
clearScreen
:
options
.
clearScreen
,
build
:
ssrBuildServerOptions
,
})
// copy ssr-manfiest.json to server
const
ssrManifestFile
=
path
.
join
(
ssrClientDir
,
'
ssr-manifest.json
'
)
if
(
fs
.
existsSync
(
ssrManifestFile
))
{
fs
.
copyFileSync
(
ssrManifestFile
,
path
.
join
(
ssrServerDir
,
'
ssr-manifest.json
'
)
)
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录