From 90faf1007e46c09dbafed0439703ccde2c153da0 Mon Sep 17 00:00:00 2001 From: 87owo <85057800+87owo@users.noreply.github.com> Date: Wed, 6 May 2026 14:14:48 +0800 Subject: [PATCH] Add files via upload --- Interface/static/css/style.css | 38 +++++++++++++++++++++ Interface/static/js/i18n.js | 33 ++++++++++++------ Interface/static/js/main.js | 61 ++++++++++++++++++++++++++++++++++ PYAS.py | 3 +- 4 files changed, 123 insertions(+), 12 deletions(-) diff --git a/Interface/static/css/style.css b/Interface/static/css/style.css index 11f571a..a5d9dcc 100644 --- a/Interface/static/css/style.css +++ b/Interface/static/css/style.css @@ -797,6 +797,44 @@ body.resizing-active * { color: var(--text-primary); } +.custom-context-menu { + position: absolute; + z-index: 10000; + background-color: var(--bg-panel); + border: 1px solid var(--border-color); + border-radius: 8px; + box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); + padding: 4px; + display: none; + min-width: 160px; +} + +.custom-context-menu.show { + display: block; +} + +.custom-context-menu-item { + display: flex; + align-items: center; + gap: 10px; + padding: 8px 12px; + border-radius: 6px; + cursor: pointer; + font-size: 13px; + color: var(--text-primary); + transition: background-color 0.2s; +} + +.custom-context-menu-item:hover { + background-color: var(--bg-hover); +} + +.custom-context-menu-item svg { + width: 16px; + height: 16px; + color: var(--text-secondary); +} + ::-webkit-scrollbar { width: 6px; height: 6px; } ::-webkit-scrollbar-track { background: transparent; } ::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 10px; } diff --git a/Interface/static/js/i18n.js b/Interface/static/js/i18n.js index 58ebed6..c15f180 100644 --- a/Interface/static/js/i18n.js +++ b/Interface/static/js/i18n.js @@ -124,7 +124,8 @@ window.AppI18n = { "類別": "類別", "標題": "標題", "修復項目": "修復項目", - "全選": "全選" + "全選": "全選", + "打開檔案所在位置": "打開檔案所在位置" }, "simplified_switch": { "PYAS Security": "PYAS Security", @@ -250,7 +251,8 @@ window.AppI18n = { "類別": "类别", "標題": "标题", "修復項目": "修复项目", - "全選": "全选" + "全選": "全选", + "打開檔案所在位置": "打开文件所在位置" }, "english_switch": { "PYAS Security": "PYAS Security", @@ -376,7 +378,8 @@ window.AppI18n = { "類別": "Class", "標題": "Title", "修復項目": "Repair Items", - "全選": "Select All" + "全選": "Select All", + "打開檔案所在位置": "Open file location" }, "japanese_switch": { "PYAS Security": "PYAS Security", @@ -502,7 +505,8 @@ window.AppI18n = { "類別": "クラス", "標題": "タイトル", "修復項目": "修復項目", - "全選": "すべて選択" + "全選": "すべて選択", + "打開檔案所在位置": "ファイルの場所を開く" }, "korean_switch": { "PYAS Security": "PYAS Security", @@ -628,7 +632,8 @@ window.AppI18n = { "類別": "클래스", "標題": "제목", "修復項目": "복구 항목", - "全選": "전체 선택" + "全選": "전체 선택", + "打開檔案所在位置": "파일 위치 열기" }, "french_switch": { "PYAS Security": "PYAS Security", @@ -754,7 +759,8 @@ window.AppI18n = { "類別": "Classe", "標題": "Titre", "修復項目": "Éléments de réparation", - "全選": "Tout sélectionner" + "全選": "Tout sélectionner", + "打開檔案所在位置": "Ouvrir l'emplacement du fichier" }, "spanish_switch": { "PYAS Security": "PYAS Security", @@ -880,7 +886,8 @@ window.AppI18n = { "類別": "Clase", "標題": "Título", "修復項目": "Elementos de reparación", - "全選": "Seleccionar todo" + "全選": "Seleccionar todo", + "打開檔案所在位置": "Abrir ubicación de archivo" }, "hindi_switch": { "PYAS Security": "PYAS Security", @@ -1006,7 +1013,8 @@ window.AppI18n = { "類別": "वर्ग", "標題": "शीर्षक", "修復項目": "मरम्मत आइटम", - "全選": "सभी चुनें" + "全選": "सभी चुनें", + "打開檔案所在位置": "फ़ाइल स्थान खोलें" }, "arabic_switch": { "PYAS Security": "PYAS Security", @@ -1132,7 +1140,8 @@ window.AppI18n = { "類別": "الفئة", "標題": "العنوان", "修復項目": "عناصر الإصلاح", - "全選": "تحديد الكل" + "全選": "تحديد الكل", + "打開檔案所在位置": "فتح موقع الملف" }, "russian_switch": { "PYAS Security": "PYAS Security", @@ -1258,7 +1267,8 @@ window.AppI18n = { "類別": "Класс", "標題": "Заголовок", "修復項目": "Элементы восстановления", - "全選": "Выбрать все" + "全選": "Выбрать все", + "打開檔案所在位置": "Открыть расположение файла" }, "slovenian_switch": { "PYAS Security": "PYAS Security", @@ -1384,7 +1394,8 @@ window.AppI18n = { "類別": "Razred", "標題": "Naslov", "修復項目": "Predmeti za popravilo", - "全選": "Izberi vse" + "全選": "Izberi vse", + "打開檔案所在位置": "Odpri mesto datoteke" } }, langMap: { diff --git a/Interface/static/js/main.js b/Interface/static/js/main.js index 095cc4b..f97ffb5 100644 --- a/Interface/static/js/main.js +++ b/Interface/static/js/main.js @@ -1172,4 +1172,65 @@ document.addEventListener('DOMContentLoaded', () => { }); } }); + + const contextMenu = document.createElement('div'); + contextMenu.className = 'custom-context-menu'; + contextMenu.innerHTML = ` +
+ `; + document.body.appendChild(contextMenu); + + const ctxSpan = contextMenu.querySelector('span[data-i18n]'); + ctxSpan.dataset.originText = ctxSpan.textContent.trim(); + + let contextMenuTarget = null; + + document.addEventListener('contextmenu', (e) => { + const listItem = e.target.closest('.manage-list-item'); + if (listItem) { + const cb = listItem.querySelector('input[type="checkbox"]'); + const path = cb ? cb.dataset.path : null; + + if (path && path !== "Unknown" && path !== "None") { + e.preventDefault(); + contextMenuTarget = path; + + ctxSpan.textContent = getMsg(ctxSpan.dataset.originText); + + contextMenu.style.left = `${e.clientX}px`; + contextMenu.style.top = `${e.clientY}px`; + contextMenu.classList.add('show'); + + const rect = contextMenu.getBoundingClientRect(); + if (rect.right > window.innerWidth) { + contextMenu.style.left = `${window.innerWidth - rect.width - 5}px`; + } + if (rect.bottom > window.innerHeight) { + contextMenu.style.top = `${window.innerHeight - rect.height - 5}px`; + } + return; + } + } + contextMenu.classList.remove('show'); + }); + + document.addEventListener('click', (e) => { + if (!e.target.closest('.custom-context-menu')) { + contextMenu.classList.remove('show'); + } + }); + + document.addEventListener('scroll', () => { + contextMenu.classList.remove('show'); + }, true); + + document.getElementById('ctx_open_location').addEventListener('click', () => { + if (window.pywebview && contextMenuTarget) { + window.pywebview.api.open_file_location(contextMenuTarget); + } + contextMenu.classList.remove('show'); + }); }); \ No newline at end of file diff --git a/PYAS.py b/PYAS.py index 5c9c4f3..a8eef16 100644 --- a/PYAS.py +++ b/PYAS.py @@ -1174,7 +1174,8 @@ class WindowAPI: def open_file_location(self, file_path): if file_path and os.path.exists(file_path): try: - subprocess.Popen(f'explorer /select,"{file_path}"') + norm_path = os.path.normpath(file_path) + subprocess.Popen(f'explorer /select,"{norm_path}"') return True except Exception: pass