Merge pull request #4 from tangjie502/main

修复wget复制bug
This commit is contained in:
Lan
2025-04-24 10:17:22 +08:00
committed by GitHub
4 changed files with 2307 additions and 2692 deletions
+2229 -2684
View File
File diff suppressed because it is too large Load Diff
+51 -7
View File
@@ -3,7 +3,7 @@
*/ */
import { useAlertStore } from '@/stores/alertStore' import { useAlertStore } from '@/stores/alertStore'
const alertStore = useAlertStore();
interface CopyOptions { interface CopyOptions {
successMsg?: string successMsg?: string
errorMsg?: string errorMsg?: string
@@ -80,10 +80,54 @@ export const copyRetrieveCode = async (code: string): Promise<boolean> => {
}) })
} }
export const copyWgetCommand = async (code: string): Promise<boolean> => { const baseUrl = window.location.origin + '/#/';
const command = `wget ${window.location.origin}/share/select?code=${code}`
return copyToClipboard(command, { /*export const copyWgetCommand = (retrieveCode: string, fileName: any) => {
successMsg: 'wget命令已复制到剪贴板', //wget https://share.lanol.cn/share/select?code=17634
errorMsg: '复制失败,请手动复制wget命令' const command = `wget ${baseUrl}share/select?code=${retrieveCode} -O "${fileName}"`;
}) navigator.clipboard.writeText(command).then(() => {
alertStore.showAlert('wget命令已复制到剪贴板', 'success');
}).catch(() => {
alertStore.showAlert('复制wget命令失败', 'error');
});
};*/
export const copyWgetCommand = (retrieveCode: string, fileName: string) => {
// const command = `wget ${window.location.origin}/download/${retrieveCode} -O ${filename}`;
const command = `wget ${baseUrl}share/select?code=${retrieveCode} -O "${fileName}"`;
if (navigator.clipboard && navigator.clipboard.writeText) {
navigator.clipboard.writeText(command)
.then(() => {
console.log("命令已复制到剪贴板!");
})
.catch((err) => {
console.error("复制失败,使用回退方法:", err);
fallbackCopyTextToClipboard(command);
});
} else {
console.warn("Clipboard API 不可用,使用回退方法。");
fallbackCopyTextToClipboard(command);
}
};
function fallbackCopyTextToClipboard(text:string) {
const textArea = document.createElement("textarea");
textArea.value = text;
textArea.style.position = "fixed"; // 避免滚动
document.body.appendChild(textArea);
textArea.focus();
textArea.select();
try {
const successful = document.execCommand("copy");
console.log("回退复制操作成功:", successful);
} catch (err) {
console.error("回退复制操作失败:", err);
}
document.body.removeChild(textArea);
}
if (navigator.clipboard && navigator.clipboard.writeText) {
navigator.clipboard.writeText("要复制的文本");
} else {
fallbackCopyTextToClipboard("要复制的文本");
} }
+1 -1
View File
@@ -339,7 +339,7 @@
<TerminalIcon class="w-4 h-4 sm:w-5 sm:h-5 mr-1.5 sm:mr-2 text-indigo-500 flex-shrink-0" /> <TerminalIcon class="w-4 h-4 sm:w-5 sm:h-5 mr-1.5 sm:mr-2 text-indigo-500 flex-shrink-0" />
<span class="truncate">wget下载</span> <span class="truncate">wget下载</span>
</h4> </h4>
<button @click="copyWgetCommand(selectedRecord.retrieveCode)" <button @click="copyWgetCommand(selectedRecord.retrieveCode,selectedRecord.filename)"
class="p-1.5 sm:p-2 rounded-full hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors flex-shrink-0"> class="p-1.5 sm:p-2 rounded-full hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors flex-shrink-0">
<ClipboardCopyIcon class="w-4 h-4 sm:w-5 sm:h-5" <ClipboardCopyIcon class="w-4 h-4 sm:w-5 sm:h-5"
:class="[isDarkMode ? 'text-gray-400' : 'text-gray-500']" /> :class="[isDarkMode ? 'text-gray-400' : 'text-gray-500']" />
@@ -0,0 +1,26 @@
// vite.config.ts
import { fileURLToPath, URL } from "node:url";
import { defineConfig } from "file:///E:/FileCodeBoxFronted/node_modules/.pnpm/vite@5.4.18_@types+node@20.17.30/node_modules/vite/dist/node/index.js";
import vue from "file:///E:/FileCodeBoxFronted/node_modules/.pnpm/@vitejs+plugin-vue@5.2.3_vite@5.4.18_vue@3.5.13/node_modules/@vitejs/plugin-vue/dist/index.mjs";
import vueJsx from "file:///E:/FileCodeBoxFronted/node_modules/.pnpm/@vitejs+plugin-vue-jsx@4.1.2_vite@5.4.18_vue@3.5.13/node_modules/@vitejs/plugin-vue-jsx/dist/index.mjs";
import vueDevTools from "file:///E:/FileCodeBoxFronted/node_modules/.pnpm/vite-plugin-vue-devtools@7.7.5_vite@5.4.18_vue@3.5.13/node_modules/vite-plugin-vue-devtools/dist/vite.mjs";
import tailwindcss from "file:///E:/FileCodeBoxFronted/node_modules/.pnpm/tailwindcss@3.4.17/node_modules/tailwindcss/lib/index.js";
import autoprefixer from "file:///E:/FileCodeBoxFronted/node_modules/.pnpm/autoprefixer@10.4.21_postcss@8.5.3/node_modules/autoprefixer/lib/autoprefixer.js";
var __vite_injected_original_import_meta_url = "file:///E:/FileCodeBoxFronted/vite.config.ts";
var vite_config_default = defineConfig({
plugins: [vue(), vueJsx(), vueDevTools()],
resolve: {
alias: {
"@": fileURLToPath(new URL("./src", __vite_injected_original_import_meta_url))
}
},
css: {
postcss: {
plugins: [tailwindcss, autoprefixer]
}
}
});
export {
vite_config_default as default
};
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsidml0ZS5jb25maWcudHMiXSwKICAic291cmNlc0NvbnRlbnQiOiBbImNvbnN0IF9fdml0ZV9pbmplY3RlZF9vcmlnaW5hbF9kaXJuYW1lID0gXCJFOlxcXFxGaWxlQ29kZUJveEZyb250ZWRcIjtjb25zdCBfX3ZpdGVfaW5qZWN0ZWRfb3JpZ2luYWxfZmlsZW5hbWUgPSBcIkU6XFxcXEZpbGVDb2RlQm94RnJvbnRlZFxcXFx2aXRlLmNvbmZpZy50c1wiO2NvbnN0IF9fdml0ZV9pbmplY3RlZF9vcmlnaW5hbF9pbXBvcnRfbWV0YV91cmwgPSBcImZpbGU6Ly8vRTovRmlsZUNvZGVCb3hGcm9udGVkL3ZpdGUuY29uZmlnLnRzXCI7aW1wb3J0IHsgZmlsZVVSTFRvUGF0aCwgVVJMIH0gZnJvbSAnbm9kZTp1cmwnXHJcblxyXG5pbXBvcnQgeyBkZWZpbmVDb25maWcgfSBmcm9tICd2aXRlJ1xyXG5pbXBvcnQgdnVlIGZyb20gJ0B2aXRlanMvcGx1Z2luLXZ1ZSdcclxuaW1wb3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