Files
daohangye/src/components/apps/Style/index.vue
T
Sun bb67aaf5a6 更新v1.2.1
Squashed commit of the following:

commit 146f106fbece251606f358141bda3d9c524c3e93
Author: Sun <95302870@qq.com>
Date:   Thu Dec 28 19:39:36 2023 +0800

    修改默认宽度

commit 827197e295b2b0997902b8f965d14ab2598c5c1b
Author: Sun <95302870@qq.com>
Date:   Thu Dec 28 17:54:25 2023 +0800

    修复升级掉登录的问题

commit 2e54326f5fe2b8fac4eed488a14b04b8133c41bb
Author: Sun <95302870@qq.com>
Date:   Thu Dec 28 17:21:49 2023 +0800

    优化边距等提示

commit 469c6fd644a2a23d96405d15456980edfdfb17b0
Author: Sun <95302870@qq.com>
Date:   Thu Dec 28 17:21:34 2023 +0800

    搜索栏选择搜索引擎后关闭选择器

commit 632da9635a4a434d361495dfcb83f8b650cb4a3c
Author: Sun <95302870@qq.com>
Date:   Thu Dec 28 16:54:28 2023 +0800

    增加 内容左右边距和最大宽度

commit f1cc3dce2a51ec60c1b04f21954b99b284b2df61
Author: Sun <95302870@qq.com>
Date:   Thu Dec 28 14:24:23 2023 +0800

    分组标题增加阴影

commit 7615a29678037362c18632f38caad72e07a32d1a
Author: Sun <95302870@qq.com>
Date:   Thu Dec 28 14:18:41 2023 +0800

    更改版本号1.2.1

commit b605374e951d3fb2ca52d36bd0fa82aec4a5e89b
Author: Sun <95302870@qq.com>
Date:   Thu Dec 28 14:11:06 2023 +0800

    优化小部分网站图标获取失败的问题

commit c8141184a14fb02f941bbec03ac98f59f8b12d4b
Author: Sun <95302870@qq.com>
Date:   Thu Dec 28 13:00:56 2023 +0800

    优化上传管理界面
2023-12-28 19:58:10 +08:00

