Merge pull request #9587 from dataease/pr@dev-v2@perf_login_demo_tips

perf: 社区版本登录页面账号密码提示内容可配置功能
This commit is contained in:
fit2cloud-chenyw 2024-05-10 14:45:23 +08:00 committed by GitHub
commit f8c645e4fc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 46 additions and 12 deletions

View File

@ -27,6 +27,9 @@ public class SysParameterManage {
@Value("${dataease.show-demo-tips:false}") @Value("${dataease.show-demo-tips:false}")
private boolean showDemoTips; private boolean showDemoTips;
@Value("${dataease.demo-tips-content:#{null}}")
private String demoTipsContent;
private static final String mapKey = "map.key"; private static final String mapKey = "map.key";
@Resource @Resource
@ -95,15 +98,20 @@ public class SysParameterManage {
@XpackInteract(value = "perSetting", replace = true) @XpackInteract(value = "perSetting", replace = true)
public List<Object> getUiList() { public List<Object> getUiList() {
Map<String, Object> loginTipsItem = new HashMap<>();
loginTipsItem.put("pkey", "showDemoTips");
loginTipsItem.put("pval", showDemoTips);
loginTipsItem.put("sort", 1);
List<Object> result = new ArrayList<>(); List<Object> result = new ArrayList<>();
result.add(loginTipsItem); result.add(buildSettingItem("community", true));
result.add(buildSettingItem("showDemoTips", showDemoTips));
result.add(buildSettingItem("demoTipsContent", demoTipsContent));
return result; return result;
} }
private Map<String, Object> buildSettingItem(String pkey, Object pval) {
Map<String, Object> item = new HashMap<>();
item.put("pkey", pkey);
item.put("pval", pval);
return item;
}
@Transactional @Transactional
public void saveGroup(List<SettingItemVO> vos, String groupKey) { public void saveGroup(List<SettingItemVO> vos, String groupKey) {

View File

@ -21,6 +21,8 @@ interface AppearanceState {
footContent?: string footContent?: string
loaded: boolean loaded: boolean
showDemoTips?: boolean showDemoTips?: boolean
demoTipsContent?: string
community: boolean
} }
const { wsCache } = useCache() const { wsCache } = useCache()
export const useAppearanceStore = defineStore('appearanceStore', { export const useAppearanceStore = defineStore('appearanceStore', {
@ -39,7 +41,9 @@ export const useAppearanceStore = defineStore('appearanceStore', {
foot: 'false', foot: 'false',
footContent: '', footContent: '',
loaded: false, loaded: false,
showDemoTips: false showDemoTips: false,
demoTipsContent: '',
community: true
} }
}, },
getters: { getters: {
@ -96,6 +100,12 @@ export const useAppearanceStore = defineStore('appearanceStore', {
}, },
getShowDemoTips(): boolean { getShowDemoTips(): boolean {
return this.showDemoTips return this.showDemoTips
},
getDemoTipsContent(): string {
return this.demoTipsContent
},
getCommunity(): boolean {
return this.community
} }
}, },
actions: { actions: {
@ -121,6 +131,7 @@ export const useAppearanceStore = defineStore('appearanceStore', {
const desktop = wsCache.get('app.desktop') const desktop = wsCache.get('app.desktop')
if (desktop) { if (desktop) {
this.loaded = true this.loaded = true
this.community = true
} }
if (this.loaded) { if (this.loaded) {
return return
@ -131,14 +142,22 @@ export const useAppearanceStore = defineStore('appearanceStore', {
if (!resData?.length) { if (!resData?.length) {
return return
} }
if (resData.length === 1 && resData[0]?.pkey === 'showDemoTips') { const data: AppearanceState = { loaded: false, community: true }
this.showDemoTips = resData[0].pval let isCommunity = false
return
}
const data: AppearanceState = { loaded: false }
resData.forEach(item => { resData.forEach(item => {
data[item.pkey] = item.pval data[item.pkey] = item.pval
if (item.pkey === 'community') {
isCommunity = true
}
}) })
data.community = isCommunity
this.community = data.community
if (this.community) {
this.showDemoTips = data.showDemoTips
this.demoTipsContent = data.demoTipsContent
this.loaded = true
return
}
this.navigate = data.navigate this.navigate = data.navigate
this.help = data.help this.help = data.help
this.navigateBg = data.navigateBg this.navigateBg = data.navigateBg

View File

@ -36,7 +36,14 @@ const footContent = ref(null)
const loginErrorMsg = ref('') const loginErrorMsg = ref('')
const xpackLoginHandler = ref() const xpackLoginHandler = ref()
const showDempTips = ref(false) const showDempTips = ref(false)
const demoTips = '账号admin 密码DataEase@123456 每晚 00:00 重置数据' const demoTips = computed(() => {
if (!showDempTips.value) {
return ''
}
return (
appearanceStore.getDemoTipsContent || '账号admin 密码DataEase@123456 每晚 00:00 重置数据'
)
})
const state = reactive({ const state = reactive({
loginForm: { loginForm: {
username: '', username: '',