refactor: some updates

This commit is contained in:
Henrique Dias 2025-11-22 17:00:08 +01:00
parent 4821c6455f
commit a401afec1a
3 changed files with 29 additions and 17 deletions

View File

@ -25,7 +25,7 @@
</td> </td>
<td class="small"> <td class="small">
<button <button
class="action copy-clipboard" class="action"
:aria-label="$t('buttons.copyToClipboard')" :aria-label="$t('buttons.copyToClipboard')"
:title="$t('buttons.copyToClipboard')" :title="$t('buttons.copyToClipboard')"
@click="copyToClipboard(buildLink(link))" @click="copyToClipboard(buildLink(link))"
@ -35,12 +35,13 @@
</td> </td>
<td class="small"> <td class="small">
<button <button
class="action copy-clipboard" class="action"
:aria-label="$t('buttons.copyInlineToClipboard')" :aria-label="$t('buttons.copyDownloadLinkToClipboard')"
:title="$t('buttons.copyInlineToClipboard')" :title="$t('buttons.copyDownloadLinkToClipboard')"
@click="copyToClipboard(buildInlineLink(link))" :disabled="!!link.password_hash"
@click="copyToClipboard(buildDownloadLink(link))"
> >
<i class="material-icons">insert_link</i> <i class="material-icons">content_paste_go</i>
</button> </button>
</td> </td>
<td class="small"> <td class="small">
@ -143,7 +144,7 @@
<script> <script>
import { mapActions, mapState } from "pinia"; import { mapActions, mapState } from "pinia";
import { useFileStore } from "@/stores/file"; import { useFileStore } from "@/stores/file";
import { share as api } from "@/api"; import * as api from "@/api/index";
import dayjs from "dayjs"; import dayjs from "dayjs";
import { useLayoutStore } from "@/stores/layout"; import { useLayoutStore } from "@/stores/layout";
import { copy } from "@/utils/clipboard"; import { copy } from "@/utils/clipboard";
@ -184,7 +185,7 @@ export default {
}, },
async beforeMount() { async beforeMount() {
try { try {
const links = await api.get(this.url); const links = await api.share.get(this.url);
this.links = links; this.links = links;
this.sort(); this.sort();
@ -223,9 +224,14 @@ export default {
let res = null; let res = null;
if (!this.time) { if (!this.time) {
res = await api.create(this.url, this.password); res = await api.share.create(this.url, this.password);
} else { } else {
res = await api.create(this.url, this.password, this.time, this.unit); res = await api.share.create(
this.url,
this.password,
this.time,
this.unit
);
} }
this.links.push(res); this.links.push(res);
@ -243,7 +249,7 @@ export default {
deleteLink: async function (event, link) { deleteLink: async function (event, link) {
event.preventDefault(); event.preventDefault();
try { try {
await api.remove(link.hash); await api.share.remove(link.hash);
this.links = this.links.filter((item) => item.hash !== link.hash); this.links = this.links.filter((item) => item.hash !== link.hash);
if (this.links.length == 0) { if (this.links.length == 0) {
@ -257,10 +263,16 @@ export default {
return dayjs(time * 1000).fromNow(); return dayjs(time * 1000).fromNow();
}, },
buildLink(share) { buildLink(share) {
return api.getShareURL(share); return api.share.getShareURL(share);
}, },
buildInlineLink(share) { buildDownloadLink(share) {
return createURL("api/public/dl/" + share.hash, { inline: "true" }); return api.pub.getDownloadURL(
{
hash: share.hash,
path: "",
},
true
);
}, },
sort() { sort() {
this.links = this.links.sort((a, b) => { this.links = this.links.sort((a, b) => {

View File

@ -98,7 +98,8 @@ main .spinner .bounce2 {
position: relative; position: relative;
} }
.action.disabled { .action.disabled,
.action[disabled] {
opacity: 0.2; opacity: 0.2;
cursor: not-allowed; cursor: not-allowed;
} }
@ -460,4 +461,4 @@ html[dir="rtl"] .card-content .small + input {
html[dir="rtl"] .card.floating .card-content .file-list { html[dir="rtl"] .card.floating .card-content .file-list {
direction: ltr; direction: ltr;
text-align: left; text-align: left;
} }

View File

@ -7,7 +7,6 @@
"copy": "Copy", "copy": "Copy",
"copyFile": "Copy file", "copyFile": "Copy file",
"copyToClipboard": "Copy to clipboard", "copyToClipboard": "Copy to clipboard",
"copyInlineToClipboard": "Copy inline link to clipboard",
"copyDownloadLinkToClipboard": "Copy download link to clipboard", "copyDownloadLinkToClipboard": "Copy download link to clipboard",
"create": "Create", "create": "Create",
"delete": "Delete", "delete": "Delete",