|
@@ -28,13 +28,13 @@
|
|
|
<span>个人中心</span>
|
|
|
<q-menu>
|
|
|
<q-list>
|
|
|
- <q-item clickable @click="onSwitchTheme">
|
|
|
+ <q-item clickable @click="state.showColor = true">
|
|
|
<q-item-section>切换主题</q-item-section>
|
|
|
</q-item>
|
|
|
<q-item clickable v-close-popup>
|
|
|
- <q-item-section @click="state.showInfo = true"
|
|
|
- >个人信息</q-item-section
|
|
|
- >
|
|
|
+ <q-item-section @click="state.showInfo = true">
|
|
|
+ 个人信息
|
|
|
+ </q-item-section>
|
|
|
</q-item>
|
|
|
<q-item clickable v-close-popup>
|
|
|
<q-item-section @click="onLogout">退出登录</q-item-section>
|
|
@@ -50,7 +50,15 @@
|
|
|
<q-dialog v-model="state.showInfo">
|
|
|
<q-card style="width: 60%; max-width: 60%">
|
|
|
<q-card-section>
|
|
|
- <div class="text-h6">个人信息</div>
|
|
|
+ <div class="text-h6 flex items-center">
|
|
|
+ 个人信息
|
|
|
+ <SvgIcon
|
|
|
+ name="czr_close"
|
|
|
+ color="#000000"
|
|
|
+ class="ml-auto"
|
|
|
+ @click="state.showInfo = false"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
</q-card-section>
|
|
|
|
|
|
<q-card-section class="q-pt-none">
|
|
@@ -110,11 +118,32 @@
|
|
|
<!-- </div>-->
|
|
|
</div>
|
|
|
</q-card-section>
|
|
|
-
|
|
|
- <q-card-actions align="right" class="text-teal bg-white">
|
|
|
- <!-- <q-btn flat label="确定" v-close-popup />-->
|
|
|
- <q-btn flat label="取消" v-close-popup />
|
|
|
- </q-card-actions>
|
|
|
+ </q-card>
|
|
|
+ </q-dialog>
|
|
|
+ <q-dialog v-model="state.showColor">
|
|
|
+ <q-card style="width: 40%; max-width: 40%">
|
|
|
+ <q-card-section>
|
|
|
+ <div class="text-h6 flex items-center">
|
|
|
+ 切换主题
|
|
|
+ <SvgIcon
|
|
|
+ name="czr_close"
|
|
|
+ color="#000000"
|
|
|
+ class="ml-auto"
|
|
|
+ @click="state.showColor = false"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ </q-card-section>
|
|
|
+ <q-card-section class="q-pt-none">
|
|
|
+ <div class="grid grid-cols-3 gap-4">
|
|
|
+ <template v-for="item in AppStore.colors">
|
|
|
+ <div
|
|
|
+ :style="{ backgroundColor: item }"
|
|
|
+ class="col-span-1 h-20 rounded-xl"
|
|
|
+ @click="onSwitchTheme(item)"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ </div>
|
|
|
+ </q-card-section>
|
|
|
</q-card>
|
|
|
</q-dialog>
|
|
|
</template>
|
|
@@ -125,12 +154,14 @@ import { useRouter } from 'vue-router'
|
|
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
|
|
import { authLogout } from '@/api/modules/global'
|
|
|
import { useAppStore, useDictionaryStore } from '@/stores'
|
|
|
+import { extractRgbFromRgba, hexToOpaqueHex, hexToRgb } from '@/utils/czr-util'
|
|
|
|
|
|
const AppStore = useAppStore()
|
|
|
const DictionaryStore = useDictionaryStore()
|
|
|
const router = useRouter()
|
|
|
const state: any = reactive({
|
|
|
showInfo: false,
|
|
|
+ showColor: false,
|
|
|
avatar: '',
|
|
|
})
|
|
|
const infoCpt = computed(() => {
|
|
@@ -147,44 +178,23 @@ const infoCpt = computed(() => {
|
|
|
const menusCpt = computed(() => {
|
|
|
return router.getRoutes().filter((v) => v.meta?.isMenu)
|
|
|
})
|
|
|
-const rgbs = [
|
|
|
- { main: '239, 87, 16', sub: '239, 87, 16' },
|
|
|
- { main: '175, 221, 224', sub: '86, 85, 154' },
|
|
|
- { main: '117, 41, 46', sub: '248, 198, 181' },
|
|
|
- { main: '193, 226, 207', sub: '165, 93, 81' },
|
|
|
- { main: '253, 216, 118', sub: '191, 209, 178' },
|
|
|
- { main: '181, 144, 107', sub: '229, 168, 75' },
|
|
|
-]
|
|
|
-const onSwitchTheme = () => {
|
|
|
- const rgb = getComputedStyle(document.documentElement).getPropertyValue(
|
|
|
- '--czr-main-color-rgb',
|
|
|
+const onSwitchTheme = (color) => {
|
|
|
+ const rgb_: string = extractRgbFromRgba(hexToRgb(color)).join(',')
|
|
|
+ const rgbSub_ = rgb_
|
|
|
+ document.documentElement.style.setProperty(
|
|
|
+ '--czr-main-color',
|
|
|
+ `rgba(${rgb_}, 1)`,
|
|
|
)
|
|
|
- const handle = (index) => {
|
|
|
- const rgb_ = rgbs[index].main
|
|
|
- const rgbSub_ = rgbs[index].main
|
|
|
- document.documentElement.style.setProperty(
|
|
|
- '--czr-main-color',
|
|
|
- `rgba(${rgb_}, 1)`,
|
|
|
- )
|
|
|
- document.documentElement.style.setProperty('--czr-main-color-rgb', rgb_)
|
|
|
- document.documentElement.style.setProperty(
|
|
|
- '--czr-main-sub-color',
|
|
|
- `rgba(${rgbSub_}, 1)`,
|
|
|
- )
|
|
|
- document.documentElement.style.setProperty(
|
|
|
- '--czr-main-sub-color-rgb',
|
|
|
- rgbSub_,
|
|
|
- )
|
|
|
- }
|
|
|
- for (let i = 0; i < rgbs.length; i++) {
|
|
|
- if (rgb === rgbs[i].main) {
|
|
|
- if (i + 1 < rgbs.length) {
|
|
|
- handle(i + 1)
|
|
|
- } else {
|
|
|
- handle(0)
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ document.documentElement.style.setProperty('--czr-main-color-rgb', rgb_)
|
|
|
+ document.documentElement.style.setProperty(
|
|
|
+ '--czr-main-sub-color',
|
|
|
+ `rgba(${rgbSub_}, 1)`,
|
|
|
+ )
|
|
|
+ document.documentElement.style.setProperty(
|
|
|
+ '--czr-main-sub-color-rgb',
|
|
|
+ rgbSub_,
|
|
|
+ )
|
|
|
+ localStorage.setItem('themeMainColor', rgb_)
|
|
|
}
|
|
|
const handleAvatarSuccess = (response, uploadFile) => {
|
|
|
state.avatar = URL.createObjectURL(uploadFile.raw!)
|