Skip to content

Commit

Permalink
主题风格配色
Browse files Browse the repository at this point in the history
  • Loading branch information
Junvary committed Nov 4, 2022
1 parent a79091e commit 36575dd
Show file tree
Hide file tree
Showing 36 changed files with 577 additions and 514 deletions.
29 changes: 29 additions & 0 deletions GQA-FRONTEND/public/icon/ant-design-vue.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions GQA-FRONTEND/public/icon/element-plus.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions GQA-FRONTEND/src/boot/permission.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { boot } from 'quasar/wrappers'
import { LoadingBar, Loading, QSpinnerGears } from 'quasar'
import { useUserStore } from 'src/stores/user'
import { usePermissionStore } from 'src/stores/permission'
import useCommon from 'src/composables/useCommon'
import useConfig from 'src/composables/useConfig'

import { i18n } from './i18n'

LoadingBar.setDefaults({
Expand Down Expand Up @@ -30,7 +31,7 @@ export default boot(({ router, store }) => {
const permissionStore = usePermissionStore()
startLoading()
const token = userStore.GetToken()
const { AllowList } = useCommon()
const { AllowList } = useConfig()
if (token) {
if (AllowList.indexOf(to.path) !== -1) {
next({ path: '/' })
Expand Down
21 changes: 12 additions & 9 deletions GQA-FRONTEND/src/boot/theme.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import { boot } from 'quasar/wrappers'
import { Cookies, setCssVar, getCssVar } from 'quasar'
import useConfig from 'src/composables/useConfig'

const { ThemeStyleQuasar } = useConfig()

export default boot(({ app }) => {
const primary = Cookies.get('gqa-theme-primary') || getCssVar('primary') || '#1976D2'
const secondary = Cookies.get('gqa-theme-secondary') || getCssVar('secondary') || '#26A69A'
const accent = Cookies.get('gqa-theme-accent') || getCssVar('accent') || '#9C27B0'
const positive = Cookies.get('gqa-theme-positive') || getCssVar('positive') || '#21BA45'
const negative = Cookies.get('gqa-theme-negative') || getCssVar('negative') || '#C10015'
const info = Cookies.get('gqa-theme-info') || getCssVar('info') || '#31CCEC'
const warning = Cookies.get('gqa-theme-warning') || getCssVar('warning') || '#F2C037'
const light = Cookies.get('gqa-theme-light') || getCssVar('light') || '#FFFFFF'
const dark = Cookies.get('gqa-theme-dark') || getCssVar('dark') || '#1D1D1D'
const primary = Cookies.get('gqa-theme-primary') || getCssVar('primary') || ThemeStyleQuasar.primary
const secondary = Cookies.get('gqa-theme-secondary') || getCssVar('secondary') || ThemeStyleQuasar.secondary
const accent = Cookies.get('gqa-theme-accent') || getCssVar('accent') || ThemeStyleQuasar.accent
const positive = Cookies.get('gqa-theme-positive') || getCssVar('positive') || ThemeStyleQuasar.positive
const negative = Cookies.get('gqa-theme-negative') || getCssVar('negative') || ThemeStyleQuasar.negative
const info = Cookies.get('gqa-theme-info') || getCssVar('info') || ThemeStyleQuasar.info
const warning = Cookies.get('gqa-theme-warning') || getCssVar('warning') || ThemeStyleQuasar.warning
const light = Cookies.get('gqa-theme-light') || getCssVar('light') || ThemeStyleQuasar.light
const dark = Cookies.get('gqa-theme-dark') || getCssVar('dark') || ThemeStyleQuasar.dark

setCssVar("primary", primary)
setCssVar("secondary", secondary)
Expand Down
5 changes: 2 additions & 3 deletions GQA-FRONTEND/src/components/GqaAvatar/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@

<script setup>
import { computed, toRefs } from 'vue';
// import { GqaDefaultAvatar } from 'src/settings'
import { useQuasar } from 'quasar';
import useCommon from 'src/composables/useCommon';
import useConfig from 'src/composables/useConfig';
const { GqaDefaultAvatar } = useCommon()
const { GqaDefaultAvatar } = useConfig()
const $q = useQuasar();
const props = defineProps({
loginUser: {
Expand Down
4 changes: 2 additions & 2 deletions GQA-FRONTEND/src/components/GqaEditor/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
</template>

<script setup>
import useDarkTheme from 'src/composables/useDarkTheme';
import useTheme from 'src/composables/useTheme';
import { ref, watch } from 'vue';
import { useQuasar } from 'quasar';
const $q = useQuasar();
const { darkTheme } = useDarkTheme()
const { darkTheme } = useTheme()
const foreColor = ref('#000000');
const backColor = ref('#ffffff');
Expand Down
5 changes: 2 additions & 3 deletions GQA-FRONTEND/src/components/GqaShowName/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@

<script setup>
import { useQuasar } from 'quasar';
// import { GqaDefaultUsername } from 'src/settings'
import { computed, toRefs } from 'vue';
import useCommon from 'src/composables/useCommon';
import useConfig from 'src/composables/useConfig';
const { GqaDefaultUsername } = useCommon()
const { GqaDefaultUsername } = useConfig()
const $q = useQuasar()
const props = defineProps({
customNameString: {
Expand Down
201 changes: 201 additions & 0 deletions GQA-FRONTEND/src/components/GqaTheme/GqaThemeColor.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
<template>
<div>
<q-field label-slot stack-label>
<template v-slot:label>
<span :style="{ color: primary }">
{{ $t('Theme') + $t('Color') }}
</span>
<span>
primary: {{ primary }}
</span>
</template>
<template v-slot:control>
<div class="q-gutter-md q-ma-none">
<q-avatar round v-for="(item, index) in colorList" :key="index"
:size="primary === item ? 'md' : 'xs'" :style="{ border: '1px solid grey', background: item }"
class="cursor" @click="setBrand('primary', item)" />
</div>
</template>
</q-field>
<q-field label-slot stack-label>
<template v-slot:label>
<span :style="{ color: secondary }">
{{ $t('Theme') + $t('Color') }}
</span>
<span>
secondary: {{ secondary }}
</span>
</template>
<template v-slot:control>
<div class="q-gutter-md q-ma-none">
<q-avatar round v-for="(item, index) in colorList" :key="index"
:size="secondary === item ? 'md' : 'xs'" :style="{ border: '1px solid grey', background: item }"
class="cursor" @click="setBrand('secondary', item)" />
</div>
</template>
</q-field>
<q-field label-slot stack-label>
<template v-slot:label>
<span :style="{ color: accent }">
{{ $t('Theme') + $t('Color') }}
</span>
<span>
accent: {{ accent }}
</span>
</template>
<template v-slot:control>
<div class="q-gutter-md q-ma-none">
<q-avatar round v-for="(item, index) in colorList" :key="index"
:size="accent === item ? 'md' : 'xs'" :style="{ border: '1px solid grey', background: item }"
class="cursor" @click="setBrand('accent', item)" />
</div>
</template>
</q-field>
<q-field label-slot stack-label>
<template v-slot:label>
<span :style="{ color: positive }">
{{ $t('Theme') + $t('Color') }}
</span>
<span>
positive: {{ positive }}
</span>
</template>
<template v-slot:control>
<div class="q-gutter-md q-ma-none">
<q-avatar round v-for="(item, index) in colorList" :key="index"
:size="positive === item ? 'md' : 'xs'" :style="{ border: '1px solid grey', background: item }"
class="cursor" @click="setBrand('positive', item)" />
</div>
</template>
</q-field>
<q-field label-slot stack-label>
<template v-slot:label>
<span :style="{ color: negative }">
{{ $t('Theme') + $t('Color') }}
</span>
<span>
negative: {{ negative }}
</span>
</template>
<template v-slot:control>
<div class="q-gutter-md q-ma-none">
<q-avatar round v-for="(item, index) in colorList" :key="index"
:size="negative === item ? 'md' : 'xs'" :style="{ border: '1px solid grey', background: item }"
class="cursor" @click="setBrand('negative', item)" />
</div>
</template>
</q-field>
<q-field label-slot stack-label>
<template v-slot:label>
<span :style="{ color: info }">
{{ $t('Theme') + $t('Color') }}
</span>
<span>
info: {{ info }}
</span>
</template>
<template v-slot:control>
<div class="q-gutter-md q-ma-none">
<q-avatar round v-for="(item, index) in colorList" :key="index" :size="info === item ? 'md' : 'xs'"
:style="{ border: '1px solid grey', background: item }" class="cursor"
@click="setBrand('info', item)" />
</div>
</template>
</q-field>
<q-field label-slot stack-label>
<template v-slot:label>
<span :style="{ color: warning }">
{{ $t('Theme') + $t('Color') }}
</span>
<span>
warning: {{ warning }}
</span>
</template>
<template v-slot:control>
<div class="q-gutter-md q-ma-none">
<q-avatar round v-for="(item, index) in colorList" :key="index"
:size="warning === item ? 'md' : 'xs'" :style="{ border: '1px solid grey', background: item }"
class="cursor" @click="setBrand('warning', item)" />
</div>
</template>
</q-field>
<q-field label-slot stack-label>
<template v-slot:label>
<span :style="{ color: light }">
{{ $t('Theme') + $t('Color') }}
</span>
<span>
light: {{ light }}
</span>
</template>
<template v-slot:control>
<div class="q-gutter-md q-ma-none">
<q-avatar round v-for="(item, index) in colorList" :key="index" :size="light === item ? 'md' : 'xs'"
:style="{ border: '1px solid grey', background: item }" class="cursor"
@click="setBrand('light', item)" />
</div>
</template>
</q-field>
<q-field label-slot stack-label>
<template v-slot:label>
<span :style="{ color: dark }">
{{ $t('Theme') + $t('Color') }}
</span>
<span>
dark: {{ dark }}
</span>
</template>
<template v-slot:control>
<div class="q-gutter-md q-ma-none">
<q-avatar round v-for="(item, index) in colorList" :key="index" :size="dark === item ? 'md' : 'xs'"
:style="{ border: '1px solid grey', background: item }" class="cursor"
@click="setBrand('dark', item)" />
</div>
</template>
</q-field>
</div>
</template>

<script setup>
import { computed, ref } from 'vue';
import { setCssVar, getCssVar, Cookies } from 'quasar';
import useConfig from 'src/composables/useConfig';
const { ThemeStyleQuasar, ThemeStyleElement, ThemeStyleAnt } = useConfig()
const colorList = computed(() => {
const cl = []
for (let q in ThemeStyleQuasar) {
cl.push(ThemeStyleQuasar[q])
}
for (let e in ThemeStyleElement) {
cl.push(ThemeStyleElement[e])
}
for (let a in ThemeStyleAnt) {
cl.push(ThemeStyleAnt[a])
}
return [...new Set(cl)]
})
const primary = ref(Cookies.get('gqa-theme-primary') || getCssVar('primary'));
const secondary = ref(Cookies.get('gqa-theme-secondary') || getCssVar('secondary'));
const accent = ref(Cookies.get('gqa-theme-accent') || getCssVar('accent'));
const positive = ref(Cookies.get('gqa-theme-positive') || getCssVar('positive'));
const negative = ref(Cookies.get('gqa-theme-negative') || getCssVar('negative'));
const info = ref(Cookies.get('gqa-theme-info') || getCssVar('info'));
const warning = ref(Cookies.get('gqa-theme-warning') || getCssVar('warning'));
const dark = ref(Cookies.get('gqa-theme-dark') || getCssVar('dark'));
const light = ref(Cookies.get('gqa-theme-light') || getCssVar('light'));
const setBrand = (type, color) => {
Cookies.set('gqa-theme-' + type, color)
setCssVar(type, color)
eval(type).value = color;
}
</script>

<style lang="scss" scoped>
.cursor {
cursor: pointer;
}
</style>
Loading

0 comments on commit 36575dd

Please sign in to comment.