Skip to content

Commit

Permalink
add not display and not inited
Browse files Browse the repository at this point in the history
  • Loading branch information
noO0ob committed Nov 6, 2024
1 parent d9a0a0d commit a19135a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
10 changes: 4 additions & 6 deletions frontend/src/views/settings/SettingDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,10 @@ export default {
return
}
// change setting item, data refresh
if (typeof newValue.submitText === 'string' && newValue.submitText.trim().length > 0) {
this.submitButtonText = newValue.submitText
}
if (newValue.language === 'cn') {
this.submitButtonText = '提交'
this.recoveryButtonText = '恢复默认'
for (const item of this.dictHeaderTemplate) {
item['text'] = item['textCn']
Expand All @@ -162,18 +164,14 @@ export default {
item['text'] = item['textCn']
}
} else {
this.submitButtonText = 'Submit'
this.submitButtonText = 'Restore default'
this.recoveryButtonText = 'Restore default'
for (const item of this.dictHeaderTemplate) {
item['text'] = item['textEn']
}
for (const item of this.listHeaderTemplate) {
item['text'] = item['textEn']
}
}
if (typeof newValue.submitText === 'string' && newValue.submitText.trim().length > 0) {
this.submitButtonText = newValue.submitText
}
for (const config of newValue.configs) {
if (config.category == 'text' || config.category == 'selector' || config.category == 'bool') {
Expand Down
2 changes: 1 addition & 1 deletion lyrebird/mock/blueprints/apis/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def get(self, action):
if action == 'list':
resp_dict = {}
for script_name, script in application.settings.items():
if not script.inited:
if not script.inited or not script.template.display:
continue
if script.category_md5 not in resp_dict:
resp_dict[script.category_md5] = {
Expand Down
13 changes: 13 additions & 0 deletions lyrebird/settings/settings_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ def load(self):
self.inited = True

def getter(self):
if not self.inited:
return f'Setting item operate is blocked, because it load failed, item name:{self.name}'
res = {}
try:
res = self.template.getter()
Expand All @@ -58,6 +60,8 @@ def getter(self):
return res

def setter(self, data):
if not self.inited:
return f'Setting item operate is blocked, because it load failed, item name:{self.name}'
res = ''
try:
res = self.template.setter(data)
Expand All @@ -67,6 +71,8 @@ def setter(self, data):
return res

def restore(self):
if not self.inited:
return f'Setting item operate is blocked, because it load failed, item name:{self.name}'
res = ''
try:
res = self.template.restore()
Expand All @@ -76,6 +82,8 @@ def restore(self):
return res

def load_finished(self):
if not self.inited:
return f'Setting item operate is blocked, because it load failed, item name:{self.name}'
res = ''
try:
res = self.template.load_finished()
Expand All @@ -85,6 +93,8 @@ def load_finished(self):
return res

def load_prepared(self):
if not self.inited:
return f'Setting item operate is blocked, because it load failed, item name:{self.name}'
res = ''
try:
res = self.template.load_prepared()
Expand All @@ -94,6 +104,8 @@ def load_prepared(self):
return res

def destory(self):
if not self.inited:
return f'Setting item operate is blocked, because it load failed, item name:{self.name}'
try:
self.template.destory()
except Exception as e:
Expand Down Expand Up @@ -184,6 +196,7 @@ def write_config(self, obj:SettingsTemplate, data={}):
}
if data:
template[template_key].update(data)
self.configs.update(template)
application._cm.update_personal_config(template)

def get_config(self, obj:SettingsTemplate):
Expand Down

0 comments on commit a19135a

Please sign in to comment.