-
Notifications
You must be signed in to change notification settings - Fork 2.9k
feat: Some adjustments to internationalization #7332
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
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 |
|---|---|---|
|
|
@@ -10,6 +10,12 @@ router.beforeEach((to, from, next) => { | |
| axiosCanceler.removeAllPending(); | ||
| const globalStore = GlobalStore(); | ||
|
|
||
| if (globalStore.isIntl && to.path.includes('xpack')) { | ||
| next({ name: '404' }); | ||
| NProgress.done(); | ||
| return; | ||
| } | ||
|
|
||
| if (to.name !== 'entrance' && !globalStore.isLogin) { | ||
| next({ | ||
| name: 'entrance', | ||
|
Member
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. There are no apparent errors or issues with this code. However, there is an opportunity for further optimization:
Here's how you can optimize it: @@ -10,6 +10,9 @@ router.beforeEach((to, from, next) => {
axiosCanceler.removeAllPending();
const globalStore = GlobalStore();
+ handleUnauthorizedRoute(next);
+
if (!globalStore.isLogin && to.name !== 'entrance') {
next({
name: 'entrance',Create this helper function: function handleUnauthorizedRoute(next) {
nprogress.done()
if(to.path.includes('xpack')){
return
}
console.log("Unauthorized path")
// You may want to log more specific information here, like the current route
}This way, the duplicate code block is removed and organized under its own named function, improving readability and maintainability. |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -77,9 +77,10 @@ | |
| @change="onSave('Language', form.language)" | ||
| v-model="form.language" | ||
| > | ||
| <el-radio v-if="globalStore.isIntl" value="en">English</el-radio> | ||
| <el-radio value="zh">中文(简体)</el-radio> | ||
| <el-radio value="tw">中文(繁體)</el-radio> | ||
| <el-radio value="en">English</el-radio> | ||
| <el-radio v-if="!globalStore.isIntl" value="en">English</el-radio> | ||
| </el-radio-group> | ||
| </el-form-item> | ||
|
|
||
|
Member
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 snippet appears to have duplication of "English" radio options. It should be cleaned up to avoid this repetition: @@ -77,13 +77,12 @@
@change="onSave('Language', form.language)"
v-model="form.language"
>
- <el-radio value="en">English</el-radio>
+ <!-- Remove duplicate English radio option -->
</el-radio-group>
</el-form-item>
Additionally, you may want to consider using conditional rendering within the If there's additional context about what these changes will achieve (like improving accessibility by hiding one of the radios), feel free to include that information for further clarification. |
||
|
|
||
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 code change seems mostly correct, but here's a quick review:
Type of
checkedLabels: The linelet checkedLabels: string | any[];specifies thatcheckedLabelscan be either a string or an array of any type (any[]). Ensure that this is intentional as it might lead to runtime errors if you expectcheckedLabelsto always be a string when used.Potential Issue with
globalStore.isIntl: Before assigning the value fromgetSettingInfo, ensure there isn't a race condition whereglobalStore.isIntlhasn't been initialized yet (e.g., using asynchronous operations outside this block).Suggested Change: Consider initializing
checkedLabelswithin the same scope as its definition without specifying types first, especially if types are not strictly necessary for all use cases (although they can help improve readability):This approach assumes
setCheckedLabelsmethod exists inglobalStore.If
isCheckedLabelsdoesn’t exist, consider setting its initial value ininitfunction before callingsearch. This would prevent undefined behavior:These optimizations focus on clarity and ensuring the flow is smooth without introducing unnecessary complexity or runtime error risks.