-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Open international professional features #7472
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -134,18 +134,19 @@ function getCheckedLabels(json: Node): string[] { | |
const search = async () => { | ||
await checkIsSystemIntl(); | ||
let checkedLabels: any[] = []; | ||
if (!globalStore.isIntl) { | ||
const res = await getSettingInfo(); | ||
const json: Node = JSON.parse(res.data.xpackHideMenu); | ||
checkedLabels = getCheckedLabels(json); | ||
} | ||
const res = await getSettingInfo(); | ||
const json: Node = JSON.parse(res.data.xpackHideMenu); | ||
checkedLabels = getCheckedLabels(json); | ||
|
||
let rstMenuList: RouteRecordRaw[] = []; | ||
menuStore.menuList.forEach((item) => { | ||
let menuItem = JSON.parse(JSON.stringify(item)); | ||
let menuChildren: RouteRecordRaw[] = []; | ||
if (menuItem.path === '/xpack') { | ||
if (checkedLabels.length) { | ||
menuItem.children = menuItem.children.filter((child: any) => { | ||
return !(globalStore.isIntl && child.path.includes('/xpack/alert')); | ||
}); | ||
menuItem.children.forEach((child: any) => { | ||
for (const str of checkedLabels) { | ||
if (child.name === str) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The provided code appears to be part of a Vue.js application using the Element Plus UI library. Here's an assessment of the code: Potential IssueThe condition SuggestionConsider refactoring this loop structure so that you only apply the filtering logic when a specific condition (e.g., checking for sub-paths beneath Here’s one possible way to refactor it: // Initialize filtered menu list directly outside the main loop
let filteredMenuList: RouteRecordRaw[] = [];
menuStore.menuList.forEach((item) => {
// Process parent item
let menuItem = JSON.parse(JSON.stringify(item));
if (menuItem.path === "/xpack") {
// Determine which parts should remain visible based on user settings
filteredMenuList.push(menuItem); // Add current item since it matches '/xpack'
// Apply visibility filter to child menu options
menuItem.children = menuItem.children.filter(child => !child.path.includes("/xpack/alert"));
// Recursively process the child menu
recursivelyFilterChildMenuItems(filteredMenuList, child);
} else {
// Directly add non-menu-item nodes to final result set.
rstMenuList.push(menuItem);
}
});
function recursivelyFilterChildMenuItems(parentList: RouteRecordRaw[], targetMenuItem: RouteRecordRaw) {
// ... Existing code remains same ...
} By doing this, you ensure that each MenuItem is processed only once, improving efficiency when dealing with nested structures. Make sure this change aligns fully with your application's requirements and architecture before implementing it! |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,8 +9,6 @@ | |
|
||
<script lang="ts" setup> | ||
import i18n from '@/lang'; | ||
import { GlobalStore } from '@/store'; | ||
const globalStore = GlobalStore(); | ||
const buttons = [ | ||
{ | ||
|
@@ -38,8 +36,4 @@ const buttons = [ | |
path: '/settings/about', | ||
}, | ||
]; | ||
if (globalStore.isIntl) { | ||
buttons.splice(4, 1); | ||
} | ||
</script> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Your code has several improvements, but there are a few areas where you can optimize it further:
import i18n from '@/lang';
// Removed: import { GlobalStore } from '@/store';
<script lang="ts" setup>
const globalStore: ReturnType<typeof import('@/store')> = await import('@/store').then(m => m.GlobalStore());
const buttons = [
{
text: 'Settings.',
iconText: '<span aria-hidden="true">fas fa-cog</span>',
path: '/settings/account',
},
...[
// other menu items remain unchanged...
],
];
if (globalStore.isIntl) {
buttons.splice(4, 1); // Assuming the index is correct; adjust if necessary.
}
</script>
Here's the optimized code with these changes: import i18n from '@/lang';
import GlobalStore from '@/store';
const globalStore = new GlobalStore();
const buttons = [
{
text: 'Settings.',
iconText: '<span aria-hidden="true">fas fa-cog</span>',
path: '/settings/account',
},
// ... rest of button configurations ...
];
if (globalStore.isIntl) {
buttons.splice(4, 1); // Adjust the index based on your logic needs.
}
<template>
<!-- Your template content here -->
</template>
<script lang="ts">
export default defineComponent({
components: {},
});
</script>
<style scoped>
/* Your styles go here */
</style> By making these adjustments, your code will be cleaner, more efficient, and easier to maintain. Make sure to test thoroughly after applying these changes to ensure compatibility and functionality. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The provided patch seems mostly correct overall, but there is one change that needs consideration:
However, from a functional standpoint, updating the links without further context about internationalization implications does not pose major issues. Here's an outline of what each line does, which helps verify their correctness:
These modifications align with standard practices in JavaScript and TypeScript development while making some minor syntactic adjustments like removing unnecessary spaces around operators (
=
). If you have additional requirements such as testing or validation, let me know!