Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MuGuiLin
uni-app
提交
4d22a82c
U
uni-app
项目概览
MuGuiLin
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
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,发现更多精彩内容 >>
提交
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')
...
@@ -5,8 +5,8 @@ const { uniInjectPlugin } = require('@dcloudio/vite-plugin-uni')
*/
*/
const
UniCloudPlugin
=
{
const
UniCloudPlugin
=
{
name
:
'
vite:uni-cloud
'
,
name
:
'
vite:uni-cloud
'
,
config
()
{
config
(
config
)
{
initUniCloudEnv
()
initUniCloudEnv
(
config
)
return
{
return
{
define
:
{
define
:
{
'
process.env.UNI_CLOUD_PROVIDER
'
:
JSON
.
stringify
(
'
process.env.UNI_CLOUD_PROVIDER
'
:
JSON
.
stringify
(
...
@@ -19,7 +19,7 @@ const UniCloudPlugin = {
...
@@ -19,7 +19,7 @@ const UniCloudPlugin = {
}
}
},
},
configureServer
(
server
)
{
configureServer
(
server
)
{
server
.
httpServer
&&
if
(
server
.
httpServer
)
{
server
.
httpServer
.
on
(
'
listening
'
,
()
=>
{
server
.
httpServer
.
on
(
'
listening
'
,
()
=>
{
if
(
!
process
.
UNI_CLOUD
)
{
if
(
!
process
.
UNI_CLOUD
)
{
return
return
...
@@ -28,6 +28,18 @@ const UniCloudPlugin = {
...
@@ -28,6 +28,18 @@ const UniCloudPlugin = {
initUniCloudWarningOnce
()
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(() => {
...
@@ -37,7 +49,7 @@ const initUniCloudWarningOnce = once(() => {
)
)
})
})
function
initUniCloudEnv
()
{
function
initUniCloudEnv
(
config
)
{
process
.
UNI_CLOUD
=
false
process
.
UNI_CLOUD
=
false
process
.
UNI_CLOUD_TCB
=
false
process
.
UNI_CLOUD_TCB
=
false
process
.
UNI_CLOUD_ALIYUN
=
false
process
.
UNI_CLOUD_ALIYUN
=
false
...
@@ -46,6 +58,7 @@ function initUniCloudEnv() {
...
@@ -46,6 +58,7 @@ function initUniCloudEnv() {
if
(
!
process
.
env
.
UNI_CLOUD_SPACES
)
{
if
(
!
process
.
env
.
UNI_CLOUD_SPACES
)
{
return
return
}
}
const
silent
=
config
.
build
&&
config
.
build
.
ssr
?
true
:
false
try
{
try
{
const
spaces
=
JSON
.
parse
(
process
.
env
.
UNI_CLOUD_SPACES
)
const
spaces
=
JSON
.
parse
(
process
.
env
.
UNI_CLOUD_SPACES
)
if
(
Array
.
isArray
(
spaces
))
{
if
(
Array
.
isArray
(
spaces
))
{
...
@@ -54,7 +67,10 @@ function initUniCloudEnv() {
...
@@ -54,7 +67,10 @@ function initUniCloudEnv() {
process
.
UNI_CLOUD_ALIYUN
=
!!
spaces
.
find
((
space
)
=>
space
.
clientSecret
)
process
.
UNI_CLOUD_ALIYUN
=
!!
spaces
.
find
((
space
)
=>
space
.
clientSecret
)
if
(
spaces
.
length
===
1
)
{
if
(
spaces
.
length
===
1
)
{
const
space
=
spaces
[
0
]
const
space
=
spaces
[
0
]
console
.
log
(
`本项目的uniCloud使用的默认服务空间spaceId为:
${
space
.
id
}
`
)
!
silent
&&
console
.
log
(
`本项目的uniCloud使用的默认服务空间spaceId为:
${
space
.
id
}
`
)
}
}
process
.
env
.
UNI_CLOUD_PROVIDER
=
JSON
.
stringify
(
process
.
env
.
UNI_CLOUD_PROVIDER
=
JSON
.
stringify
(
spaces
.
map
((
space
)
=>
{
spaces
.
map
((
space
)
=>
{
...
@@ -83,9 +99,10 @@ function initUniCloudEnv() {
...
@@ -83,9 +99,10 @@ function initUniCloudEnv() {
process
.
env
.
UNI_PLATFORM
===
'
h5
'
&&
process
.
env
.
UNI_PLATFORM
===
'
h5
'
&&
process
.
env
.
NODE_ENV
===
'
production
'
process
.
env
.
NODE_ENV
===
'
production
'
)
{
)
{
console
.
warn
(
!
silent
&&
'
发布H5,需要在uniCloud后台操作,绑定安全域名,否则会因为跨域问题而无法访问。教程参考:https://uniapp.dcloud.io/uniCloud/quickstart?id=useinh5
'
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 = {
...
@@ -485,7 +485,7 @@ var safeAreaInsets = {
onChange,
onChange,
offChange
offChange
};
};
var
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out = safeAreaInsets;
var out = safeAreaInsets;
const onEventPrevent = /* @__PURE__ */ withModifiers(() => {
const onEventPrevent = /* @__PURE__ */ withModifiers(() => {
}, ["prevent"]);
}, ["prevent"]);
const onEventStop = /* @__PURE__ */ withModifiers(() => {
const onEventStop = /* @__PURE__ */ withModifiers(() => {
...
@@ -497,10 +497,10 @@ function getWindowOffset() {
...
@@ -497,10 +497,10 @@ function getWindowOffset() {
const left = parseInt(style.getPropertyValue("--window-left"));
const left = parseInt(style.getPropertyValue("--window-left"));
const right = parseInt(style.getPropertyValue("--window-right"));
const right = parseInt(style.getPropertyValue("--window-right"));
return {
return {
top: top ? top +
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.top : 0,
top: top ? top + out.top : 0,
bottom: bottom ? bottom +
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.bottom : 0,
bottom: bottom ? bottom + out.bottom : 0,
left: left ? left +
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.left : 0,
left: left ? left + out.left : 0,
right: right ? right +
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.right : 0
right: right ? right + out.right : 0
};
};
}
}
function updateCssVar(cssVars) {
function updateCssVar(cssVars) {
...
@@ -12860,7 +12860,7 @@ function normalizePageMeta(pageMeta) {
...
@@ -12860,7 +12860,7 @@ function normalizePageMeta(pageMeta) {
let offset = rpx2px(refreshOptions.offset);
let offset = rpx2px(refreshOptions.offset);
const {type} = navigationBar;
const {type} = navigationBar;
if (type !== "transparent" && type !== "none") {
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.offset = offset;
refreshOptions.height = rpx2px(refreshOptions.height);
refreshOptions.height = rpx2px(refreshOptions.height);
...
@@ -15051,7 +15051,7 @@ const getSystemInfoSync = /* @__PURE__ */ defineSyncApi("getSystemInfoSync", ()
...
@@ -15051,7 +15051,7 @@ const getSystemInfoSync = /* @__PURE__ */ defineSyncApi("getSystemInfoSync", ()
const windowWidth = getWindowWidth(screenWidth);
const windowWidth = getWindowWidth(screenWidth);
let windowHeight = window.innerHeight;
let windowHeight = window.innerHeight;
const language = navigator.language;
const language = navigator.language;
const statusBarHeight =
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.top;
const statusBarHeight = out.top;
let osname;
let osname;
let osversion;
let osversion;
let model;
let model;
...
@@ -15164,12 +15164,12 @@ const getSystemInfoSync = /* @__PURE__ */ defineSyncApi("getSystemInfoSync", ()
...
@@ -15164,12 +15164,12 @@ const getSystemInfoSync = /* @__PURE__ */ defineSyncApi("getSystemInfoSync", ()
const system = `${osname} ${osversion}`;
const system = `${osname} ${osversion}`;
const platform = osname.toLocaleLowerCase();
const platform = osname.toLocaleLowerCase();
const safeArea = {
const safeArea = {
left:
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.left,
left: out.left,
right: windowWidth -
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.right,
right: windowWidth - out.right,
top:
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.top,
top: out.top,
bottom: windowHeight -
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.bottom,
bottom: windowHeight - out.bottom,
width: windowWidth -
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.left - D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.right,
width: windowWidth -
out.left -
out.right,
height: windowHeight -
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.top - D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.bottom
height: windowHeight -
out.top -
out.bottom
};
};
const {top: windowTop, bottom: windowBottom} = getWindowOffset();
const {top: windowTop, bottom: windowBottom} = getWindowOffset();
windowHeight -= windowTop;
windowHeight -= windowTop;
...
@@ -15189,10 +15189,10 @@ const getSystemInfoSync = /* @__PURE__ */ defineSyncApi("getSystemInfoSync", ()
...
@@ -15189,10 +15189,10 @@ const getSystemInfoSync = /* @__PURE__ */ defineSyncApi("getSystemInfoSync", ()
model,
model,
safeArea,
safeArea,
safeAreaInsets: {
safeAreaInsets: {
top:
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.top,
top: out.top,
right:
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.right,
right: out.right,
bottom:
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.bottom,
bottom: out.bottom,
left:
D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_
out.left
left: out.left
}
}
};
};
});
});
...
...
packages/vite-plugin-uni/src/cli/build.ts
浏览文件 @
4d22a82c
import
fs
from
'
fs-extra
'
import
path
from
'
path
'
import
path
from
'
path
'
import
{
build
as
buildByVite
,
BuildOptions
}
from
'
vite
'
import
{
build
as
buildByVite
,
BuildOptions
}
from
'
vite
'
import
{
CliOptions
}
from
'
.
'
import
{
CliOptions
}
from
'
.
'
...
@@ -14,27 +15,52 @@ export async function build(options: CliOptions) {
...
@@ -14,27 +15,52 @@ export async function build(options: CliOptions) {
export
async
function
buildSSR
(
options
:
CliOptions
)
{
export
async
function
buildSSR
(
options
:
CliOptions
)
{
const
outputDir
=
process
.
env
.
UNI_OUTPUT_DIR
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
)
const
ssrBuildClientOptions
:
BuildOptions
=
cleanOptions
(
options
)
ssrBuildClientOptions
.
ssrManifest
=
true
ssrBuildClientOptions
.
ssrManifest
=
true
ssrBuildClientOptions
.
outDir
=
process
.
env
.
UNI_OUTPUT_DIR
ssrBuildClientOptions
.
outDir
=
process
.
env
.
UNI_OUTPUT_DIR
process
.
env
.
UNI_SSR_CLIENT
=
'
true
'
await
buildByVite
({
await
buildByVite
({
root
:
process
.
env
.
VITE_ROOT_DIR
,
root
:
process
.
env
.
VITE_ROOT_DIR
,
logLevel
:
options
.
logLevel
,
logLevel
:
options
.
logLevel
,
clearScreen
:
options
.
clearScreen
,
clearScreen
:
options
.
clearScreen
,
build
:
ssrBuildClientOptions
,
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
)
const
ssrBuildServerOptions
:
BuildOptions
=
cleanOptions
(
options
)
ssrBuildServerOptions
.
ssr
=
path
.
resolve
(
ssrBuildServerOptions
.
ssr
=
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
process
.
env
.
UNI_INPUT_DIR
,
'
entry-server.js
'
'
entry-server.js
'
)
)
ssrBuildServerOptions
.
outDir
=
process
.
env
.
UNI_OUTPUT_DIR
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
({
await
buildByVite
({
root
:
process
.
env
.
VITE_ROOT_DIR
,
root
:
process
.
env
.
VITE_ROOT_DIR
,
logLevel
:
options
.
logLevel
,
logLevel
:
options
.
logLevel
,
clearScreen
:
options
.
clearScreen
,
clearScreen
:
options
.
clearScreen
,
build
:
ssrBuildServerOptions
,
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录