From f24913dfe21e17211578967c156ab0fedb325f8f Mon Sep 17 00:00:00 2001 From: xianyunleo Date: Thu, 31 Oct 2024 18:26:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/utils/utils.js | 5 ++- src/renderer/components/Settings/Server.vue | 27 ++++++------- src/renderer/components/Settings/Timer.vue | 44 +++++++++------------ src/renderer/store/index.js | 6 +-- src/renderer/views/Home.vue | 12 +++--- 5 files changed, 41 insertions(+), 53 deletions(-) diff --git a/src/main/utils/utils.js b/src/main/utils/utils.js index 4a71ea58..dd86c203 100644 --- a/src/main/utils/utils.js +++ b/src/main/utils/utils.js @@ -6,9 +6,10 @@ export const isDev = process.resourcesPath.includes(`${sep}node_modules${sep}`) export const isWindows = OS.isWindows() export const isMacOS = OS.isMacOS() -export function devConsoleLog(...str) { +export function devConsoleLog(...inputArr) { if (isDev) { - console.log(...str) + const outputArr = inputArr.map((input) => (typeof input === 'function' ? input() : input)) + console.log(...outputArr) } } diff --git a/src/renderer/components/Settings/Server.vue b/src/renderer/components/Settings/Server.vue index 7a66c04a..d6a39859 100644 --- a/src/renderer/components/Settings/Server.vue +++ b/src/renderer/components/Settings/Server.vue @@ -1,28 +1,26 @@ @@ -40,11 +38,7 @@ const { serverList } = storeToRefs(store) const oneClickServerOptions = computed(() => { const options = serverList.value.map((item) => { const name = item.Name - const obj = { value: name, label: item.ServerName ? item.ServerName : name } - if (name === 'Nginx') { - obj.disabled = true - } - return obj + return { value: name, label: item.ServerName ? item.ServerName : name } }) options.unshift({ label: t('Website') + ' PHP-FPM', value: 'PHP-FPM' }) return options @@ -59,6 +53,9 @@ const changeAutoStartAndRestartServer = () => { const changeAfterOpenAppStartServer = () => { store.setSettings('AfterOpenAppStartServer') } + +const emptyOneClickServerList = () => store.settings.OneClickServerList.length === 0 +const disabledTextClass = () => emptyOneClickServerList() ? 'disabled-text' : '' diff --git a/src/renderer/components/Settings/Timer.vue b/src/renderer/components/Settings/Timer.vue index 73fbe2a3..56af1335 100644 --- a/src/renderer/components/Settings/Timer.vue +++ b/src/renderer/components/Settings/Timer.vue @@ -1,33 +1,27 @@ @@ -68,14 +62,10 @@ const ACard = createAsyncComponent(import('ant-design-vue'), 'Card') const store = useMainStore() const { serverList } = storeToRefs(store) const { serverReactive } = inject('GlobalProvide') -const TimerServerOptions = computed(() => { +const timerServerOptions = computed(() => { const options = serverList.value.map((item) => { const name = item.Name - const obj = { value: name, label: item.ServerName ? item.ServerName : name } - if (name === 'Nginx') { - obj.disabled = true - } - return obj + return { value: name, label: item.ServerName ? item.ServerName : name } }) options.unshift({ label: t('Website') + ' PHP-FPM', value: 'PHP-FPM' }) return options @@ -128,6 +118,8 @@ const changeAutoTimerRestartServer = () => { store.setSettings('AutoTimerRestartServer') setRestartTimer() } + +const disabledTextClass = () => !store.settings.AutoTimerRestartServer ? 'disabled-text' : '' diff --git a/src/renderer/store/index.js b/src/renderer/store/index.js index fd22bb74..e437b790 100644 --- a/src/renderer/store/index.js +++ b/src/renderer/store/index.js @@ -34,11 +34,11 @@ export const useMainStore = defineStore('main', { return { ...item, Installed } })) }, - async setSettings(key, callback = null) { + async setSettings(key, beforeFunc = null) { const originVal = Settings.get(key) try { - if (callback) { - const res = await callback(originVal) + if (beforeFunc) { + const res = await beforeFunc(originVal) if (res === false) { return } diff --git a/src/renderer/views/Home.vue b/src/renderer/views/Home.vue index 66308c76..67b9ef56 100644 --- a/src/renderer/views/Home.vue +++ b/src/renderer/views/Home.vue @@ -80,7 +80,6 @@