Skip to content

Commit

Permalink
Merge pull request #39 from ximo-156/main-min
Browse files Browse the repository at this point in the history
feat: 增加黑暗主题
  • Loading branch information
codercup authored Mar 28, 2024
2 parents 81a5017 + a67c786 commit 1527e69
Show file tree
Hide file tree
Showing 17 changed files with 105 additions and 19 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,6 @@
"uvui",
"WechatMiniprogram"
],
"typescript.tsdk": "node_modules\\typescript\\lib"
"typescript.tsdk": "node_modules\\typescript\\lib",
"i18n-ally.localesPaths": ["src/locale"]
}
16 changes: 15 additions & 1 deletion manifest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,21 @@ export default defineManifestConfig({
autoclose: true,
delay: 0,
},
safearea: {
// iOS平台的安全区域
background: '@bgColorBottom',
backgroundDark: '#2f0508', // HX 3.1.19+支持
bottom: {
offset: 'auto',
},
},
/* 模块配置 */
modules: {},
/* 应用发布信息 */
distribute: {
/* android打包配置 */
android: {
darkmode: true, // 暗黑模式
minSdkVersion: 30,
targetSdkVersion: 30,
abiFilters: ['armeabi-v7a', 'arm64-v8a'],
Expand All @@ -67,7 +76,9 @@ export default defineManifestConfig({
],
},
/* ios打包配置 */
ios: {},
ios: {
darkmode: true, // 暗黑模式
},
/* SDK配置 */
sdkConfigs: {},
/* 图标配置 */
Expand All @@ -81,14 +92,17 @@ export default defineManifestConfig({
quickapp: {},
/* 小程序特有相关 */
'mp-weixin': {
darkmode: true, // 暗黑模式
appid: VITE_WX_APPID,
setting: {
urlCheck: false,
},
usingComponents: true,
// __usePrivacyCheck__: true,
},
// 支付宝小程序配置
'mp-alipay': {
// darkmode: true, // 暗黑模式
usingComponents: true,
},
'mp-baidu': {
Expand Down
28 changes: 15 additions & 13 deletions pages.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,42 @@ export default defineUniPages({
globalStyle: {
navigationStyle: 'default',
navigationBarTitleText: 'unibest',
navigationBarBackgroundColor: '#f8f8f8',
navigationBarTextStyle: 'black',
backgroundColor: '#FFFFFF',
navigationBarBackgroundColor: '@navBgColor',
navigationBarTextStyle: '@navTxtStyle',
backgroundColor: '@bgColor',
backgroundTextStyle: '@bgTxtStyle',
backgroundColorTop: '@bgColorTop',
backgroundColorBottom: '@bgColorBottom',
h5: {
navigationStyle: 'custom',
},
},
easycom: {
autoscan: true,
custom: {
'^uni-(.*)': '@dcloudio/uni-ui/lib/uni-$1/uni-$1.vue',
'^uv-(.*)': '@climblee/uv-ui/components/uv-$1/uv-$1.vue',
'^wd-(.*)': 'wot-design-uni/components/wd-$1/wd-$1.vue',
},
},
tabBar: {
color: '#999999',
selectedColor: '#018d71',
backgroundColor: '#F8F8F8',
borderStyle: 'black',
height: '50px',
fontSize: '10px',
iconWidth: '24px',
iconWidth: '30px',
spacing: '3px',
color: '@tabFontColor',
selectedColor: '@tabSelectedColor',
backgroundColor: '@tabBgColor',
borderStyle: '@tabBorderStyle',
list: [
{
iconPath: 'static/tabbar/home.png',
selectedIconPath: 'static/tabbar/homeHL.png',
iconPath: '@iconPath1',
selectedIconPath: '@selectedIconPath1',
pagePath: 'pages/index/index',
text: '首页',
},
{
iconPath: 'static/tabbar/example.png',
selectedIconPath: 'static/tabbar/exampleHL.png',
iconPath: '@iconPath2',
selectedIconPath: '@selectedIconPath2',
pagePath: 'pages/demo/index',
text: '示例',
},
Expand Down
20 changes: 19 additions & 1 deletion src/layouts/default.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
<template>
<view class="default-layout">
<slot />
<wd-config-provider :theme="theme" :themeVars="themeVars">
<slot />
</wd-config-provider>
</view>
</template>
<script lang="ts" setup>
import type { ConfigProviderThemeVars } from 'wot-design-uni'
const themeVars: ConfigProviderThemeVars = {
// 定制 WOT-UI库的主题色
// colorTheme: '#8053f9',
}
// 获取系统主题色
const theme = ref('dark')
uni.getSystemInfo({
success(res) {
theme.value = res.hostTheme
},
})
</script>

<style lang="scss">
.default-layout {
Expand Down
4 changes: 2 additions & 2 deletions src/pages/demo/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
v-for="(tab, idx) in tabList"
:key="tab.id"
>
<view class="font-800" @click="currIdx = idx">{{ tab.title }}</view>
<view class="font-800 some-text" @click="currIdx = idx">{{ tab.title }}</view>
</view>
</view>
<view class="bg-slate-100 px-4 pt-3">
Expand All @@ -23,7 +23,7 @@
class="flex bg-white items-center justify-between p-3 mb-2"
@click="goDetailPage(item.path)"
>
<text class="flex-1 text-4 text-dark">{{ item.title }}</text>
<text class="flex-1 text-4 some-text">{{ item.title }}</text>
<text class="i-carbon-chevron-right"></text>
</view>
</view>
Expand Down
Binary file added src/static/tabbar/acty-dark-code.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 src/static/tabbar/acty-light-home.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 src/static/tabbar/code-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 removed src/static/tabbar/example.png
Binary file not shown.
Binary file removed src/static/tabbar/exampleHL.png
Binary file not shown.
Binary file removed src/static/tabbar/home.png
Binary file not shown.
Binary file removed src/static/tabbar/homeHL.png
Binary file not shown.
Binary file added src/static/tabbar/light-home.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 src/static/tabbar/personal.png
Binary file not shown.
Binary file removed src/static/tabbar/personalHL.png
Binary file not shown.
19 changes: 18 additions & 1 deletion src/style/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,23 @@
color: red;
}

// 黑暗模式需要用到媒体查询来确定样式
@media (prefers-color-scheme: dark) {
/* DarkMode 下的样式 start */
.bg-white {
background: #1b1b1b;
}

.bg-slate-100 {
background: #1b1b1b;
}

.some-text {
color: #fff;
}
/* DarkMode 下的样式 end */
}

// 全局字体引用 DEMO
// @font-face {
// font-family: TiTi;
Expand All @@ -14,4 +31,4 @@

// .titi {
// font-family: TiTi, Arial, sans-serif;
// }
// }
34 changes: 34 additions & 0 deletions src/theme.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"light": {
"navBgColor": "#f8f8f8",
"navTxtStyle": "black",
"bgColor": "#ffffff",
"bgTxtStyle": "light",
"bgColorTop": "#eeeeee",
"bgColorBottom": "#efefef",
"tabFontColor": "#000000",
"tabSelectedColor": "#3cc51f",
"tabBgColor": "#ffffff",
"tabBorderStyle": "black",
"iconPath1": "/static/tabbar/light-home.png",
"selectedIconPath1": "/static/tabbar/acty-light-home.png",
"iconPath2": "/static/tabbar/code-dark.png",
"selectedIconPath2": "/static/tabbar/acty-dark-code.png"
},
"dark": {
"navBgColor": "#292929",
"navTxtStyle": "white",
"bgColor": "#1f1f1f",
"bgTxtStyle": "dark",
"bgColorTop": "#292929",
"bgColorBottom": "#1f1f1f",
"tabFontColor": "#ffffff",
"tabSelectedColor": "#51a937",
"tabBgColor": "#292929",
"tabBorderStyle": "white",
"iconPath1": "/static/tabbar/light-home.png",
"selectedIconPath1": "/static/tabbar/acty-light-home.png",
"iconPath2": "/static/tabbar/code-dark.png",
"selectedIconPath2": "/static/tabbar/acty-dark-code.png"
}
}

0 comments on commit 1527e69

Please sign in to comment.