kes-kopyala-yapıştır eklendi
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<script>
|
||||
import { onMount, tick } from "svelte";
|
||||
import { API, apiFetch, moveEntry, renameFolder } from "../utils/api.js";
|
||||
import { API, apiFetch, moveEntry, renameFolder, copyEntry } from "../utils/api.js";
|
||||
import { cleanFileName, extractTitleAndYear } from "../utils/filename.js";
|
||||
import { refreshMovieCount } from "../stores/movieStore.js";
|
||||
import { refreshTvShowCount } from "../stores/tvStore.js";
|
||||
@@ -453,6 +453,10 @@
|
||||
let breadcrumbMenuPosition = { top: 0, left: 0 };
|
||||
let hiddenBreadcrumbs = [];
|
||||
|
||||
// Clipboard state
|
||||
let clipboardItem = null;
|
||||
let clipboardOperation = null; // 'cut' veya 'copy'
|
||||
|
||||
if (typeof window !== "undefined") {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
const pathParam = params.get("path");
|
||||
@@ -1542,6 +1546,81 @@
|
||||
cancelRenameFolder();
|
||||
}
|
||||
}
|
||||
|
||||
// Clipboard fonksiyonları
|
||||
function cutFile(item) {
|
||||
if (!item) return;
|
||||
clipboardItem = item;
|
||||
clipboardOperation = 'cut';
|
||||
closeMenu();
|
||||
}
|
||||
|
||||
function copyFile(item) {
|
||||
if (!item) return;
|
||||
clipboardItem = item;
|
||||
clipboardOperation = 'copy';
|
||||
closeMenu();
|
||||
}
|
||||
|
||||
async function pasteFile() {
|
||||
if (!clipboardItem || !clipboardOperation) return;
|
||||
|
||||
const sourcePath = resolveEntryOriginalPath(clipboardItem);
|
||||
const targetPath = resolveOriginalPathForDisplay(currentPath, currentOriginalPath);
|
||||
|
||||
if (!sourcePath || !targetPath) {
|
||||
alert("Geçersiz kaynak veya hedef yolu");
|
||||
return;
|
||||
}
|
||||
|
||||
const normalizedSource = normalizePath(sourcePath);
|
||||
const normalizedTarget = normalizePath(targetPath);
|
||||
|
||||
if (!normalizedSource || !normalizedTarget) {
|
||||
alert("Geçersiz kaynak veya hedef yolu");
|
||||
return;
|
||||
}
|
||||
|
||||
// Aynı konuma yapıştırmayı engelle
|
||||
const sourceParent = normalizedSource.split("/").slice(0, -1).join("/");
|
||||
if (sourceParent === normalizedTarget && clipboardOperation === 'cut') {
|
||||
alert("Öğe zaten bu konumda");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
let result;
|
||||
if (clipboardOperation === 'cut') {
|
||||
// Kes işlemi - moveEntry kullan
|
||||
result = await moveEntry(normalizedSource, normalizedTarget);
|
||||
} else {
|
||||
// Kopyala işlemi - copyEntry kullan
|
||||
result = await copyEntry(normalizedSource, normalizedTarget);
|
||||
}
|
||||
|
||||
if (!result?.success) {
|
||||
const message = result?.error || "İşlem başarısız oldu";
|
||||
alert(message);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!result?.unchanged) {
|
||||
await loadFiles();
|
||||
}
|
||||
|
||||
// Kes işleminden sonra clipboard'u temizle
|
||||
if (clipboardOperation === 'cut') {
|
||||
clipboardItem = null;
|
||||
clipboardOperation = null;
|
||||
}
|
||||
// Kopyala işleminde clipboard'u koru (tekrar yapıştırmaya izin ver)
|
||||
|
||||
selectedItems = new Set();
|
||||
} catch (err) {
|
||||
console.error("❌ Yapıştırma hatası:", err);
|
||||
alert("İşlem tamamlanamadı. Lütfen tekrar dene.");
|
||||
}
|
||||
}
|
||||
|
||||
onMount(async () => {
|
||||
setSearchScope("files");
|
||||
@@ -1913,6 +1992,17 @@
|
||||
<i class="fa-solid fa-square-check"></i>
|
||||
</button>
|
||||
{/if}
|
||||
{#if clipboardItem && clipboardOperation}
|
||||
<button
|
||||
class="paste-btn"
|
||||
type="button"
|
||||
on:click|stopPropagation={pasteFile}
|
||||
aria-label="Yapıştır"
|
||||
title={clipboardOperation === 'cut' ? 'Kes ve yapıştır' : 'Kopyala ve yapıştır'}
|
||||
>
|
||||
<i class="fa-solid fa-paste"></i>
|
||||
</button>
|
||||
{/if}
|
||||
<button
|
||||
class="create-folder-btn"
|
||||
type="button"
|
||||
@@ -2154,6 +2244,21 @@
|
||||
<span>Yeniden adlandır</span>
|
||||
</button>
|
||||
<div class="menu-divider"></div>
|
||||
<button
|
||||
class="menu-item"
|
||||
on:click|stopPropagation={() => cutFile(activeMenu)}
|
||||
>
|
||||
<i class="fa-solid fa-scissors"></i>
|
||||
<span>Kes</span>
|
||||
</button>
|
||||
<button
|
||||
class="menu-item"
|
||||
on:click|stopPropagation={() => copyFile(activeMenu)}
|
||||
>
|
||||
<i class="fa-solid fa-copy"></i>
|
||||
<span>Kopyala</span>
|
||||
</button>
|
||||
<div class="menu-divider"></div>
|
||||
{:else}
|
||||
<button
|
||||
class="menu-item"
|
||||
@@ -2170,6 +2275,21 @@
|
||||
<span>Eşleştir</span>
|
||||
</button>
|
||||
<div class="menu-divider"></div>
|
||||
<button
|
||||
class="menu-item"
|
||||
on:click|stopPropagation={() => cutFile(activeMenu)}
|
||||
>
|
||||
<i class="fa-solid fa-scissors"></i>
|
||||
<span>Kes</span>
|
||||
</button>
|
||||
<button
|
||||
class="menu-item"
|
||||
on:click|stopPropagation={() => copyFile(activeMenu)}
|
||||
>
|
||||
<i class="fa-solid fa-copy"></i>
|
||||
<span>Kopyala</span>
|
||||
</button>
|
||||
<div class="menu-divider"></div>
|
||||
{/if}
|
||||
<button
|
||||
class="menu-item delete"
|
||||
@@ -2831,6 +2951,33 @@
|
||||
transform: scale(0.95);
|
||||
}
|
||||
|
||||
.paste-btn {
|
||||
background: transparent;
|
||||
border: 1px solid #ddd;
|
||||
color: #666;
|
||||
padding: 10px 14px;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 36px;
|
||||
width: 36px;
|
||||
transition: all 0.2s ease;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.paste-btn:hover {
|
||||
background: #4caf50;
|
||||
border-color: #45a049;
|
||||
color: #fff;
|
||||
transform: scale(1.05);
|
||||
}
|
||||
|
||||
.paste-btn:active {
|
||||
transform: scale(0.95);
|
||||
}
|
||||
|
||||
/* Klasör oluşturma UI elemanları */
|
||||
.creating-folder {
|
||||
background: rgba(245, 179, 51, 0.1);
|
||||
@@ -3074,6 +3221,9 @@
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
min-height: 20px; /* Dosya isimleri için tutarlı yükseklik */
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
.size {
|
||||
font-size: 12px;
|
||||
@@ -3475,6 +3625,9 @@
|
||||
}
|
||||
.media-card.list-view .name {
|
||||
font-size: 15px;
|
||||
min-height: 22px; /* Liste görünümündeki dosya isimleri için tutarlı yükseklik */
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
.media-card.list-view .size {
|
||||
display: none;
|
||||
@@ -3650,6 +3803,11 @@
|
||||
color: #2d2d2d;
|
||||
line-height: 1.35;
|
||||
word-break: break-word;
|
||||
min-height: 40px; /* Tek ve çok satırlı isimler için aynı yükseklik */
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.folder-rename-input {
|
||||
@@ -3689,6 +3847,9 @@
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
min-height: 24px; /* Liste görünümünde tutarlı yükseklik */
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
/* Menü düğmesi ve dropdown stilleri */
|
||||
|
||||
@@ -64,3 +64,15 @@ export async function renameFolder(path, newName) {
|
||||
});
|
||||
return res.json();
|
||||
}
|
||||
|
||||
export async function copyEntry(sourcePath, targetDirectory) {
|
||||
const res = await apiFetch("/api/file/copy", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
sourcePath,
|
||||
targetDirectory
|
||||
})
|
||||
});
|
||||
return res.json();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user