Правки кода, завершение настройки после финальной секции
This commit is contained in:
parent
d3fd4f5858
commit
cb44386061
7 changed files with 38 additions and 10 deletions
|
|
@ -12,7 +12,6 @@ import (
|
|||
|
||||
func Start() {
|
||||
//Создаем новый объект Main для настройки.
|
||||
//todo работа внутри apt, вывод интерфейса во время выполнения apt
|
||||
m := NewMain()
|
||||
p := tea.NewProgram(m, tea.WithAltScreen()) //Запускаем через bubble tea программу
|
||||
m.Program = p //Указываем объекту настроек, программу в которой запущен, чтобы передавать туда сигналы
|
||||
|
|
@ -108,7 +107,7 @@ func (m *Main) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||
return types.ShowModalMsg{
|
||||
Type: types.ModalWarning,
|
||||
Title: "Закрытие приложения",
|
||||
Message: "Вы нажали ctrl+c, вы желаете закрыть приложение?",
|
||||
Message: "Вы нажали ctrl+c/ctrl+q, вы желаете закрыть приложение?",
|
||||
ModalButtons: []types.ModalButton{
|
||||
{Text: "Закрыть приложение", Value: true},
|
||||
{Text: "Не закрывать", Value: false},
|
||||
|
|
@ -295,7 +294,7 @@ func (m *Main) executeSectionActions() {
|
|||
for _, action := range m.CurrentSection.Actions {
|
||||
//Если условие для действия не выполняется, то пропускаем
|
||||
if !utils.CheckCondition(action.Condition, m.CurrentApplication) {
|
||||
return
|
||||
continue
|
||||
}
|
||||
sectionActionLog := fmt.Sprintf("Выполнение действия: %s", action.Name)
|
||||
logrus.Infof(sectionActionLog)
|
||||
|
|
@ -330,6 +329,7 @@ func (m *Main) executeSectionActions() {
|
|||
// NextSectionProcess проверяет доступность следующей секции для настройки
|
||||
func (m *Main) NextSectionProcess() (bool, types.ShowModalMsg) {
|
||||
//Ищем индекс следующей секции, если он остался 0, то следующие секции недоступны.
|
||||
//Если текущая секция последняя секция, то завершаем настройку.
|
||||
//Возвращаем модальное окно с выходом к списку приложений
|
||||
nextSectionIndex := 0
|
||||
for sectionIDx := m.CurrentSectionIdx + 1; sectionIDx < len(m.CurrentApplication.Sections); sectionIDx++ {
|
||||
|
|
@ -339,7 +339,22 @@ func (m *Main) NextSectionProcess() (bool, types.ShowModalMsg) {
|
|||
break
|
||||
}
|
||||
}
|
||||
if nextSectionIndex == 0 {
|
||||
|
||||
if nextSectionIndex == 0 && m.CurrentSectionIdx+1 == len(m.CurrentApplication.Sections) {
|
||||
return false, types.ShowModalMsg{
|
||||
Type: types.ModalInfo,
|
||||
Title: "Настройка завершена",
|
||||
Message: "Настройка завершена, нажмите enter чтобы закрыть приложение",
|
||||
ModalButtons: []types.ModalButton{
|
||||
{Text: "Закрыть приложение", Value: true},
|
||||
},
|
||||
OnResult: func(result any) tea.Cmd {
|
||||
return func() tea.Msg {
|
||||
return tea.Quit()
|
||||
}
|
||||
},
|
||||
}
|
||||
} else if nextSectionIndex == 0 {
|
||||
return false, types.ShowModalMsg{
|
||||
Type: types.ModalWarning,
|
||||
Title: "Ошибка секций приложения",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue