|
1 | 1 | <template>
|
2 | 2 | <a-card size="small" :title="t('Timer')" class="settings-card">
|
3 | 3 | <div class="settings-card-row flex-vertical-center">
|
4 |
| - <a-tooltip> |
5 |
| - <template #title>{{ t('TimerServerList') }}</template> |
6 |
| - <span>{{ mt('Server', 'ws', 'List') }}</span> |
7 |
| - </a-tooltip> |
8 |
| - |
| 4 | + <a-switch v-model:checked="store.settings.AutoTimerRestartServer" class="settings-switch" |
| 5 | + @change="changeAutoTimerRestartServer" /> |
| 6 | + <span>{{ t('ServerAutoRestartText') }}</span> |
| 7 | + </div> |
| 8 | + <div class="settings-card-row flex-vertical-center"> |
| 9 | + <span :class="disabledTextClass()">{{ mt('Server', 'ws', 'List') }}:</span> |
9 | 10 | <a-select
|
10 | 11 | v-model:value="store.settings.AutoTimerServerList"
|
11 |
| - :options="TimerServerOptions" |
12 |
| - mode="multiple" |
13 |
| - style="flex: 1" |
14 |
| - placeholder="请选择" |
| 12 | + :options="timerServerOptions" :disabled="!store.settings.AutoTimerRestartServer" |
| 13 | + mode="multiple" style="flex: 1" :placeholder="t('pleaseChoose')" |
15 | 14 | @change="AutoTimerServerChange"
|
16 | 15 | ></a-select>
|
17 | 16 | </div>
|
18 | 17 |
|
19 |
| - <div class="interval-card-row flex-vertical-center"> |
20 |
| - <a-tooltip> |
21 |
| - <template #title>{{ t('RestartIntervalText') }}</template> |
22 |
| - <span>{{ t('RestartIntervalText') }}:</span> |
23 |
| - </a-tooltip> |
24 |
| - |
25 |
| - <a-select v-model:value="store.settings.AutoTimerInterval" :options="intervalOptions" placeholder="选择重启间隔" style="flex: 1" @change="changeAutoTimerInterval"></a-select> |
26 |
| - </div> |
27 |
| - |
28 | 18 | <div class="settings-card-row flex-vertical-center">
|
29 |
| - <a-switch v-model:checked="store.settings.AutoTimerRestartServer" class="settings-switch" @change="changeAutoTimerRestartServer" /> |
30 |
| - <span>{{ t('ServerAutoRestartText') }}</span> |
| 19 | + <span :class="disabledTextClass()">{{ t('RestartIntervalText') }}:</span> |
| 20 | + <a-select v-model:value="store.settings.AutoTimerInterval" |
| 21 | + :options="intervalOptions" :placeholder="t('pleaseChoose')" style="flex: 1" |
| 22 | + :disabled="!store.settings.AutoTimerRestartServer" |
| 23 | + @change="changeAutoTimerInterval" |
| 24 | + ></a-select> |
31 | 25 | </div>
|
32 | 26 | </a-card>
|
33 | 27 | </template>
|
@@ -68,14 +62,10 @@ const ACard = createAsyncComponent(import('ant-design-vue'), 'Card')
|
68 | 62 | const store = useMainStore()
|
69 | 63 | const { serverList } = storeToRefs(store)
|
70 | 64 | const { serverReactive } = inject('GlobalProvide')
|
71 |
| -const TimerServerOptions = computed(() => { |
| 65 | +const timerServerOptions = computed(() => { |
72 | 66 | const options = serverList.value.map((item) => {
|
73 | 67 | const name = item.Name
|
74 |
| - const obj = { value: name, label: item.ServerName ? item.ServerName : name } |
75 |
| - if (name === 'Nginx') { |
76 |
| - obj.disabled = true |
77 |
| - } |
78 |
| - return obj |
| 68 | + return { value: name, label: item.ServerName ? item.ServerName : name } |
79 | 69 | })
|
80 | 70 | options.unshift({ label: t('Website') + ' PHP-FPM', value: 'PHP-FPM' })
|
81 | 71 | return options
|
@@ -128,6 +118,8 @@ const changeAutoTimerRestartServer = () => {
|
128 | 118 | store.setSettings('AutoTimerRestartServer')
|
129 | 119 | setRestartTimer()
|
130 | 120 | }
|
| 121 | +
|
| 122 | +const disabledTextClass = () => !store.settings.AutoTimerRestartServer ? 'disabled-text' : '' |
131 | 123 | </script>
|
132 | 124 |
|
133 | 125 | <style scoped></style>
|
0 commit comments