mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-09-10 16:46:26 +08:00
feat: Optimize code (#10063)
This commit is contained in:
parent
a07df9d7fe
commit
536a5fc1a0
4 changed files with 16 additions and 8 deletions
|
@ -700,7 +700,6 @@ func shouldSendResourceAlert(alert dto.AlertDTO, currentUsage float64, usageLoad
|
|||
if len(*usageLoad) == threshold {
|
||||
avgUsage := average(*usageLoad)
|
||||
if avgUsage >= float64(alert.Count) {
|
||||
//global.LOG.Infof("%d minute %s: %f , usage: %v", threshold, alert.Type, avgUsage, usageLoad)
|
||||
sendResourceAlert(alert, avgUsage)
|
||||
}
|
||||
}
|
||||
|
@ -736,7 +735,6 @@ func getModuleName(alertType string) string {
|
|||
return module
|
||||
}
|
||||
|
||||
// 检查是否超过今日发送次数限制
|
||||
func canSendAlertToday(alertType, quotaType string, sendCount uint, method string) (uint, bool) {
|
||||
todayCount, _, err := alertRepo.LoadTaskCount(alertType, quotaType, method)
|
||||
if err != nil {
|
||||
|
|
|
@ -194,6 +194,7 @@ defineExpose({
|
|||
clearSelects,
|
||||
sort,
|
||||
clearSort,
|
||||
closeRightClick,
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
|
|
|
@ -675,12 +675,14 @@ let fileTypes = {
|
|||
text: ['.iso', '.tiff', '.exe', '.so', '.bz', '.dmg', '.apk', '.pptx', '.ppt', '.xlsb'],
|
||||
};
|
||||
|
||||
export const getFileType = (extension?: string) => {
|
||||
const ext = extension?.toLowerCase();
|
||||
if (!ext) return 'text';
|
||||
|
||||
const match = Object.entries(fileTypes).find((extensions) => extensions.includes(ext));
|
||||
return match ? match[0] : 'text';
|
||||
export const getFileType = (extension: string) => {
|
||||
let type = 'text';
|
||||
Object.entries(fileTypes).forEach(([key, extensions]) => {
|
||||
if (extensions.includes(extension.toLowerCase())) {
|
||||
type = key;
|
||||
}
|
||||
});
|
||||
return type;
|
||||
};
|
||||
|
||||
export const newUUID = () => {
|
||||
|
|
|
@ -725,6 +725,7 @@ const viewHideFile = async () => {
|
|||
};
|
||||
|
||||
const open = async (row: File.File) => {
|
||||
hideRightMenu();
|
||||
calculateBtn.value = false;
|
||||
disableBtn.value = false;
|
||||
if (row.isDir) {
|
||||
|
@ -866,6 +867,7 @@ const top = () => {
|
|||
};
|
||||
|
||||
const jump = async (url: string) => {
|
||||
hideRightMenu();
|
||||
history.splice(pointer + 1);
|
||||
history.push(url);
|
||||
pointer = history.length - 1;
|
||||
|
@ -1199,6 +1201,7 @@ const openMoveBtn = (type: string, item: File.File) => {
|
|||
const closeMove = () => {
|
||||
selects.value = [];
|
||||
tableRef.value.clearSelects();
|
||||
hideRightMenu();
|
||||
fileMove.oldPaths = [];
|
||||
fileMove.name = '';
|
||||
fileMove.count = 0;
|
||||
|
@ -1425,6 +1428,10 @@ const handleDragleave = (event: { preventDefault: () => void }) => {
|
|||
event.preventDefault();
|
||||
};
|
||||
|
||||
function hideRightMenu() {
|
||||
tableRef.value.closeRightClick();
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
if (localStorage.getItem('show-hidden') === null) {
|
||||
localStorage.setItem('show-hidden', 'true');
|
||||
|
|
Loading…
Add table
Reference in a new issue