+
- Close
+ {{ $t('common.close') }}
diff --git a/components/dashboard/links/Index.vue b/components/dashboard/links/Index.vue
index b0a56eb..849e9e4 100644
--- a/components/dashboard/links/Index.vue
+++ b/components/dashboard/links/Index.vue
@@ -8,6 +8,24 @@ let cursor = ''
let listComplete = false
let listError = false
+const sortBy = ref('az')
+
+const displayedLinks = computed(() => {
+ const sorted = [...links.value]
+ switch (sortBy.value) {
+ case 'newest':
+ return sorted.sort((a, b) => b.createdAt - a.createdAt)
+ case 'oldest':
+ return sorted.sort((a, b) => a.createdAt - b.createdAt)
+ case 'az':
+ return sorted.sort((a, b) => a.slug.localeCompare(b.slug))
+ case 'za':
+ return sorted.sort((a, b) => b.slug.localeCompare(a.slug))
+ default:
+ return sorted
+ }
+})
+
async function getLinks() {
try {
const data = await useAPI('/api/link/list', {
@@ -50,6 +68,7 @@ function updateLinkList(link, type) {
}
else {
links.value.unshift(link)
+ sortBy.value = 'newest'
}
}
@@ -58,13 +77,16 @@ function updateLinkList(link, type) {
- No more links
+ {{ $t('links.no_more') }}
- Loading links failed,
+ {{ $t('links.load_failed') }}
diff --git a/components/dashboard/links/Link.vue b/components/dashboard/links/Link.vue
index e59f6a4..4b36f53 100644
--- a/components/dashboard/links/Link.vue
+++ b/components/dashboard/links/Link.vue
@@ -13,6 +13,7 @@ const props = defineProps({
})
const emit = defineEmits(['update:link'])
+const { t } = useI18n()
const editPopoverOpen = ref(false)
const { host, origin } = location
@@ -31,6 +32,11 @@ function updateLink(link, type) {
emit('update:link', link, type)
editPopoverOpen.value = false
}
+
+function copyLink() {
+ copy(shortLink.value)
+ toast(t('links.copy_success'))
+}
@@ -69,7 +75,7 @@ function updateLink(link, type) {
@@ -134,7 +140,7 @@ function updateLink(link, type) {