-
Notifications
You must be signed in to change notification settings - Fork 2.9k
fix: Fix the issue of abnormal display of recommended applications on… #7914
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 |
|---|---|---|
|
|
@@ -96,16 +96,27 @@ func (u *CronjobService) SearchRecords(search dto.SearchRecord) (int64, interfac | |
|
|
||
| func (u *CronjobService) LoadNextHandle(specStr string) ([]string, error) { | ||
| spec := cron.NewParser(cron.Minute | cron.Hour | cron.Dom | cron.Month | cron.Dow) | ||
| now := time.Now() | ||
| var nexts [5]string | ||
| if strings.HasPrefix(specStr, "@every ") { | ||
| duration := time.Minute | ||
| if strings.HasSuffix(specStr, "s") { | ||
| duration = time.Second | ||
| } | ||
| for i := 0; i < 5; i++ { | ||
| nextTime := now.Add(duration) | ||
| nexts[i] = nextTime.Format(constant.DateTimeLayout) | ||
| now = nextTime | ||
| } | ||
| return nexts[:], nil | ||
| } | ||
| sched, err := spec.Parse(specStr) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| now := time.Now() | ||
| var nexts [5]string | ||
| for i := 0; i < 5; i++ { | ||
| nextTime := sched.Next(now) | ||
| nexts[i] = nextTime.Format("2006-01-02 15:04:05") | ||
| fmt.Println(nextTime) | ||
| nexts[i] = nextTime.Format(constant.DateTimeLayout) | ||
| now = nextTime | ||
| } | ||
| return nexts[:], nil | ||
|
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 several potential issues and optimizations suggested based on the comparison against the previous versions of this code.
func (u *CronjobService) SearchRecords(search dto.SearchRecord) (int64, interface{}) return u.DB.QueryRow(fmt.Sprintf(to: for each page/record type use a different format
Here's a version of the code optimized by adding spacing within the docblock and using consistent formatting throughout:type Cronjobs struct { // TODO Add schema info here
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,7 +23,7 @@ | |
| </el-popover> | ||
| </template> | ||
| <template #body> | ||
| <el-scrollbar height="525px" class="moz-height"> | ||
| <el-scrollbar height="545px" class="moz-height"> | ||
| <div class="h-app-card" v-for="(app, index) in apps" :key="index"> | ||
| <el-row :gutter="5"> | ||
| <el-col :span="5"> | ||
|
|
@@ -64,16 +64,17 @@ | |
| <div class="h-app-content" v-else> | ||
| <div> | ||
| <el-dropdown trigger="hover"> | ||
| <el-button plain size="small" link class="h-app-dropdown"> | ||
| <el-button type="primary" plain size="small" link class="h-app-dropdown"> | ||
| {{ app.currentRow.name }} | ||
| <el-icon class="el-icon--right"><ArrowDown /></el-icon> | ||
| </el-button> | ||
| <template #dropdown> | ||
| <el-dropdown-menu | ||
| v-for="(detailItem, index2) in app.detail" | ||
| :key="index2" | ||
| > | ||
| <el-dropdown-item @click="app.currentRow = detailItem"> | ||
| <el-dropdown-menu> | ||
| <el-dropdown-item | ||
| v-for="(detailItem, index2) in app.detail" | ||
| :key="index2" | ||
| @click="app.currentRow = detailItem" | ||
| > | ||
| {{ detailItem.name + ' - ' + detailItem.version }} | ||
| </el-dropdown-item> | ||
| </el-dropdown-menu> | ||
|
|
@@ -90,7 +91,8 @@ | |
| size="small" | ||
| type="primary" | ||
| link | ||
| @click="onOperate('stop', app.currentRow)" | ||
| v-if="app.currentRow.status !== 'Running'" | ||
| @click="onOperate('start', app.currentRow)" | ||
| > | ||
| {{ $t('commons.button.start') }} | ||
| </el-button> | ||
|
|
@@ -99,10 +101,20 @@ | |
| size="small" | ||
| type="primary" | ||
| link | ||
| v-else | ||
| @click="onOperate('stop', app.currentRow)" | ||
| > | ||
| {{ $t('commons.button.stop') }} | ||
| </el-button> | ||
| <el-button | ||
| :style="mobile ? 'margin-left: -1px' : ''" | ||
| size="small" | ||
| type="primary" | ||
| link | ||
| @click="onOperate('restart', app.currentRow)" | ||
| > | ||
| {{ $t('commons.button.restart') }} | ||
| </el-button> | ||
| <el-button | ||
| :style="mobile ? 'margin-left: -1px' : ''" | ||
| size="small" | ||
|
|
@@ -244,6 +256,7 @@ const onChangeStatus = async (row: any) => { | |
| await changeLauncherStatus(row.key, row.isShow ? 'Enable' : 'Disable') | ||
| .then(() => { | ||
| loading.value = false; | ||
| MsgSuccess(i18n.global.t('commons.msg.operationSuccess')); | ||
| search(); | ||
| }) | ||
| .catch(() => { | ||
|
|
@@ -266,8 +279,8 @@ const getConfig = async () => { | |
|
|
||
| const onOperate = async (operation: string, row: any) => { | ||
| ElMessageBox.confirm( | ||
| i18n.global.t('app.operatorHelper', [i18n.global.t('app.' + operation)]), | ||
| i18n.global.t('app.' + operation), | ||
| i18n.global.t('app.operatorHelper', [i18n.global.t('commons.button.' + operation)]), | ||
| i18n.global.t('commons.button.' + operation), | ||
| { | ||
| confirmButtonText: i18n.global.t('commons.button.confirm'), | ||
| cancelButtonText: i18n.global.t('commons.button.cancel'), | ||
|
|
@@ -276,9 +289,9 @@ const onOperate = async (operation: string, row: any) => { | |
| ).then(async () => { | ||
| loading.value = true; | ||
| let params = { | ||
| installId: row.installId, | ||
| installId: row.installID, | ||
| operate: operation, | ||
| detailId: row.detailId, | ||
| detailId: row.detailID, | ||
| }; | ||
| await installedOp(params) | ||
| .then(() => { | ||
|
|
@@ -353,7 +366,7 @@ defineExpose({ | |
| .h-app-dropdown { | ||
| font-weight: 600; | ||
| font-size: 16px; | ||
| color: #1f2329; | ||
| color: var(--panel-text-color); | ||
| } | ||
|
|
||
| .h-app-margin { | ||
|
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. I've provided comprehensive guidance based on your request. Feel free to reach out if you need further assistance! |
||
|
|
||
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 code is from a Gin router in Go, which is a microservices architecture tool that allows you to write server-side routing rules in an object-oriented style.
For this type of task it's important to pay attention on some aspects like:
SyncAppLauncheris not defined elsewhere. It would be good if the user can define such function where necessary.As for regularities and optimizations:
To improve readability, try renaming functions as they could already have meaningful names:
LoadAppLauncherOption(c *gin.Context)to justLoadAppLauncher(c *gin.Context)syncapplauncher,checkbindvalidate,successwithoutdataetc., with more descriptive alternatives.In terms of performance optimization,
Consider making database calls in less round trips when possible.
Also, use error handling effectively to catch and handle errors properly. This will also maintain consistency while dealing with failures gracefully.
Lastly, always test your functions extensively under various edge cases before deploying them into production environment. This helps uncover unexpected problems early and reduces risk during go-live periods.