From 91757586d38c8facbd610e88966b6ee35b1311b4 Mon Sep 17 00:00:00 2001 From: wally <18603454788@163.com> Date: Mon, 10 Jan 2022 16:35:20 +0800 Subject: [PATCH] feat(theme): theme demo --- App.vue | 32 +++++++++-- CHANGELOG.md | 1 + common/styles/theme/default.scss | 8 +++ common/styles/theme/index.scss | 5 ++ common/styles/theme/test.scss | 8 +++ components/Globals/Globals.vue | 8 ++- components/Theme/Theme.vue | 13 +++++ components/TimeLine/component/Title.vue | 7 --- hooks/theme/useTheme.js | 7 +++ pages.json | 58 ++++++++++---------- pages/project/project.vue | 3 ++ plugins/p-deliver/p-deliver.vue | 9 ++++ plugins/p-task-title/p-task-title.vue | 4 +- store/index.js | 70 ++++++++++++++----------- 14 files changed, 160 insertions(+), 73 deletions(-) create mode 100644 common/styles/theme/default.scss create mode 100644 common/styles/theme/index.scss create mode 100644 common/styles/theme/test.scss create mode 100644 components/Theme/Theme.vue create mode 100644 hooks/theme/useTheme.js create mode 100644 plugins/p-deliver/p-deliver.vue diff --git a/App.vue b/App.vue index 3cffe57..a526b47 100644 --- a/App.vue +++ b/App.vue @@ -1,6 +1,21 @@ diff --git a/components/TimeLine/component/Title.vue b/components/TimeLine/component/Title.vue index fafec0b..e69de29 100644 --- a/components/TimeLine/component/Title.vue +++ b/components/TimeLine/component/Title.vue @@ -1,7 +0,0 @@ - diff --git a/hooks/theme/useTheme.js b/hooks/theme/useTheme.js new file mode 100644 index 0000000..c9ea155 --- /dev/null +++ b/hooks/theme/useTheme.js @@ -0,0 +1,7 @@ +import { computed } from 'vue'; +import { useStore } from 'vuex'; +export default function useTheme() { + const store = useStore(); + const theme = computed(() => store.state.theme); + return theme; +} diff --git a/pages.json b/pages.json index 54acbb8..aefec0e 100644 --- a/pages.json +++ b/pages.json @@ -1,30 +1,32 @@ { - "pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages - { - "path": "pages/index/index", - "style": { - "navigationBarText": "TALL" - } - }, - { - "path": "pages/project/project", - "style": { - "navigationStyle": "custom", - "navigationBarTextStyle": "white" - } - } - ], - "globalStyle": { - "navigationBarTextStyle": "black", - "navigationBarTitleText": "TALL", - "navigationBarBackgroundColor": "#F8F8F8", - "backgroundColor": "#F8F8F8" - }, - "easycom": { - "autoscan": true, - "custom": { - "^u-(.*)": "uview-ui/components/u-$1/u-$1.vue", - "^p-(.*)": "@/plugins/p-$1/p-$1.vue" - } - } + "pages": [ + //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages + { + "path": "pages/index/index", + "style": { + "navigationBarText": "TALL" + } + }, + { + "path": "pages/project/project", + "style": { + "navigationStyle": "custom", + "navigationBarTextStyle": "white" + } + } + ], + "globalStyle": { + "navigationBarTextStyle": "black", + "navigationBarTitleText": "TALL", + "navigationBarBackgroundColor": "#F8F8F8", + "backgroundColor": "#F8F8F8" + }, + "easycom": { + "autoscan": true, + "custom": { + "^u-(.*)": "uview-ui/components/u-$1/u-$1.vue", + "^p-(.*)": "@/plugins/p-$1/p-$1.vue", + "theme": "@/components/Theme/Theme.vue" + } + } } diff --git a/pages/project/project.vue b/pages/project/project.vue index f83fb1e..6337f25 100644 --- a/pages/project/project.vue +++ b/pages/project/project.vue @@ -13,6 +13,9 @@ + + + 测试切换主题 diff --git a/plugins/p-deliver/p-deliver.vue b/plugins/p-deliver/p-deliver.vue new file mode 100644 index 0000000..1e501b0 --- /dev/null +++ b/plugins/p-deliver/p-deliver.vue @@ -0,0 +1,9 @@ + + + + + diff --git a/plugins/p-task-title/p-task-title.vue b/plugins/p-task-title/p-task-title.vue index a66a026..2cf8195 100644 --- a/plugins/p-task-title/p-task-title.vue +++ b/plugins/p-task-title/p-task-title.vue @@ -1,6 +1,8 @@