Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小浣熊撸代码
uni-app
提交
70aaee2b
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,发现更多精彩内容 >>
提交
70aaee2b
编写于
6月 24, 2020
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(cli): support theme.json #1828
上级
94893771
变更
15
显示空白变更内容
内联
并排
Showing
15 changed file
with
114 addition
and
14 deletion
+114
-14
packages/uni-app-plus/dist/index.js
packages/uni-app-plus/dist/index.js
+2
-1
packages/uni-cli-shared/lib/theme.js
packages/uni-cli-shared/lib/theme.js
+59
-0
packages/uni-mp-alipay/dist/index.js
packages/uni-mp-alipay/dist/index.js
+2
-1
packages/uni-mp-baidu/dist/index.js
packages/uni-mp-baidu/dist/index.js
+2
-1
packages/uni-mp-qq/dist/index.js
packages/uni-mp-qq/dist/index.js
+2
-1
packages/uni-mp-toutiao/dist/index.js
packages/uni-mp-toutiao/dist/index.js
+2
-1
packages/uni-mp-weixin/dist/index.js
packages/uni-mp-weixin/dist/index.js
+2
-1
packages/uni-mp-weixin/lib/uni.config.js
packages/uni-mp-weixin/lib/uni.config.js
+4
-2
packages/uni-quickapp-webview/dist/index.js
packages/uni-quickapp-webview/dist/index.js
+2
-1
packages/vue-cli-plugin-uni/packages/mp-vue/dist/mp.runtime.esm.js
...vue-cli-plugin-uni/packages/mp-vue/dist/mp.runtime.esm.js
+2
-0
packages/webpack-uni-pages-loader/lib/index-new.js
packages/webpack-uni-pages-loader/lib/index-new.js
+13
-1
packages/webpack-uni-pages-loader/lib/platforms/mp.js
packages/webpack-uni-pages-loader/lib/platforms/mp.js
+11
-1
packages/webpack-uni-pages-loader/lib/util.js
packages/webpack-uni-pages-loader/lib/util.js
+7
-1
src/core/service/plugins/lifecycle.js
src/core/service/plugins/lifecycle.js
+2
-1
src/platforms/mp-weixin/runtime/wrapper/app-base-parser.js
src/platforms/mp-weixin/runtime/wrapper/app-base-parser.js
+2
-1
未找到文件。
packages/uni-app-plus/dist/index.js
浏览文件 @
70aaee2b
...
...
@@ -1156,7 +1156,8 @@ const hooks = [
'
onShow
'
,
'
onHide
'
,
'
onError
'
,
'
onPageNotFound
'
'
onPageNotFound
'
,
'
onThemeChange
'
];
function
parseBaseApp
(
vm
,
{
...
...
packages/uni-cli-shared/lib/theme.js
0 → 100644
浏览文件 @
70aaee2b
const
fs
=
require
(
'
fs
'
)
const
path
=
require
(
'
path
'
)
const
{
getJson
}
=
require
(
'
./json
'
)
function
parseThemeByJsonStr
(
jsonStr
,
keys
,
theme
)
{
if
(
jsonStr
.
indexOf
(
'
@
'
)
===
-
1
)
{
return
jsonStr
}
keys
.
forEach
(
key
=>
{
jsonStr
=
jsonStr
.
replace
(
new
RegExp
(
'
@
'
+
key
,
'
g
'
),
theme
[
key
])
})
return
jsonStr
}
const
themeJsonPath
=
path
.
join
(
process
.
env
.
UNI_INPUT_DIR
,
'
theme.json
'
)
function
hasTheme
()
{
return
fs
.
existsSync
(
themeJsonPath
)
}
function
darkmode
()
{
return
!!
(
global
.
uniPlugin
.
options
||
{}).
darkmode
}
module
.
exports
=
{
darkmode
,
hasTheme
,
initTheme
()
{
if
(
!
hasTheme
())
{
return
}
if
(
darkmode
())
{
return
}
try
{
const
theme
=
getJson
(
'
theme.json
'
,
true
)
global
.
uniPlugin
.
defaultTheme
=
theme
.
light
}
catch
(
e
)
{
console
.
error
(
e
)
}
},
parseTheme
(
json
)
{
const
theme
=
global
.
uniPlugin
.
defaultTheme
if
(
!
theme
)
{
return
json
}
const
keys
=
Object
.
keys
(
theme
)
if
(
!
keys
.
length
)
{
return
json
}
if
(
typeof
json
===
'
string
'
)
{
return
parseThemeByJsonStr
(
json
,
keys
,
theme
)
}
return
JSON
.
parse
(
parseThemeByJsonStr
(
JSON
.
stringify
(
json
),
keys
,
theme
))
}
}
packages/uni-mp-alipay/dist/index.js
浏览文件 @
70aaee2b
...
...
@@ -1633,7 +1633,8 @@ const hooks = [
'
onShow
'
,
'
onHide
'
,
'
onError
'
,
'
onPageNotFound
'
'
onPageNotFound
'
,
'
onThemeChange
'
];
function
parseBaseApp
(
vm
,
{
...
...
packages/uni-mp-baidu/dist/index.js
浏览文件 @
70aaee2b
...
...
@@ -1298,7 +1298,8 @@ const hooks = [
'
onShow
'
,
'
onHide
'
,
'
onError
'
,
'
onPageNotFound
'
'
onPageNotFound
'
,
'
onThemeChange
'
];
function
parseBaseApp
(
vm
,
{
...
...
packages/uni-mp-qq/dist/index.js
浏览文件 @
70aaee2b
...
...
@@ -1214,7 +1214,8 @@ const hooks = [
'
onShow
'
,
'
onHide
'
,
'
onError
'
,
'
onPageNotFound
'
'
onPageNotFound
'
,
'
onThemeChange
'
];
function
parseBaseApp
(
vm
,
{
...
...
packages/uni-mp-toutiao/dist/index.js
浏览文件 @
70aaee2b
...
...
@@ -1306,7 +1306,8 @@ const hooks = [
'
onShow
'
,
'
onHide
'
,
'
onError
'
,
'
onPageNotFound
'
'
onPageNotFound
'
,
'
onThemeChange
'
];
function
parseBaseApp
(
vm
,
{
...
...
packages/uni-mp-weixin/dist/index.js
浏览文件 @
70aaee2b
...
...
@@ -1171,7 +1171,8 @@ const hooks = [
'
onShow
'
,
'
onHide
'
,
'
onError
'
,
'
onPageNotFound
'
'
onPageNotFound
'
,
'
onThemeChange
'
];
function
parseBaseApp
(
vm
,
{
...
...
packages/uni-mp-weixin/lib/uni.config.js
浏览文件 @
70aaee2b
...
...
@@ -17,10 +17,12 @@ module.exports = {
},
filterTag
:
'
wxs
'
,
project
:
'
project.config.json
'
,
subPackages
:
true
subPackages
:
true
,
darkmode
:
true
},
copyWebpackOptions
(
platformOptions
,
vueOptions
)
{
const
copyOptions
=
[
'
theme.json
'
,
'
sitemap.json
'
,
'
ext.json
'
,
'
custom-tab-bar
'
...
...
packages/uni-quickapp-webview/dist/index.js
浏览文件 @
70aaee2b
...
...
@@ -1156,7 +1156,8 @@ const hooks = [
'
onShow
'
,
'
onHide
'
,
'
onError
'
,
'
onPageNotFound
'
'
onPageNotFound
'
,
'
onThemeChange
'
];
function
parseBaseApp
(
vm
,
{
...
...
packages/vue-cli-plugin-uni/packages/mp-vue/dist/mp.runtime.esm.js
浏览文件 @
70aaee2b
...
...
@@ -5952,6 +5952,8 @@ var LIFECYCLE_HOOKS$1 = [
'
onShow
'
,
'
onHide
'
,
'
onUniNViewMessage
'
,
'
onPageNotFound
'
,
'
onThemeChange
'
,
'
onError
'
,
//Page
'
onLoad
'
,
...
...
packages/webpack-uni-pages-loader/lib/index-new.js
浏览文件 @
70aaee2b
...
...
@@ -16,6 +16,11 @@ const {
updateProjectJson
}
=
require
(
'
@dcloudio/uni-cli-shared/lib/cache
'
)
const
{
initTheme
,
parseTheme
}
=
require
(
'
@dcloudio/uni-cli-shared/lib/theme
'
)
const
{
// pagesJsonJsFileName,
initAutoImportComponents
...
...
@@ -35,6 +40,8 @@ function renameUsingComponents (jsonObj) {
module
.
exports
=
function
(
content
,
map
)
{
this
.
cacheable
&&
this
.
cacheable
()
initTheme
()
let
isAppView
=
false
if
(
this
.
resourceQuery
)
{
const
params
=
loaderUtils
.
parseQuery
(
this
.
resourceQuery
)
...
...
@@ -48,13 +55,18 @@ module.exports = function (content, map) {
// this.addDependency(pagesJsonJsPath)
this
.
addDependency
(
manifestJsonPath
)
cons
t
pagesJson
=
parsePagesJson
(
content
,
{
le
t
pagesJson
=
parsePagesJson
(
content
,
{
addDependency
:
(
file
)
=>
{
(
process
.
UNI_PAGES_DEPS
||
(
process
.
UNI_PAGES_DEPS
=
new
Set
())).
add
(
normalizePath
(
file
))
this
.
addDependency
(
file
)
}
})
if
(
global
.
uniPlugin
.
defaultTheme
)
{
pagesJson
=
parseTheme
(
pagesJson
)
this
.
addDependency
(
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
'
theme.json
'
))
}
// 组件自动导入配置
process
.
UNI_AUTO_SCAN_COMPONENTS
=
!
(
pagesJson
.
easycom
&&
pagesJson
.
easycom
.
autoscan
===
false
)
initAutoImportComponents
(
pagesJson
.
easycom
)
...
...
packages/webpack-uni-pages-loader/lib/platforms/mp.js
浏览文件 @
70aaee2b
...
...
@@ -12,6 +12,11 @@ const {
updateAppJsonUsingComponents
}
=
require
(
'
@dcloudio/uni-cli-shared/lib/cache
'
)
const
{
darkmode
,
hasTheme
}
=
require
(
'
@dcloudio/uni-cli-shared/lib/theme
'
)
const
{
hasOwn
,
parseStyle
...
...
@@ -208,6 +213,11 @@ module.exports = function (pagesJson, manifestJson, project = {}) {
updateAppJsonUsingComponents
(
app
.
usingComponents
)
}
if
(
darkmode
()
&&
hasTheme
())
{
app
.
darkmode
=
true
app
.
themeLocation
=
'
theme.json
'
}
const
projectName
=
getPlatformProject
()
const
projectPath
=
projectName
&&
path
.
resolve
(
process
.
env
.
VUE_CLI_CONTEXT
||
process
.
cwd
(),
projectName
)
...
...
packages/webpack-uni-pages-loader/lib/util.js
浏览文件 @
70aaee2b
...
...
@@ -74,7 +74,13 @@ function parseStyle (style = {}, root = '') {
return
Object
.
assign
(
windowOptions
,
platformStyle
)
}
if
(
style
.
navigationBarTextStyle
&&
style
.
navigationBarTextStyle
!==
'
black
'
)
{
if
(
style
.
navigationBarTextStyle
&&
(
style
.
navigationBarTextStyle
!==
'
black
'
&&
style
.
navigationBarTextStyle
.
indexOf
(
'
@
'
)
!==
0
)
)
{
style
.
navigationBarTextStyle
=
'
white
'
}
...
...
src/core/service/plugins/lifecycle.js
浏览文件 @
70aaee2b
...
...
@@ -7,6 +7,7 @@ const LIFECYCLE_HOOKS = [
'
onHide
'
,
'
onUniNViewMessage
'
,
'
onPageNotFound
'
,
'
onThemeChange
'
,
'
onError
'
,
// Page
'
onLoad
'
,
...
...
src/platforms/mp-weixin/runtime/wrapper/app-base-parser.js
浏览文件 @
70aaee2b
...
...
@@ -9,7 +9,8 @@ const hooks = [
'
onShow
'
,
'
onHide
'
,
'
onError
'
,
'
onPageNotFound
'
'
onPageNotFound
'
,
'
onThemeChange
'
]
export
default
function
parseBaseApp
(
vm
,
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录