Skip to content

Commit

Permalink
feat: soft shutdown shell ui
Browse files Browse the repository at this point in the history
  • Loading branch information
JdaieLin committed Jun 1, 2022
1 parent 88245b8 commit 835b313
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 3 deletions.
11 changes: 9 additions & 2 deletions electron/src/renderer/components/MainWindow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,11 @@
</el-switch>
<span class="form-item-desc">{{$t('softPoweroffDesc')}}</span>
</el-form-item>
<el-form-item v-if="softPoweroffEnabled" :label="$t('softPoweroffShell')">
<br/>
<span class="form-item-desc">{{$t('softPoweroffShellDesc')}}</span>
<el-input v-model="softPoweroffShell" autocomplete="off" :placeholder="$t('shellPlaceholder')"></el-input>
</el-form-item>
</template>
<!-- version 2 -->
<el-form-item v-if="isModel2">
Expand All @@ -281,7 +286,7 @@
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="settingDialog = false">{{$t('cancel')}}</el-button>
<el-button type="primary" @click="chargeConfirm">{{$t('confirm')}}</el-button>
<el-button type="primary" @click="handleAdvanceSettingConfirm">{{$t('confirm')}}</el-button>
</div>
</el-dialog>

Expand Down Expand Up @@ -416,6 +421,7 @@
timeUpdaterCount: 0,
inputProtectEnabled: false,
softPoweroffEnabled: false,
softPoweroffShell: '',
antiMistouchEnabled: false,
isTimeEditFocused: false,
adjustPPM: 0,
Expand Down Expand Up @@ -780,7 +786,7 @@
}
window.location.reload()
},
chargeConfirm () {
handleAdvanceSettingConfirm () {
this.settingDialog = false
if (this.isModel2Adv) {
const value = this.chargingRestartPoint === 100 ? '' : ` ${this.chargingRestartPoint},100`
Expand All @@ -790,6 +796,7 @@
this.$socket.send(`set_battery_input_protect ${!!this.inputProtectEnabled}`)
this.$socket.send(`set_anti_mistouch ${!!this.antiMistouchEnabled}`)
this.$socket.send(`set_soft_poweroff ${!!this.softPoweroffEnabled}`)
this.$socket.send(`set_soft_poweroff_shell ${this.softPoweroffShell}`)
}
},
getDeviceTime () {
Expand Down
5 changes: 5 additions & 0 deletions electron/src/renderer/components/socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const initCommands = [
'get battery_input_protect_enabled',
'get auth_username',
'get soft_poweroff',
'get soft_poweroff_shell',
'get anti_mistouch'
]

Expand Down Expand Up @@ -154,6 +155,10 @@ export async function onSocketMessage (e) {
this.passwordForm.username = msg.replace('auth_username: ', '').trim()
return
}
if (msg.startsWith('soft_poweroff_shell:')) {
this.softPoweroffShell = msg.replace('soft_poweroff_shell: ', '').trim()
return
}
if (msg.startsWith('soft_poweroff:')) {
this.softPoweroffEnabled = (msg.replace('soft_poweroff: ', '').trim() === 'true')
return
Expand Down
4 changes: 3 additions & 1 deletion electron/src/renderer/locale/en-US.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ module.exports = {
antiMistouchDesc: 'When the anti-mistouch is turned on, the switch needs to be clicked and held to trigger.',
softPoweroff: 'Soft Shutdown',
softPoweroffDesc: 'Using the switch button to shut down will not directly power off, the shutdown command will be issued by the software.',
softPoweroffShell: 'Soft Shutdown Shell',
softPoweroffShellDesc: 'Shell to execute when soft shutdown is triggered.',
changeLoginPassword: 'Change Login Password',
username: 'Username',
password: 'Password',
Expand All @@ -82,5 +84,5 @@ module.exports = {
passwordNotConsistent: 'Two input password must be consistent',
usernameWithSpace: 'Username cannot contain spaces',
passwordWithSpace: 'Password cannot contain spaces',
changePasswordSuccess: 'The modification is complete.'
changePasswordSuccess: 'The modification is complete.',
}
2 changes: 2 additions & 0 deletions electron/src/renderer/locale/ru-RU.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ module.exports = {
antiMistouchDesc: 'После того, как защита от прикосновения включена, переключатель необходимо щелкнуть + длительное нажатие для срабатывания.',
softPoweroff: 'Мягкое отключение',
softPoweroffDesc: 'Использование кнопки переключения для выключения не приведет к прямому отключению питания, команда выключения будет выдана программным обеспечением.',
softPoweroffShell: 'Оболочка мягкого отключения',
softPoweroffShellDesc: 'Оболочка для выполнения при срабатывании мягкого завершения работы.',
changeLoginPassword: 'Изменить пароль для входа',
username: 'имя пользователя',
password: 'пароль',
Expand Down
2 changes: 2 additions & 0 deletions electron/src/renderer/locale/zh-CN.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ module.exports = {
antiMistouchDesc: '防误触开启后,开关需要单击+长按方式才能触发。',
softPoweroff: '软关机',
softPoweroffDesc: '使用开关按键关机将不会直接断电,而是由软件发出关机指令。',
softPoweroffShell: '软关机Shell',
softPoweroffShellDesc: '将在软关机被触发时(关机前)执行的shell指令。',
changeLoginPassword: '修改登录密码',
username: '用户名',
password: '密码',
Expand Down

0 comments on commit 835b313

Please sign in to comment.