267 lines
8.2 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script setup lang="ts">
import { ref, watch } from 'vue'
import type { UploadFileInfo } from 'naive-ui'
import { NButton, NCard, NColorPicker, NGrid, NGridItem, NInput, NInputGroup, NPopconfirm, NSelect, NSlider, NSwitch, NUpload, NUploadDragger, useMessage } from 'naive-ui'
import { useAuthStore, usePanelState } from '@/store'
import { set as setUserConfig } from '@/api/panel/userConfig'
import { PanelPanelConfigStyleEnum } from '@/enums/panel'
const authStore = useAuthStore()
const panelState = usePanelState()
const ms = useMessage()
const isSaveing = ref(false)
const iconTypeOptions = [
{
label: '详情图标',
value: PanelPanelConfigStyleEnum.info,
},
{
label: '小图标',
value: PanelPanelConfigStyleEnum.icon,
},
]
const maxWidthUnitOption = [
{
label: 'px',
value: 'px',
},
{
label: '%',
value: '%',
},
]
watch(panelState.panelConfig, () => {
if (!isSaveing.value) {
isSaveing.value = true
setTimeout(() => {
panelState.recordState()// 本地记录
uploadCloud()
}, 1000)
}
})
function handleUploadBackgroundFinish({
file,
event,
}: {
file: UploadFileInfo
event?: ProgressEvent
}) {
const res = JSON.parse((event?.target as XMLHttpRequest).response)
panelState.panelConfig.backgroundImageSrc = res.data.imageUrl
return file
}
function uploadCloud() {
setUserConfig({ panel: panelState.panelConfig }).then((res) => {
if (res.code === 0)
ms.success('配置已保存')
else
ms.error(`配置已保存${res.msg}`)
})
}
function resetPanelConfig() {
panelState.resetPanelConfig()
uploadCloud()
}
</script>
<template>
<div class="bg-slate-200 rounded-[10px] p-[8px] overflow-auto">
<NCard style="border-radius:10px" size="small">
<div class="text-slate-500 mb-[5px] font-bold">
LOGO
</div>
<div>
<div>
文本内容
</div>
<div class="flex items-center mt-[5px]">
<NInput v-model:value="panelState.panelConfig.logoText" type="text" show-count :maxlength="20" placeholder="请输入文字" />
</div>
</div>
</NCard>
<NCard style="border-radius:10px" class="mt-[10px]" size="small">
<div class="text-slate-500 mb-[5px] font-bold">
时钟
</div>
<div class="flex items-center mt-[5px]">
<span class="mr-[10px]">显示秒</span>
<NSwitch v-model:value="panelState.panelConfig.clockShowSecond" />
</div>
</NCard>
<NCard style="border-radius:10px" class="mt-[10px]" size="small">
<div class="text-slate-500 mb-[5px] font-bold">
搜索框
</div>
<div class="flex items-center mt-[5px]">
<span class="mr-[10px]">显示</span>
<NSwitch v-model:value="panelState.panelConfig.searchBoxShow" />
</div>
<div v-if="panelState.panelConfig.searchBoxShow" class="flex items-center mt-[5px]">
<span class="mr-[10px]">允许搜索快捷图标</span>
<NSwitch v-model:value="panelState.panelConfig.searchBoxSearchIcon" />
</div>
</NCard>
<NCard style="border-radius:10px" class="mt-[10px]" size="small">
<div class="text-slate-500 mb-[5px] font-bold">
图标
</div>
<div class="mt-[5px]">
<div>
样式
</div>
<div class="flex items-center mt-[5px]">
<NSelect v-model:value="panelState.panelConfig.iconStyle" :options="iconTypeOptions" />
</div>
</div>
<div v-if="panelState.panelConfig.iconStyle === PanelPanelConfigStyleEnum.info" class="mt-[5px]">
<div>
隐藏描述信息
</div>
<div class="flex items-center mt-[5px]">
<NSwitch v-model:value="panelState.panelConfig.iconTextInfoHideDescription" />
</div>
</div>
<div v-if="panelState.panelConfig.iconStyle === PanelPanelConfigStyleEnum.icon" class="mt-[5px]">
<div>
隐藏标题
</div>
<div class="flex items-center mt-[5px]">
<NSwitch v-model:value="panelState.panelConfig.iconTextIconHideTitle" />
</div>
</div>
<div class="mt-[5px]">
<div>
文字颜色
</div>
<div class="flex items-center mt-[5px]">
<NColorPicker
v-model:value="panelState.panelConfig.iconTextColor"
:show-alpha="false"
size="small"
:modes="['hex']"
:swatches="[
'#000000',
'#ffffff',
'#18A058',
'#2080F0',
'#F0A020',
]"
/>
</div>
</div>
</NCard>
<NCard style="border-radius:10px" class="mt-[10px]" size="small">
<div class="text-slate-500 mb-[5px] font-bold">
壁纸
</div>
<NUpload
action="/api/file/uploadImg"
:show-file-list="false"
name="imgfile"
:headers="{
token: authStore.token as string,
}"
:directory-dnd="true"
@finish="handleUploadBackgroundFinish"
>
<NUploadDragger style="width: 100%;">
<div
class="h-[200px] w-full border bg-slate-100 flex justify-center items-center cursor-pointer rounded-[10px]"
:style="{ background: `url(${panelState.panelConfig.backgroundImageSrc}) no-repeat`, backgroundSize: 'cover' }"
>
<div class="text-shadow text-white">
点击上传替换图片或拖拽到框内
</div>
</div>
</NUploadDragger>
</NUpload>
<div class="flex items-center mt-[10px]">
<span class="mr-[10px]">模糊</span>
<NSlider v-model:value="panelState.panelConfig.backgroundBlur" class="max-w-[200px]" :step="2" :max="20" />
</div>
<div class="flex items-center mt-[10px]">
<span class="mr-[10px]">遮罩</span>
<NSlider v-model:value="panelState.panelConfig.backgroundMaskNumber" class="max-w-[200px]" :step="0.1" :max="1" />
</div>
</NCard>
<NCard style="border-radius:10px" class="mt-[10px]" size="small">
<div class="text-slate-500 mb-[5px] font-bold">
内容区域
</div>
<NGrid cols="2">
<NGridItem span="12 400:12">
<div class="flex items-center mt-[10px]">
<span class="mr-[10px]">最大宽度</span>
<div class="flex">
<NInputGroup>
<NInput v-model:value="panelState.panelConfig.maxWidth" size="small" type="number" :maxlength="10" :style="{ width: '100px' }" placeholder="1200" />
<NSelect v-model:value="panelState.panelConfig.maxWidthUnit" :style="{ width: '80px' }" :options="maxWidthUnitOption" size="small" />
</NInputGroup>
</div>
</div>
</NGridItem>
<NGridItem span="12 400:12">
<div class="flex items-center mt-[10px]">
<span class="mr-[10px]">左右边距</span>
<NSlider v-model:value="panelState.panelConfig.marginX" class="max-w-[200px]" :step="1" :max="100" />
</div>
</NGridItem>
<NGridItem span="12 400:12">
<div class="flex items-center mt-[10px]">
<span class="mr-[10px]">上边距 (%)</span>
<NSlider v-model:value="panelState.panelConfig.marginTop" class="max-w-[200px]" :step="1" :max="50" />
</div>
</NGridItem>
<NGridItem span="12 400:6">
<div class="flex items-center mt-[10px]">
<span class="mr-[10px]">下边距 (%)</span>
<NSlider v-model:value="panelState.panelConfig.marginBottom" class="max-w-[200px]" :step="1" :max="50" />
</div>
</NGridItem>
</NGrid>
</NCard>
<NCard style="border-radius:10px" class="mt-[10px]" size="small">
<NPopconfirm
@positive-click="resetPanelConfig"
>
<template #trigger>
<NButton size="small" quaternary type="error">
重置
</NButton>
</template>
确定要重置这些样式吗
</NPopconfirm>
<NButton size="small" quaternary type="success" class="ml-[10px]" @click="uploadCloud">
立即保存
</NButton>
</NCard>
</div>
</template>
<style scoped>
.text-shadow{
text-shadow: 0px 0px 5px gray;
}
</style>