Skip to content

Commit

Permalink
feat: dark mode
Browse files Browse the repository at this point in the history
  • Loading branch information
yangmingshan committed May 26, 2024
1 parent 0d89a56 commit 9fd1561
Show file tree
Hide file tree
Showing 17 changed files with 56 additions and 11 deletions.
9 changes: 8 additions & 1 deletion template/base/src/app.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
page {
color: #333;
color: #181818;
font-size: 28px;
font-family:
ui-sans-serif,
Expand All @@ -9,3 +9,10 @@ page {
sans-serif;
background: #fff;
}

@media (prefers-color-scheme: dark) {
page {
color: #fff;
background: #181818;
}
}
26 changes: 16 additions & 10 deletions template/base/src/app.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
{
"darkmode": true,
"themeLocation": "theme.json",
"pages": ["pages/home/index", "pages/mine/index"],
"window": {
"navigationBarBackgroundColor": "#ffffff",
"navigationBarTextStyle": "black",
"navigationBarTitleText": "vue-mini-project"
"navigationBarBackgroundColor": "@bgColor",
"navigationBarTextStyle": "@style",
"navigationBarTitleText": "vue-mini-project",
"backgroundColor": "@bgColor",
"backgroundColorTop": "@bgColor",
"backgroundColorBottom": "@bgColor"
},
"tabBar": {
"color": "#000",
"selectedColor": "#000",
"backgroundColor": "#ffffff",
"color": "@color",
"selectedColor": "@color",
"backgroundColor": "@bgColor",
"borderStyle": "@style",
"list": [
{
"text": "主页",
"pagePath": "pages/home/index",
"iconPath": "/images/home.png",
"selectedIconPath": "/images/home-selected.png"
"iconPath": "@homeIcon",
"selectedIconPath": "@homeSelectedIcon"
},
{
"text": "",
"pagePath": "pages/mine/index",
"iconPath": "/images/mine.png",
"selectedIconPath": "/images/mine-selected.png"
"iconPath": "@mineIcon",
"selectedIconPath": "@mineSelectedIcon"
}
]
},
Expand Down
Binary file added template/base/src/images/home-dark-selected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added template/base/src/images/home-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added template/base/src/images/home-light-selected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added template/base/src/images/home-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed template/base/src/images/home-selected.png
Binary file not shown.
Binary file removed template/base/src/images/home.png
Binary file not shown.
Binary file added template/base/src/images/mine-dark-selected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added template/base/src/images/mine-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added template/base/src/images/mine-light-selected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added template/base/src/images/mine-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed template/base/src/images/mine-selected.png
Binary file not shown.
Binary file removed template/base/src/images/mine.png
Binary file not shown.
6 changes: 6 additions & 0 deletions template/base/src/pages/home/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@
font-size: 64px;
font-weight: bold;
}

@media (prefers-color-scheme: dark) {
.greeting {
color: #fff;
}
}
6 changes: 6 additions & 0 deletions template/base/src/pages/mine/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@
font-size: 64px;
font-weight: bold;
}

@media (prefers-color-scheme: dark) {
.greeting {
color: #fff;
}
}
20 changes: 20 additions & 0 deletions template/base/src/theme.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"light": {
"style": "black",
"color": "#181818",
"bgColor": "#ffffff",
"homeIcon": "/assets/home-light.png",
"homeSelectedIcon": "/assets/home-light-selected.png",
"mineIcon": "/assets/mine-light.png",
"mineSelectedIcon": "/assets/mine-light-selected.png"
},
"dark": {
"style": "white",
"color": "#ffffff",
"bgColor": "#181818",
"homeIcon": "/assets/home-dark.png",
"homeSelectedIcon": "/assets/home-dark-selected.png",
"mineIcon": "/assets/mine-dark.png",
"mineSelectedIcon": "/assets/mine-dark-selected.png"
}
}

0 comments on commit 9fd1561

Please sign in to comment.