|
@@ -1,21 +1,200 @@
|
|
|
<template>
|
|
|
- 111
|
|
|
+ <HcCard>
|
|
|
+ <div class="text-lg font-medium mb-4">主题模式<span class="text-sm text-slate-400 font-light ml-4">深色模式还未适配,暂不推荐使用深色模式</span></div>
|
|
|
+ <div class="hc-theme-box mb-8">
|
|
|
+ <el-radio-group v-model="UserTheme" @change="ThemeTabsUpdate">
|
|
|
+ <template v-for="item in ThemeDatas">
|
|
|
+ <div class="item" :class="UserTheme === item?.key ? 'active' : ''">
|
|
|
+ <div class="demo" :class="item?.key">
|
|
|
+ <img :src="ImgTheme" alt="">
|
|
|
+ </div>
|
|
|
+ <div class="action" @click="ThemeConfigClick(item)">
|
|
|
+ <el-radio :label="item?.key" size="large" class="size-xl">{{item?.name}}</el-radio>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-radio-group>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="text-lg font-medium mb-4">主题色</div>
|
|
|
+ <div class="hc-theme-box color-box mb-4">
|
|
|
+ <template v-for="(item,index) in ColorConfigData">
|
|
|
+ <div class="item" :class="UserColorNmae === item.name ? 'active' : ''" v-if="index < 5">
|
|
|
+ <div class="demo" :class="`bg-${item.name}`">
|
|
|
+ <img :src="ImgColor" alt="">
|
|
|
+ </div>
|
|
|
+ <div class="action" @click="ColorConfigClick(item)">
|
|
|
+ <el-radio v-model="UserColorNmae" :label="item?.name" size="large" class="size-xl">{{item?.label}}</el-radio>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </div>
|
|
|
+ <div class="hc-theme-box color-box mb-8">
|
|
|
+ <template v-for="(item,index) in ColorConfigData">
|
|
|
+ <div class="item" :class="UserColorNmae === item.name ? 'active' : ''" v-if="index >= 5">
|
|
|
+ <div class="demo" :class="`bg-${item.name}`">
|
|
|
+ <img :src="ImgColor" alt="">
|
|
|
+ </div>
|
|
|
+ <div class="action" @click="ColorConfigClick(item)">
|
|
|
+ <el-radio v-model="UserColorNmae" :label="item?.name" size="large" class="size-xl">{{item?.label}}</el-radio>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="text-lg font-medium mb-4">首页背景</div>
|
|
|
+ <div class="hc-theme-box home-bg-box mb-8">
|
|
|
+ <template v-for="item in homeConfigData">
|
|
|
+ <div class="item" :class="HomeTheme.name === item?.name ? 'active' : ''" @click="homeConfigClick(item)">
|
|
|
+ <img :src="item.bg" alt="" crossOrigin="anonymous">
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="text-lg font-medium mb-4">截图设置</div>
|
|
|
+ <div class="hc-screenshot-box mb-4">
|
|
|
+ <div class="item">
|
|
|
+ <div class="label">WebRtc:</div>
|
|
|
+ <el-popover placement="top-start" trigger="hover" :width="400">
|
|
|
+ <template #reference>
|
|
|
+ <el-switch v-model="webRtcVal" size="large" active-value="1" inactive-value="0" @change="webRtcUpdate"/>
|
|
|
+ </template>
|
|
|
+ <div>
|
|
|
+ <div>是否启用WebRtc方式截图,WebRtc方式不会错版,但需要同意授权,调用的是浏览器的共享屏幕API (可能在某些浏览器上,不支持)。</div>
|
|
|
+ <div class="mt-2 mb-2">不启用WebRtc时,采用 html2canvas 实现截图,但支持的并不好,容易出现错版。</div>
|
|
|
+ <div>但目前市面上,网页截图的仅有这两种方案,推荐使用第三方截图来手动上传图片。</div>
|
|
|
+ </div>
|
|
|
+ </el-popover>
|
|
|
+ </div>
|
|
|
+ <div class="item">
|
|
|
+ <div class="label">全屏截图:</div>
|
|
|
+ <el-popover placement="top-start" trigger="hover" :width="180">
|
|
|
+ <template #reference>
|
|
|
+ <el-switch v-model="fullScreenVal" size="large" active-value="1" inactive-value="0" @change="fullScreenUpdate"/>
|
|
|
+ </template>
|
|
|
+ <div>单击截全屏的启用状态</div>
|
|
|
+ </el-popover>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <template #action>
|
|
|
+ <el-button size="large">取消</el-button>
|
|
|
+ <el-button type="primary" size="large">保存配置</el-button>
|
|
|
+ </template>
|
|
|
+ </HcCard>
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import {ref,watch} from "vue";
|
|
|
+import {ref,watch,nextTick} from "vue";
|
|
|
import {useAppStore} from "~src/store/index";
|
|
|
+import themeData from '~src/config/theme';
|
|
|
+import {userConfigSave} from "~api/other";
|
|
|
+import ImgTheme from "~src/assets/images/theme.png";
|
|
|
+import ImgColor from "~src/assets/images/color.png";
|
|
|
+import {utilsTo} from "vue-utils-plus"
|
|
|
+import {useOsTheme} from 'vooks'
|
|
|
|
|
|
-//变量
|
|
|
+//初始变量
|
|
|
const useAppState = useAppStore()
|
|
|
-const HomeTheme = ref(useAppState.getHomeTheme);
|
|
|
+const { toColor } = utilsTo()
|
|
|
+const UserTheme = ref(useAppState.getTheme)
|
|
|
+const UserColor = ref(useAppState.getColor)
|
|
|
+const HomeTheme = ref(useAppState.getHomeTheme)
|
|
|
+const webRtcVal = ref(useAppState.getShotWebRtc)
|
|
|
+const fullScreenVal = ref(useAppState.getFullScreen)
|
|
|
+const UserColorNmae = ref(UserColor.value?.name || 'green')
|
|
|
|
|
|
//监听
|
|
|
watch(() => [
|
|
|
+ useAppState.getTheme,
|
|
|
+ useAppState.getColor,
|
|
|
useAppState.getHomeTheme,
|
|
|
-], ([theme]) => {
|
|
|
- HomeTheme.value = theme
|
|
|
+ useAppState.getShotWebRtc,
|
|
|
+ useAppState.getFullScreen,
|
|
|
+], ([Theme,ColorVal,homeTheme,WebRtc,FullScreen]) => {
|
|
|
+ UserTheme.value = Theme
|
|
|
+ UserColor.value = ColorVal
|
|
|
+ HomeTheme.value = homeTheme
|
|
|
+ webRtcVal.value = WebRtc
|
|
|
+ fullScreenVal.value = FullScreen
|
|
|
+ UserColorNmae.value = ColorVal?.name || 'green'
|
|
|
})
|
|
|
+
|
|
|
+//颜色
|
|
|
+const ColorConfigData = ref(themeData.color)
|
|
|
+
|
|
|
+//更改主色调
|
|
|
+const ColorConfigClick = (item) => {
|
|
|
+ useAppState.setColor(item)
|
|
|
+ UserColorNmae.value = item?.name
|
|
|
+ userConfigSave({color: item?.name})
|
|
|
+ setUserColor(item?.color)
|
|
|
+ nextTick(() => {
|
|
|
+ UserColor.value = item
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+//设置主色调
|
|
|
+const setUserColor = (color) => {
|
|
|
+ const el = document.documentElement
|
|
|
+ el.style.setProperty('--el-color-primary', color)
|
|
|
+ // 设置 css 渐变 变量
|
|
|
+ const numArr = [3,5,7,8,9]
|
|
|
+ numArr.forEach(item => {
|
|
|
+ let amount = 0
|
|
|
+ if (item === 3) {
|
|
|
+ amount = 0.9
|
|
|
+ } else if (item === 5) {
|
|
|
+ amount = 0.7
|
|
|
+ } else if (item >= 7) {
|
|
|
+ amount = amount = (10 - item) / 10
|
|
|
+ }
|
|
|
+ const val = toColor('#FFFFFF', color , amount)
|
|
|
+ el.style.setProperty(`--el-color-primary-light-${item}`, val)
|
|
|
+ })
|
|
|
+ //生成深主色颜色
|
|
|
+ const val = toColor('#000000', color , 0.9)
|
|
|
+ el.style.setProperty('--el-color-primary-dark-2', val)
|
|
|
+}
|
|
|
+
|
|
|
+//更改主题设置
|
|
|
+const ThemeDatas = ref([
|
|
|
+ {key: 'auto', name: '跟随系统'},
|
|
|
+ {key: 'light', name: '浅色模式'},
|
|
|
+ {key: 'dark', name: '深色模式'}
|
|
|
+])
|
|
|
+const ThemeConfigClick = (item) => {
|
|
|
+ ThemeTabsUpdate(item?.key)
|
|
|
+}
|
|
|
+const ThemeTabsUpdate = (val) => {
|
|
|
+ UserTheme.value = val
|
|
|
+ useAppState.setTheme(val)
|
|
|
+ if (val === 'auto') {
|
|
|
+ useAppState.setThemeVal(useOsTheme().value)
|
|
|
+ } else {
|
|
|
+ useAppState.setThemeVal(val)
|
|
|
+ }
|
|
|
+ let colorName = UserColorNmae.value || 'green'
|
|
|
+ document.documentElement.setAttribute('class',`${val} color-${colorName}`)
|
|
|
+ userConfigSave({theme: val})
|
|
|
+}
|
|
|
+
|
|
|
+//更改首页主题
|
|
|
+const homeConfigData = ref(themeData.home)
|
|
|
+const homeConfigClick = (item) => {
|
|
|
+ useAppState.setHomeTheme(item)
|
|
|
+ userConfigSave({homeTheme: item?.name})
|
|
|
+}
|
|
|
+
|
|
|
+//更改截图方式
|
|
|
+const webRtcUpdate = (val) => {
|
|
|
+ useAppState.setShotWebRtc(val)
|
|
|
+ userConfigSave({shotWebRtc: val})
|
|
|
+}
|
|
|
+//更改全屏截图方式
|
|
|
+const fullScreenUpdate = (val) => {
|
|
|
+ useAppState.setFullScreen(val)
|
|
|
+ userConfigSave({fullScreen: val})
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|