-
Notifications
You must be signed in to change notification settings - Fork 3.2k
feat: Applications support setting a description field. #8437
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 |
|---|---|---|
|
|
@@ -666,6 +666,15 @@ export function getLabel(row: any) { | |
| } | ||
| } | ||
|
|
||
| export function getDescription(row: any) { | ||
| const language = localStorage.getItem('lang') || 'zh'; | ||
| let lang = language == 'tw' ? 'zh-Hant' : language; | ||
| if (row.description && row.description[lang] != '') { | ||
| return row.description[lang]; | ||
| } | ||
| return ''; | ||
| } | ||
|
|
||
| export function emptyLineFilter(str: string, spilt: string) { | ||
| let list = str.split(spilt); | ||
| let results = []; | ||
|
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 code appears to be well-structured, but here are some suggestions for improvement: Suggestion 1: Ensure Language Handling ConsistencyThe function function getLanguageCode(language: string): string {
return language === 'tw' ? 'zh-Hant' : language;
}
const descriptionsByLang = new Map<string, Record<string, string>>([
['en', { description_en: '' }],
['fr', { description_fr: '' }],
// Add more mappings as needed
]);
export function getDescription(row: any) {
const language = localStorage.getItem('lang') || 'zh';
const langCode = getLanguageCode(language);
const rowDescription = descriptionsByLang.get(langCode)?.description[lang];
if (typeof rowDescription !== 'undefined') {
return String(rowDescription); // Convert to non-null assertion operator or type guard if necessary
}
return '';
}Suggestion 2: Remove Unnecessary Typing ConversionConvertion from Additional Considerations:
Overall, the current code is clean and effective for its intended use case, with room for enhancement based on additional requirements or constraints. |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -116,6 +116,7 @@ | |
| </span> | ||
| </el-col> | ||
| </el-row> | ||
| <span class="input-help" v-if="p.description">{{ getDescription(p) }}</span> | ||
| </el-form-item> | ||
| </div> | ||
| </template> | ||
|
|
@@ -125,7 +126,7 @@ import { getRandomStr } from '@/utils/util'; | |
| import { getAppService } from '@/api/modules/app'; | ||
| import { Rules } from '@/global/form-rules'; | ||
| import { App } from '@/api/interface/app'; | ||
| import { getDBName, getLabel } from '@/utils/util'; | ||
| import { getDBName, getLabel, getDescription } from '@/utils/util'; | ||
| import { getPathByType } from '@/api/modules/files'; | ||
|
|
||
| interface ParamObj extends App.FromField { | ||
|
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 errors in the provided code changes. However, there is a typo in one of the lines that could lead to an unintended outcome: @@ -126,7 +126,7 @@ import { getDescription } from '@/utils/util';The line should be corrected to: import { getDescription, getLabel } from '@/utils/util'; // Corrected typo hereAdditionally, it's recommended to add documentation or comments about new functionality introduced by this change to help future developers understand why |
||
|
|
||
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.
There are no irregularities, potential issues, or optimization suggestions with the provided code changes. The fields that were added (Description, EnvKey) will not affect existing functionality but can be useful for additional context if needed. If there was an intention to replace Label with another data structure for labels in different languages, ensure it's structured similarly so the rest of the app can accommodate this change gracefully.