删除 tipsPreference.

This commit is contained in:
lijiahang
2023-10-08 17:51:30 +08:00
parent fbd815a10e
commit 66b2539630
13 changed files with 68 additions and 86 deletions

View File

@@ -37,7 +37,4 @@ public class UserCollectInfoVO {
@Schema(description = "系统偏好")
private Map<String, Object> systemPreference;
@Schema(description = "提示偏好")
private Map<String, Object> tipsPreference;
}

View File

@@ -20,11 +20,6 @@ public enum PreferenceTypeEnum {
*/
SYSTEM("systemPreferenceStrategy"),
/**
* 提示偏好
*/
TIPS("tipsPreferenceStrategy"),
;
PreferenceTypeEnum(String beanName) {

View File

@@ -1,25 +0,0 @@
package com.orion.ops.module.infra.handler.preference.model;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 提示偏好模型
*
* @author Jiahang Li
* @version 1.0.0
* @since 2023/10/8 13:59
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class TipsPreferenceModel implements PreferenceModel {
@Schema(description = "是否提示过系统偏好设置模态框")
private Boolean tippedSystemPreferenceModal;
}

View File

@@ -1,23 +0,0 @@
package com.orion.ops.module.infra.handler.preference.strategy;
import com.orion.ops.module.infra.handler.preference.model.TipsPreferenceModel;
import org.springframework.stereotype.Component;
/**
* 提示偏好处理策略
*
* @author Jiahang Li
* @version 1.0.0
* @since 2023/10/8 15:11
*/
@Component
public class TipsPreferenceStrategy implements IPreferenceStrategy<TipsPreferenceModel> {
@Override
public TipsPreferenceModel getDefault() {
return TipsPreferenceModel.builder()
.tippedSystemPreferenceModal(false)
.build();
}
}

View File

@@ -201,8 +201,6 @@ public class PermissionServiceImpl implements PermissionService {
Long id = user.getId();
// 获取用户系统偏好
Future<Map<String, Object>> systemPreference = preferenceService.getPreference(id, PreferenceTypeEnum.SYSTEM);
// 获取用户提示偏好
Future<Map<String, Object>> tipsPreference = preferenceService.getPreference(id, PreferenceTypeEnum.TIPS);
// 获取用户角色
List<String> roles = this.getUserEnabledRoles();
// 获取用户权限
@@ -228,7 +226,6 @@ public class PermissionServiceImpl implements PermissionService {
}
// 获取异步结果
user.setSystemPreference(systemPreference.get());
user.setTipsPreference(tipsPreference.get());
// 组装数据
return UserPermissionVO.builder()
.user(user)

View File

@@ -1,6 +1,6 @@
import axios from 'axios';
type Preference = 'SYSTEM' | 'TIPS'
type Preference = 'SYSTEM'
/**
* 用户偏好更新请求

View File

@@ -1,16 +1,18 @@
<template>
<div class="block">
<h5 class="title">{{ title }}</h5>
<div v-for="option in options" :key="option.name" class="option-wrapper">
<!-- 偏好项 -->
<span>{{ option.name }}</span>
<!-- 偏好值 -->
<form-wrapper :name="option.key"
:type="option.type as string"
:default-value="option.defaultVal"
:options="option.options"
@input-change="handleChange" />
</div>
<template v-for="option in options" :key="option.name">
<div class="option-wrapper" v-permission="option.permission || []">
<!-- 偏好项 -->
<span>{{ option.name }}</span>
<!-- 偏好值 -->
<form-wrapper :name="option.key"
:type="option.type as string"
:default-value="option.defaultVal"
:options="option.options"
@input-change="handleChange" />
</div>
</template>
</div>
</template>
@@ -26,6 +28,7 @@
name: string;
key: string;
type?: string;
permission?: string[];
defaultVal?: boolean | string | number;
options?: Array<RadioOption>;
}

View File

@@ -78,6 +78,7 @@
name: '主机列表',
key: 'hostView',
type: 'radio-group',
permission: ['asset:host:query'],
defaultVal: appStore.hostView,
options: [{ value: 'table', label: '表格' }, { value: 'card', label: '卡片' }]
},
@@ -85,6 +86,7 @@
name: '主机秘钥',
key: 'hostKeyView',
type: 'radio-group',
permission: ['asset:host-key:query'],
defaultVal: appStore.hostKeyView,
options: [{ value: 'table', label: '表格' }, { value: 'card', label: '卡片' }]
},
@@ -92,6 +94,7 @@
name: '主机身份',
key: 'hostIdentityView',
type: 'radio-group',
permission: ['asset:host-identity:query'],
defaultVal: appStore.hostIdentityView,
options: [{ value: 'table', label: '表格' }, { value: 'card', label: '卡片' }]
},

View File

@@ -117,16 +117,31 @@
</li>
<!-- 偏好设置 -->
<li>
<a-tooltip content="偏好设置">
<a-button class="nav-btn"
type="outline"
shape="circle"
@click="openGlobalSetting">
<template #icon>
<icon-settings />
</template>
</a-button>
</a-tooltip>
<a-popover :popup-visible="tippedPreference" position="br">
<template #title>
💡 点击这里可以修改系统偏好~
</template>
<template #content>
<span style="line-height: 1.8">
可以修改页面布局<br>
可以切换显示视图
</span>
<div class="tips-buttons">
<a-button size="mini" class="mr8" @click="closePreferenceTip(false)">关闭</a-button>
<a-button size="mini" type="primary" @click="closePreferenceTip(true)">不在提醒</a-button>
</div>
</template>
<a-tooltip content="偏好设置">
<a-button class="nav-btn"
type="outline"
shape="circle"
@click="openGlobalSetting">
<template #icon>
<icon-settings />
</template>
</a-button>
</a-tooltip>
</a-popover>
</li>
<!-- 用户信息 -->
<li>
@@ -177,6 +192,8 @@
import MessageBox from '../message-box/index.vue';
import { openGlobalSettingKey, toggleDrawerMenuKey } from '@/types/symbol';
// TODO 默认值
const tippedPreference = ref(true);
const appStore = useAppStore();
const userStore = useUserStore();
const { logout } = useUser();
@@ -201,7 +218,9 @@
valueLight: 'light',
storageKey: 'arco-theme',
onChanged(dark: boolean) {
appStore.toggleTheme(dark);
appStore.updateSettings({
theme: dark ? 'dark' : 'light'
});
},
});
@@ -232,6 +251,15 @@
// 注入收缩菜单
const toggleDrawerMenu = inject(toggleDrawerMenuKey) as () => void;
// 关闭偏好提示
const closePreferenceTip = (ack: boolean) => {
tippedPreference.value = false;
if (ack) {
// TODO 修改
}
};
</script>
<style scoped lang="less">
@@ -296,4 +324,11 @@
margin-top: 0;
}
}
.tips-buttons {
margin-top: 12px;
display: flex;
justify-content: flex-end;
}
</style>

View File

@@ -4,6 +4,7 @@ import { FavoriteType, addFavorite, cancelFavorite } from '@/api/meta/favorite';
export default function useFavorite(type: FavoriteType) {
const toggle = async (record: any, id: number, cancelField = 'favorite') => {
const request = { relId: id, type };
Message.clear();
const loading = Message.loading(record[cancelField] ? '取消中' : '收藏中');
try {
if (record[cancelField]) {

View File

@@ -12,7 +12,7 @@ export {
useMenuStore,
useUserStore,
useTabBarStore,
useCacheStore
useCacheStore,
};
export default pinia;

View File

@@ -1,6 +1,5 @@
import { defineStore } from 'pinia';
import { AppState } from './types';
import TimeScale from 'echarts/types/src/scale/Time';
const defaultConfig: AppState = {
// 应用设置

View File

@@ -1,6 +1,6 @@
export type Theme = 'light' | 'dark'
export type Device = 'desktop' | 'mobile'
export type ViewType = 'table' | 'card' | undefined
type Theme = 'light' | 'dark';
type Device = 'desktop' | 'mobile';
type ViewType = 'table' | 'card' | undefined;
/**
* 应用状态