Browse Source

feat(theme): theme demo

test2
wally 4 years ago
parent
commit
91757586d3
  1. 32
      App.vue
  2. 1
      CHANGELOG.md
  3. 8
      common/styles/theme/default.scss
  4. 5
      common/styles/theme/index.scss
  5. 8
      common/styles/theme/test.scss
  6. 8
      components/Globals/Globals.vue
  7. 13
      components/Theme/Theme.vue
  8. 7
      components/TimeLine/component/Title.vue
  9. 7
      hooks/theme/useTheme.js
  10. 6
      pages.json
  11. 3
      pages/project/project.vue
  12. 9
      plugins/p-deliver/p-deliver.vue
  13. 2
      plugins/p-task-title/p-task-title.vue
  14. 16
      store/index.js

32
App.vue

@ -1,6 +1,21 @@
<script> <script>
// import { mapState } from 'vuex';
export default { export default {
// computed: {
// ...mapState(['theme']),
// },
// watch: {
// theme(newTheme) {
// console.log('newTheme: ', newTheme);
// if (!newTheme) return;
// this.loadTheme();
// },
// },
async onLaunch(options) { async onLaunch(options) {
// this.loadTheme();
console.log('onLaunch options: ', options); console.log('onLaunch options: ', options);
this.checkNetwork(); // this.checkNetwork(); //
this.getSystemInfo(); // this.getSystemInfo(); //
@ -16,6 +31,11 @@ export default {
}, },
methods: { methods: {
// loadTheme() {
// const path = this.theme.replace('-', '/');
// import(`./common/styles/${path}.scss`);
// },
async getToken() { async getToken() {
const { token } = this.$store.state.user; const { token } = this.$store.state.user;
const tokenIsAvailable = this.$store.getters['user/tokenIsAvailable']; const tokenIsAvailable = this.$store.getters['user/tokenIsAvailable'];
@ -63,18 +83,19 @@ export default {
} }
} }
if (this.$store.state.user.token && localToken) { // token if (this.$store.state.user.token && localToken) {
// token
this.$store.commit('user/setToken', localToken); this.$store.commit('user/setToken', localToken);
} }
if (this.$store.state.user.tokenExpiredTime && tokenExpiredTime) { // tokenExpiredTime if (this.$store.state.user.tokenExpiredTime && tokenExpiredTime) {
// tokenExpiredTime
this.$store.commit('user/setTokenExpiredTime', +tokenExpiredTime); this.$store.commit('user/setTokenExpiredTime', +tokenExpiredTime);
} }
resolve(); resolve();
} catch (error) { } catch (error) {
reject(error); reject(error);
} }
});
})
}, },
// store // store
@ -136,10 +157,11 @@ export default {
<style lang="scss"> <style lang="scss">
/*每个页面公共css */ /*每个页面公共css */
@import "@/uni_modules/vk-uview-ui/index.scss"; @import '@/uni_modules/vk-uview-ui/index.scss';
@import '@/common/styles/iconfont.scss'; @import '@/common/styles/iconfont.scss';
@import '@/common/styles/app.scss'; @import '@/common/styles/app.scss';
@import '@/common/styles/tailwind.scss'; @import '@/common/styles/tailwind.scss';
@import '@/common/styles/theme/index.scss';
page { page {
height: 100%; height: 100%;

1
CHANGELOG.md

@ -29,6 +29,7 @@
范围|描述|commitId 范围|描述|commitId
--|--|-- --|--|--
app.vue | 修复获取token报错的问题 | [9120d54](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/9120d54) app.vue | 修复获取token报错的问题 | [9120d54](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/9120d54)
createTask | 修复createTask v-model的问题 | [b20d3f0](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/b20d3f0)
- | 修复一些内容 | [3cdb1ce](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/3cdb1ce) - | 修复一些内容 | [3cdb1ce](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/3cdb1ce)

8
common/styles/theme/default.scss

@ -0,0 +1,8 @@
// 默认主题文件
.theme-default {
background-color: #333;
.u-card {
font-size: 24px !important;
color: #0f0;
}
}

5
common/styles/theme/index.scss

@ -0,0 +1,5 @@
// 整合所有主题
// 默认主题
@import './default.scss';
@import './test.scss';

8
common/styles/theme/test.scss

@ -0,0 +1,8 @@
// TODO: 测试用的scss主题样式
.theme-test {
background-color: #fff;
.u-card {
font-size: 24px !important;
background-color: #ff0 !important;
}
}

8
components/Globals/Globals.vue

@ -1,5 +1,5 @@
<template> <template>
<view class="m-2" > <theme class="m-2" >
<u-card <u-card
@click="openCard" @click="openCard"
:show-foot="false" :show-foot="false"
@ -7,6 +7,7 @@
:style="{ 'max-height': globalsHeight + 'px' }" :style="{ 'max-height': globalsHeight + 'px' }"
border-radius="25" border-radius="25"
margin="0" margin="0"
class="global-container"
> >
<template v-slot:body> <template v-slot:body>
<scroll-view :scrollY="true" :style="{ 'max-height': globalsHeight - 30 + 'px' }"> <scroll-view :scrollY="true" :style="{ 'max-height': globalsHeight - 30 + 'px' }">
@ -31,13 +32,16 @@
</view> </view>
</template> </template>
<!-- 任务名插件 -->
<p-task-title :task="item" v-else /> <p-task-title :task="item" v-else />
<!-- 交付物插件 -->
<p-deliver></p-deliver>
</view> </view>
</view> </view>
</scroll-view> </scroll-view>
</template> </template>
</u-card> </u-card>
</view> </theme>
</template> </template>
<script setup> <script setup>

13
components/Theme/Theme.vue

@ -0,0 +1,13 @@
<template>
<view :class="[theme]">
<slot></slot>
</view>
</template>
<script setup>
import { computed } from 'vue';
import { useStore } from 'vuex';
const store = useStore();
const theme = computed(() => store.state.theme);
</script>

7
components/TimeLine/component/Title.vue

@ -1,7 +0,0 @@
<!--
* @Author: aBin
* @email: binbin0314@126.com
* @Date: 2021-07-19 15:40:02
* @LastEditors: aBin
* @LastEditTime: 2021-07-19 15:40:03
-->

7
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;
}

6
pages.json

@ -1,5 +1,6 @@
{ {
"pages": [ //pageshttps://uniapp.dcloud.io/collocation/pages "pages": [
//pageshttps://uniapp.dcloud.io/collocation/pages
{ {
"path": "pages/index/index", "path": "pages/index/index",
"style": { "style": {
@ -24,7 +25,8 @@
"autoscan": true, "autoscan": true,
"custom": { "custom": {
"^u-(.*)": "uview-ui/components/u-$1/u-$1.vue", "^u-(.*)": "uview-ui/components/u-$1/u-$1.vue",
"^p-(.*)": "@/plugins/p-$1/p-$1.vue" "^p-(.*)": "@/plugins/p-$1/p-$1.vue",
"theme": "@/components/Theme/Theme.vue"
} }
} }
} }

3
pages/project/project.vue

@ -13,6 +13,9 @@
<!-- 定期任务面板 --> <!-- 定期任务面板 -->
<!-- <TimeLine @getTasks="getTasks" class="flex-1 overflow-hidden" ref="timeLine" /> --> <!-- <TimeLine @getTasks="getTasks" class="flex-1 overflow-hidden" ref="timeLine" /> -->
<TimeLine class="flex-1 overflow-hidden" ref="timeLine" /> <TimeLine class="flex-1 overflow-hidden" ref="timeLine" />
<!-- TODO: DEBUG: -->
<u-button @click="$store.commit('setTheme', 'theme-test')">测试切换主题</u-button>
</view> </view>
</view> </view>
</template> </template>

9
plugins/p-deliver/p-deliver.vue

@ -0,0 +1,9 @@
<template>
<view class="deliver-container">p-deliver</view>
</template>
<script setup>
</script>
<style lang="scss"></style>

2
plugins/p-task-title/p-task-title.vue

@ -1,6 +1,8 @@
<template> <template>
<!-- 任务名插件 --> <!-- 任务名插件 -->
<theme>
<view>{{ task.name }}</view> <view>{{ task.name }}</view>
</theme>
</template> </template>
<script setup> <script setup>

16
store/index.js

@ -1,12 +1,13 @@
import { createStore } from 'vuex'; import { createStore } from 'vuex';
import user from './user/index.js';
import socket from './socket/index.js';
import project from './project/index.js'; import project from './project/index.js';
import role from './role/index.js'; import role from './role/index.js';
import socket from './socket/index.js';
import task from './task/index.js'; import task from './task/index.js';
import user from './user/index.js';
// 不属于具体模块的 应用级的 store内容 // 不属于具体模块的 应用级的 store内容
const state = { const state = {
theme: 'theme-default',
networkConnected: true, // 网络是否连接 networkConnected: true, // 网络是否连接
forceUseStorage: true, // 强制启用storage forceUseStorage: true, // 强制启用storage
systemInfo: null, // 系统设备信息 systemInfo: null, // 系统设备信息
@ -38,11 +39,20 @@ const mutations = {
setSystemInfo(state, data) { setSystemInfo(state, data) {
state.systemInfo = data; state.systemInfo = data;
}, },
/**
* 设置主题
* @param {object} state
* @param {string} theme 主题名称 默认theme-default
*/
setTheme(state, theme) {
state.theme = theme || 'theme-default';
},
}; };
export default createStore({ export default createStore({
state, state,
getters, getters,
mutations, mutations,
modules: {user, socket, project, role, task} modules: { user, socket, project, role, task },
}); });

Loading…
Cancel
Save