Skip to content

Commit

Permalink
feat(view): ✨ 增加透明高斯模糊开关
Browse files Browse the repository at this point in the history
  • Loading branch information
nongyehong committed Jan 11, 2025
1 parent a2b3c32 commit 4b01189
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 11 deletions.
9 changes: 9 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ watch(
{ immediate: true }
)
/** 控制高斯模糊 */
watch(
() => page.value.blur,
(val) => {
document.documentElement.setAttribute('data-blur', val ? '1' : '0')
},
{ immediate: true }
)

Check warning on line 52 in src/App.vue

View check run for this annotation

Codecov / codecov/patch

src/App.vue#L46-L52

Added lines #L46 - L52 were not covered by tests
/** 控制字体样式 */
watch(
() => page.value.fonts,
Expand Down
2 changes: 1 addition & 1 deletion src/components/rightBox/ApplyList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
trigger="click"
placement="bottom-start"
:show-arrow="false"
style="padding: 0; background: var(--bg-info); backdrop-filter: blur(10px)">
style="padding: 0; background: var(--bg-info)">

Check warning on line 27 in src/components/rightBox/ApplyList.vue

View check run for this annotation

Codecov / codecov/patch

src/components/rightBox/ApplyList.vue#L27

Added line #L27 was not covered by tests
<template #trigger>
<p @click="currentUserId = item.uid" class="text-(14px #13987f) cursor-pointer">
{{ useUserInfo(item.uid).value.name }}
Expand Down
2 changes: 1 addition & 1 deletion src/components/rightBox/chatBox/ChatMain.vue
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
placement="right"
:show-arrow="false"
v-model:show="infoPopover"
style="padding: 0; background: var(--bg-info); backdrop-filter: blur(10px)">
style="padding: 0; background: var(--bg-info)">

Check warning on line 135 in src/components/rightBox/chatBox/ChatMain.vue

View check run for this annotation

Codecov / codecov/patch

src/components/rightBox/chatBox/ChatMain.vue#L135

Added line #L135 was not covered by tests
<template #trigger>
<ContextMenu
@select="$event.click(item, 'Main')"
Expand Down
2 changes: 1 addition & 1 deletion src/components/rightBox/chatBox/ChatSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
placement="left"
:show-arrow="false"
v-model:show="infoPopover"
style="padding: 0; background: var(--bg-info); backdrop-filter: blur(10px)">
style="padding: 0; background: var(--bg-info)">

Check warning on line 73 in src/components/rightBox/chatBox/ChatSidebar.vue

View check run for this annotation

Codecov / codecov/patch

src/components/rightBox/chatBox/ChatSidebar.vue#L73

Added line #L73 was not covered by tests
<template #trigger>
<ContextMenu
:content="item"
Expand Down
1 change: 0 additions & 1 deletion src/services/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export type HttpParams = {

/**
* @description HTTP 请求实现
* @since Beta v0.5.1
* @template T
* @param {string} url 请求地址
* @param {HttpParams} options 请求参数
Expand Down
3 changes: 2 additions & 1 deletion src/stores/setting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ export const useSettingStore = defineStore(StoresEnum.SETTING, {
},
page: {
shadow: true,
fonts: 'PingFang'
fonts: 'PingFang',
blur: true
}
}),
actions: {
Expand Down
21 changes: 16 additions & 5 deletions src/styles/scss/global/variable.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ svg {
--shadow-enabled: 1;
// 字体
--font-family: 'PingFang';
// 是否启用透明高斯模糊
--blur-enabled: 1;

--center-bg-color: #fff;
--right-bg-color: #f1f1f1;
Expand Down Expand Up @@ -66,7 +68,7 @@ svg {
--tray-hover: #eee;
--tray-hover-e: #f5dce1;
// 信息框背景颜色
--bg-info: rgba(255, 255, 255, 0.8);
--bg-info: rgba(255, 255, 255);
// 表情框样式
--bg-emoji: rgba(255, 255, 255, 0.6);
--emoji-hover: #e3e3e3;
Expand Down Expand Up @@ -152,7 +154,7 @@ html[data-theme='dark'] {
--tray-hover: #3b3b3b;
--tray-hover-e: #bb8188;
// 信息框背景颜色
--bg-info: rgba(27, 27, 27, 0.8);
--bg-info: rgba(27, 27, 27);
// 表情框样式
--bg-emoji: rgba(27, 27, 27, 0.8);
--emoji-hover: #3b3b3b;
Expand Down Expand Up @@ -237,13 +239,22 @@ html[data-theme='dark'] {
right: 0;
top: 0;
bottom: 0;
background-color: rgba(255, 255, 255, 0.1);
backdrop-filter: blur($blur);
-webkit-backdrop-filter: blur($blur);
}

// 使用CSS变量来控制模糊效果
html[data-blur="1"] {
.n-modal-mask,
.n-drawer-mask {
background-color: rgba(255, 255, 255, 0.1);
backdrop-filter: blur(4px);
-webkit-backdrop-filter: blur(4px);
}
}

.n-modal-mask {
@include mask-style;
}

.n-drawer-mask {
@include mask-style(2px);
}
Expand Down
2 changes: 2 additions & 0 deletions src/typings/stores.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ declare namespace STO {
shadow: boolean
/** 字体 */
fonts: string
/** 高斯模糊 */
blur: boolean
}
}

Expand Down
9 changes: 8 additions & 1 deletion src/views/moreWindow/settings/General.vue
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,14 @@
<span class="pl-10px">界面</span>

<n-flex class="item" :size="12" vertical>
<!-- 发送信息 -->
<n-flex align="center" justify="space-between">

Check warning on line 105 in src/views/moreWindow/settings/General.vue

View check run for this annotation

Codecov / codecov/patch

src/views/moreWindow/settings/General.vue#L105

Added line #L105 was not covered by tests
<span>是否开启透明高斯模糊</span>

<n-switch size="small" v-model:value="page.blur" />

Check warning on line 108 in src/views/moreWindow/settings/General.vue

View check run for this annotation

Codecov / codecov/patch

src/views/moreWindow/settings/General.vue#L108

Added line #L108 was not covered by tests
</n-flex>

<span class="w-full h-1px bg-[--line-color]"></span>

<n-flex align="center" justify="space-between">
<span>是否开启阴影</span>

Expand Down

0 comments on commit 4b01189

Please sign in to comment.