From 7e4606eda51d91a1697eba380fa32acae58a215b Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Fri, 1 Mar 2024 13:51:01 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E9=98=B2=E7=AF=A1?= =?UTF-8?q?=E6=94=B9=E5=8A=9F=E8=83=BD=20(#4016)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/lang/modules/en.ts | 37 +++++++++++++-- frontend/src/lang/modules/tw.ts | 29 ++++++++++-- frontend/src/lang/modules/zh.ts | 26 ++++++++++- frontend/src/utils/shortcuts.ts | 45 ++++++++++++++++++ frontend/src/views/cronjob/helper.ts | 46 ------------------- frontend/src/views/cronjob/record/index.vue | 2 +- .../src/views/host/monitor/monitor/index.vue | 44 +----------------- 7 files changed, 130 insertions(+), 99 deletions(-) create mode 100644 frontend/src/utils/shortcuts.ts diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index 7e93841c9..45adf9403 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -291,6 +291,7 @@ const message = { process: 'Process', network: 'Network', supervisor: 'Supervisor', + name: 'Tamper Proof', }, home: { restart_1panel: 'Restart Panel', @@ -2145,16 +2146,42 @@ const message = { name: 'X-Pack', waf: { name: 'WAF', - blackWhite: 'black and white list', + blackWhite: 'Black and White List', globalSetting: 'Global Setting', - websiteSetting: 'Website Settings', - blockRecords: 'Block records', + websiteSetting: 'Website Setting', + blockRecords: 'Block Records', }, monitor: { - name: 'Website monitoring', + name: 'Website Monitoring', }, tamper: { - name: 'Tamper-proof', + tamperHelper1: + 'One-click deployment type of website, it is recommended to enable the application directory anti-tampering function;', + tamperHelper2: + 'If the website cannot be used normally or backup and restore fail after enabling the anti-tampering function, please disable the anti-tampering function first;', + tamperHelper3: + 'Enabling tamper-proofing will restrict reading, writing, deleting, permission, and owner modification operations of protected files under non-excluded directories. Please choose carefully when setting [Exclude Directory] and [Protect].', + op: 'Operation', + create: 'Create', + file: 'File', + tamperPath: 'Protection Directory', + tamperPathEdit: 'Modify Path', + log: 'Intercept Logs', + totalProtect: 'Total Protection', + todayProtect: 'Today’s Protection', + addRule: 'Add Rule', + ignore: 'Exclude Directory', + ignoreHelper: 'One per line, e.g., \ntmp\n./tmp', + ignoreHelper1: 'Add folder names or specific paths to ignore', + ignoreHelper2: 'To ignore specific folders, use relative paths starting with ./', + protect: 'Protect', + protectHelper: 'One per line, e.g., \npng\n./test.css', + protectHelper1: 'Specify file names, suffixes, or specific files for protection', + protectHelper2: 'To protect specific files, use relative paths starting with ./', + enableHelper: + 'The anti-tampering function of website {0} is about to be enabled to enhance website security. Do you want to continue?', + disableHelper: + 'The anti-tampering function of website {0} is about to be disabled. Do you want to continue?', }, }, }, diff --git a/frontend/src/lang/modules/tw.ts b/frontend/src/lang/modules/tw.ts index c35f4643d..4b437c183 100644 --- a/frontend/src/lang/modules/tw.ts +++ b/frontend/src/lang/modules/tw.ts @@ -288,6 +288,7 @@ const message = { process: '進程', network: '網絡', supervisor: '進程守護', + tamper: '防篡改', }, home: { restart_1panel: '重啟面板', @@ -2008,15 +2009,37 @@ const message = { waf: { name: 'WAF', blackWhite: '黑白名單', - globalSetting: '全域設定', - websiteSetting: '網站設定', + globalSetting: '全局設置', + websiteSetting: '網站設置', blockRecords: '封鎖記錄', }, monitor: { name: '網站監控', }, tamper: { - name: '防篡改', + tamperHelper1: '一鍵部署類型的網站,建議啟用應用目錄防篡改功能;', + tamperHelper2: '如果在啟用防篡改功能後出現網站無法正常使用或備份、恢復失敗的情況,請先關閉防篡改功能;', + tamperHelper3: + '啟用防篡改,將限制非排除目錄下受保護文件的讀寫、刪除、權限和所有者修改操作,請在設定 [排除目錄] 和 [保護] 時謹慎選擇。', + op: '操作', + create: '創建', + file: '文件', + tamperPath: '防護目錄', + tamperPathEdit: '修改路徑', + log: '攔截日誌', + totalProtect: '總防護', + todayProtect: '今日防護', + addRule: '添加規則', + ignore: '排除目錄', + ignoreHelper: '一行一個,例: \ntmp\n./tmp', + ignoreHelper1: '添加要忽略的文件夾名或特定路徑', + ignoreHelper2: '要忽略特定文件夾,請使用以 ./ 開頭的相對路徑', + protect: '保護', + protectHelper: '一行一個,例: \npng\n./test.css', + protectHelper1: '可指定文件名、後綴名或特定文件進行保護', + protectHelper2: '要保護特定文件,請使用以 ./ 開頭的相對路徑', + enableHelper: '即將啟用 {0} 網站的防窜改功能,以提升網站安全性,是否繼續?', + disableHelper: '即將關閉 {0} 網站的防窜改功能,是否繼續?', }, }, }, diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index 5aa6c9d28..fb0398be4 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -288,6 +288,7 @@ const message = { process: '进程', network: '网络', supervisor: '进程守护', + tamper: '防篡改', }, home: { restart_1panel: '重启面板', @@ -2017,7 +2018,30 @@ const message = { name: '网站监控', }, tamper: { - name: '防篡改', + tamper: '防篡改', + tamperHelper1: '一键部署类型的网站,建议启用应用目录防篡改功能;', + tamperHelper2: '如果在启用防篡改功能后出现网站无法正常使用或备份、恢复失败的情况,请先关闭防篡改功能;', + tamperHelper3: + '启用防篡改,将限制非排除目录下受保护文件的读写、删除、权限和所有者修改操作,请在设定 [排除目录] 和 [保护] 时谨慎选择。', + op: '操作', + create: '创建', + file: '文件', + tamperPath: '防护目录', + tamperPathEdit: '修改路径', + log: '拦截日志', + totalProtect: '总防护', + todayProtect: '今日防护', + addRule: '添加规则', + ignore: '排除目录', + ignoreHelper: '一行一个,例: \ntmp\n./tmp', + ignoreHelper1: '添加要忽略的文件夹名或特定路径', + ignoreHelper2: '要忽略特定文件夹,请使用以 ./ 开头的相对路径', + protect: '保护', + protectHelper: '一行一个,例: \npng\n./test.css', + protectHelper1: '可指定文件名、后缀名或特定文件进行保护', + protectHelper2: '要保护特定文件,请使用以 ./ 开头的相对路径', + enableHelper: '即将启用 {0} 网站的防窜改功能,以提升网站安全性,是否继续?', + disableHelper: '即将关闭 {0} 网站的防窜改功能,是否继续?', }, }, }; diff --git a/frontend/src/utils/shortcuts.ts b/frontend/src/utils/shortcuts.ts new file mode 100644 index 000000000..a340955b7 --- /dev/null +++ b/frontend/src/utils/shortcuts.ts @@ -0,0 +1,45 @@ +import i18n from '@/lang'; + +export const shortcuts = [ + { + text: i18n.global.t('monitor.today'), + value: () => { + const end = new Date(); + const start = new Date(new Date().setHours(0, 0, 0, 0)); + return [start, end]; + }, + }, + { + text: i18n.global.t('monitor.yesterday'), + value: () => { + const yesterday = new Date(new Date().getTime() - 3600 * 1000 * 24 * 1); + const end = new Date(yesterday.setHours(23, 59, 59, 999)); + const start = new Date(yesterday.setHours(0, 0, 0, 0)); + return [start, end]; + }, + }, + { + text: i18n.global.t('monitor.lastNDay', [3]), + value: () => { + const start = new Date(new Date().getTime() - 3600 * 1000 * 24 * 3); + const end = new Date(); + return [start, end]; + }, + }, + { + text: i18n.global.t('monitor.lastNDay', [7]), + value: () => { + const start = new Date(new Date().getTime() - 3600 * 1000 * 24 * 7); + const end = new Date(); + return [start, end]; + }, + }, + { + text: i18n.global.t('monitor.lastNDay', [30]), + value: () => { + const start = new Date(new Date().getTime() - 3600 * 1000 * 24 * 30); + const end = new Date(); + return [start, end]; + }, + }, +]; diff --git a/frontend/src/views/cronjob/helper.ts b/frontend/src/views/cronjob/helper.ts index be0544bda..fb9556464 100644 --- a/frontend/src/views/cronjob/helper.ts +++ b/frontend/src/views/cronjob/helper.ts @@ -2,52 +2,6 @@ import { Cronjob } from '@/api/interface/cronjob'; import i18n from '@/lang'; import { loadZero } from '@/utils/util'; -export const shortcuts = [ - { - text: i18n.global.t('monitor.today'), - value: () => { - const end = new Date(new Date().setHours(23, 59, 59, 999)); - const start = new Date(new Date().setHours(0, 0, 0, 0)); - return [start, end]; - }, - }, - { - text: i18n.global.t('monitor.yesterday'), - value: () => { - const itemDate = new Date(new Date().getTime() - 3600 * 1000 * 24 * 1); - const end = new Date(itemDate.setHours(23, 59, 59, 999)); - const start = new Date(itemDate.setHours(0, 0, 0, 0)); - return [start, end]; - }, - }, - { - text: i18n.global.t('monitor.lastNDay', [3]), - value: () => { - const itemDate = new Date(new Date().getTime() - 3600 * 1000 * 24 * 3); - const end = new Date(new Date().setHours(23, 59, 59, 999)); - const start = new Date(itemDate.setHours(0, 0, 0, 0)); - return [start, end]; - }, - }, - { - text: i18n.global.t('monitor.lastNDay', [7]), - value: () => { - const itemDate = new Date(new Date().getTime() - 3600 * 1000 * 24 * 7); - const end = new Date(new Date().setHours(23, 59, 59, 999)); - const start = new Date(itemDate.setHours(0, 0, 0, 0)); - return [start, end]; - }, - }, - { - text: i18n.global.t('monitor.lastNDay', [30]), - value: () => { - const itemDate = new Date(new Date().getTime() - 3600 * 1000 * 24 * 30); - const end = new Date(new Date().setHours(23, 59, 59, 999)); - const start = new Date(itemDate.setHours(0, 0, 0, 0)); - return [start, end]; - }, - }, -]; export const specOptions = [ { label: i18n.global.t('cronjob.perMonth'), value: 'perMonth' }, { label: i18n.global.t('cronjob.perWeek'), value: 'perWeek' }, diff --git a/frontend/src/views/cronjob/record/index.vue b/frontend/src/views/cronjob/record/index.vue index bd9384669..598eaebeb 100644 --- a/frontend/src/views/cronjob/record/index.vue +++ b/frontend/src/views/cronjob/record/index.vue @@ -245,7 +245,7 @@ import { oneDark } from '@codemirror/theme-one-dark'; import { MsgSuccess } from '@/utils/message'; import { listDbItems } from '@/api/modules/database'; import { ListAppInstalled } from '@/api/modules/app'; -import { shortcuts } from './../helper'; +import { shortcuts } from '@/utils/shortcuts'; const loading = ref(); const refresh = ref(false); diff --git a/frontend/src/views/host/monitor/monitor/index.vue b/frontend/src/views/host/monitor/monitor/index.vue index cd4317d03..abf4924a9 100644 --- a/frontend/src/views/host/monitor/monitor/index.vue +++ b/frontend/src/views/host/monitor/monitor/index.vue @@ -208,6 +208,7 @@ import { computeSizeFromKBs, dateFormatWithoutYear } from '@/utils/util'; import i18n from '@/lang'; import MonitorRouter from '@/views/host/monitor/index.vue'; import { GlobalStore } from '@/store'; +import { shortcuts } from '@/utils/shortcuts'; const globalStore = GlobalStore(); @@ -227,49 +228,6 @@ const networkChoose = ref(); const netOptions = ref(); const chartsOption = ref({ loadLoadChart: null, loadCPUChart: null, loadMemoryChart: null, loadNetworkChart: null }); -const shortcuts = [ - { - text: i18n.global.t('monitor.today'), - value: () => { - const end = new Date(); - const start = new Date(new Date().setHours(0, 0, 0, 0)); - return [start, end]; - }, - }, - { - text: i18n.global.t('monitor.yesterday'), - value: () => { - const yesterday = new Date(new Date().getTime() - 3600 * 1000 * 24 * 1); - const end = new Date(yesterday.setHours(23, 59, 59, 999)); - const start = new Date(yesterday.setHours(0, 0, 0, 0)); - return [start, end]; - }, - }, - { - text: i18n.global.t('monitor.lastNDay', [3]), - value: () => { - const start = new Date(new Date().getTime() - 3600 * 1000 * 24 * 3); - const end = new Date(); - return [start, end]; - }, - }, - { - text: i18n.global.t('monitor.lastNDay', [7]), - value: () => { - const start = new Date(new Date().getTime() - 3600 * 1000 * 24 * 7); - const end = new Date(); - return [start, end]; - }, - }, - { - text: i18n.global.t('monitor.lastNDay', [30]), - value: () => { - const start = new Date(new Date().getTime() - 3600 * 1000 * 24 * 30); - const end = new Date(); - return [start, end]; - }, - }, -]; const searchTime = ref(); const searchInfo = reactive({ param: '',