Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
良好的行为成为习惯
uni-app
提交
f4bcef5c
U
uni-app
项目概览
良好的行为成为习惯
/
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,发现更多精彩内容 >>
提交
f4bcef5c
编写于
4月 28, 2021
作者:
雪洛
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore: 添加cli项目使用uniCloud时的提示
上级
bc2039ed
变更
4
展开全部
隐藏空白更改
内联
并排
Showing
4 changed file
with
40 addition
and
36 deletion
+40
-36
packages/vue-cli-plugin-uni/commands/serve.js
packages/vue-cli-plugin-uni/commands/serve.js
+12
-17
packages/vue-cli-plugin-uni/lib/chain-webpack.js
packages/vue-cli-plugin-uni/lib/chain-webpack.js
+2
-1
packages/vue-cli-plugin-uni/lib/env.js
packages/vue-cli-plugin-uni/lib/env.js
+25
-17
packages/vue-cli-plugin-uni/packages/uni-cloud/dist/index.js
packages/vue-cli-plugin-uni/packages/uni-cloud/dist/index.js
+1
-1
未找到文件。
packages/vue-cli-plugin-uni/commands/serve.js
浏览文件 @
f4bcef5c
...
...
@@ -21,14 +21,14 @@ module.exports = (api, options) => {
'
--host
'
:
`specify host (default:
${
defaults
.
host
}
)`
,
'
--port
'
:
`specify port (default:
${
defaults
.
port
}
)`
,
'
--https
'
:
`use https (default:
${
defaults
.
https
}
)`
,
'
--public
'
:
'
specify the public network URL for the HMR client
'
,
'
--auto-host
'
:
'
specify automator host
'
,
'
--public
'
:
'
specify the public network URL for the HMR client
'
,
'
--auto-host
'
:
'
specify automator host
'
,
'
--auto-port
'
:
'
specify automator port
'
}
},
async
function
serve
(
args
)
{
info
(
'
Starting development server...
'
)
info
(
'
Starting development server...
'
)
require
(
'
./util
'
).
initAutomator
(
args
)
require
(
'
./util
'
).
initAutomator
(
args
)
// although this is primarily a dev server, it is possible that we
// are running it in a mode with a production env, e.g. in E2E tests.
...
...
@@ -199,10 +199,10 @@ module.exports = (api, options) => {
})
}
return
new
Promise
((
resolve
,
reject
)
=>
{
const
{
runByHBuilderX
}
=
require
(
'
@dcloudio/uni-cli-shared
'
)
return
new
Promise
((
resolve
,
reject
)
=>
{
const
{
runByHBuilderX
}
=
require
(
'
@dcloudio/uni-cli-shared
'
)
// log instructions & open browser on first compilation complete
let
isFirstCompile
=
true
compiler
.
hooks
.
done
.
tap
(
'
vue-cli-service uni-serve
'
,
stats
=>
{
...
...
@@ -224,9 +224,9 @@ module.exports = (api, options) => {
printRunningAt
&&
console
.
log
(
'
App running at:
'
)
printRunningAt
&&
console
.
log
(
` - Local:
${
chalk
.
cyan
(
urls
.
localUrlForTerminal
)}
${
copied
}
`
)
if
(
!
printRunningAt
)
{
console
.
log
(
'
Build complete. Watching for changes...
'
)
)
if
(
!
printRunningAt
)
{
console
.
log
(
'
Build complete. Watching for changes...
'
)
}
if
(
!
isInContainer
)
{
printRunningAt
&&
console
.
log
(
` - Network:
${
chalk
.
cyan
(
networkUrl
)}
`
)
...
...
@@ -260,11 +260,6 @@ module.exports = (api, options) => {
isFirstCompile
=
false
if
(
!
isProduction
)
{
if
(
process
.
UNI_CLOUD
)
{
console
.
warn
(
'
当前项目使用了uniCloud,为避免云函数调用跨域问题,建议在HBuilderX内置浏览器里调试,如使用外部浏览器需处理跨域,详见:https://uniapp.dcloud.io/uniCloud/quickstart?id=useinh5
'
)
}
// const buildCommand = hasProjectYarn(api.getCwd()) ? `yarn build` : `npm run build`
// console.log(` Note that the development build is not optimized.`)
// console.log(` To create a production build, run ${chalk.cyan(buildCommand)}.`)
...
...
@@ -343,4 +338,4 @@ function checkInContainer () {
module
.
exports
.
defaultModes
=
{
serve
:
'
development
'
}
}
packages/vue-cli-plugin-uni/lib/chain-webpack.js
浏览文件 @
f4bcef5c
...
...
@@ -96,6 +96,7 @@ module.exports = function chainWebpack (platformOptions, vueOptions, api) {
'
process.env.UNI_ENV
'
:
JSON
.
stringify
(
process
.
env
.
UNI_PLATFORM
),
'
process.env.UNI_CLOUD_PROVIDER
'
:
process
.
env
.
UNI_CLOUD_PROVIDER
,
'
process.env.UNICLOUD_DEBUG
'
:
process
.
env
.
UNICLOUD_DEBUG
,
'
process.env.RUN_BY_HBUILDERX
'
:
process
.
env
.
RUN_BY_HBUILDERX
,
'
process.env.UNI_AUTOMATOR_WS_ENDPOINT
'
:
JSON
.
stringify
(
process
.
env
.
UNI_AUTOMATOR_WS_ENDPOINT
)
}
if
(
process
.
env
.
UNI_USING_VUE3
)
{
...
...
@@ -138,4 +139,4 @@ module.exports = function chainWebpack (platformOptions, vueOptions, api) {
webpackConfig
.
plugins
.
delete
(
'
progress
'
)
}
}
}
}
packages/vue-cli-plugin-uni/lib/env.js
浏览文件 @
f4bcef5c
...
...
@@ -32,22 +32,38 @@ process.env.VUE_APP_NAME = manifestJsonObj.name
process
.
env
.
UNI_USING_V3_SCOPED
=
true
process
.
UNI_CLOUD
=
false
process
.
UNI_CLOUD_TCB
=
false
process
.
UNI_CLOUD_ALIYUN
=
false
process
.
env
.
UNI_CLOUD_PROVIDER
=
JSON
.
stringify
([])
const
isH5
=
!
process
.
env
.
UNI_SUB_PLATFORM
&&
process
.
env
.
UNI_PLATFORM
===
'
h5
'
const
isProduction
=
process
.
env
.
NODE_ENV
===
'
production
'
if
(
process
.
env
.
UNI_CLOUD_SPACES
)
{
try
{
const
spaces
=
JSON
.
parse
(
process
.
env
.
UNI_CLOUD_SPACES
)
if
(
Array
.
isArray
(
spaces
))
{
process
.
UNI_CLOUD
=
spaces
.
length
>
0
process
.
UNI_CLOUD_TCB
=
!!
spaces
.
find
(
space
=>
!
space
.
clientSecret
)
process
.
UNI_CLOUD_ALIYUN
=
!!
spaces
.
find
(
space
=>
space
.
clientSecret
)
const
hasUniCloudSpace
=
spaces
.
length
>
0
if
(
spaces
.
length
===
1
)
{
const
space
=
spaces
[
0
]
console
.
log
(
`本项目的uniCloud使用的默认服务空间spaceId为:
${
space
.
id
}
`
)
}
if
(
hasUniCloudSpace
&&
isH5
&&
isProduction
)
{
console
.
warn
(
'
发布H5,需要在uniCloud后台操作,绑定安全域名,否则会因为跨域问题而无法访问。教程参考:https://uniapp.dcloud.io/uniCloud/quickstart?id=useinh5
'
)
}
else
if
(
hasUniCloudSpace
&&
isH5
&&
!
isProduction
)
{
console
.
warn
(
'
当前项目使用了uniCloud,为避免云函数调用跨域问题,建议在HBuilderX内置浏览器里调试,如使用外部浏览器需处理跨域,详见:https://uniapp.dcloud.io/uniCloud/quickstart?id=useinh5
'
)
}
process
.
env
.
UNI_CLOUD_PROVIDER
=
JSON
.
stringify
(
spaces
.
map
(
space
=>
{
if
(
space
.
clientSecret
)
{
return
{
...
...
@@ -69,16 +85,6 @@ if (process.env.UNI_CLOUD_SPACES) {
}
catch
(
e
)
{}
}
if
(
process
.
UNI_CLOUD
&&
!
process
.
env
.
UNI_SUB_PLATFORM
&&
process
.
env
.
UNI_PLATFORM
===
'
h5
'
&&
process
.
env
.
NODE_ENV
===
'
production
'
)
{
console
.
warn
(
'
发布H5,需要在uniCloud后台操作,绑定安全域名,否则会因为跨域问题而无法访问。教程参考:https://uniapp.dcloud.io/uniCloud/quickstart?id=useinh5
'
)
}
// 初始化环境变量
const
defaultOutputDir
=
'
../../../../dist/
'
+
(
process
.
env
.
NODE_ENV
===
'
production
'
?
'
build
'
:
'
dev
'
)
+
'
/
'
+
...
...
@@ -110,7 +116,9 @@ const {
isSupportSubPackages
,
runByHBuilderX
,
getPagesJson
}
=
require
(
'
@dcloudio/uni-cli-shared
'
)
}
=
require
(
'
@dcloudio/uni-cli-shared
'
)
process
.
env
.
RUN_BY_HBUILDERX
=
JSON
.
stringify
(
runByHBuilderX
)
const
{
initUniModules
...
...
packages/vue-cli-plugin-uni/packages/uni-cloud/dist/index.js
浏览文件 @
f4bcef5c
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录