Skip to content

Commit

Permalink
fix: decode link text error
Browse files Browse the repository at this point in the history
  • Loading branch information
KUN1007 committed Oct 23, 2024
1 parent a0c79c9 commit 5d03e26
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions assets/css/editor/kun-content.scss
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
color: var(--kungalgame-blue-5);
text-decoration: underline;
text-underline-offset: 3px;
word-break: break-word;
}

table {
Expand Down
2 changes: 1 addition & 1 deletion components/galgame/resource/Details.vue
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const handleRewriteResource = (details: GalgameResourceDetails) => {
<div class="more" v-if="details">
<div class="title">
<span class="link" v-for="(kun, index) in details.link" :key="index">
<KunCopy :text="decodeURI(kun)" />
<KunCopy :text="kun" />
<a :href="kun" target="_blank" rel="noopener noreferrer">
<Icon class="icon" name="lucide:external-link" />
</a>
Expand Down
2 changes: 1 addition & 1 deletion components/kun/Copy.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ withDefaults(defineProps<{ text: string; name?: string }>(), {

<template>
<span class="kun-copy" @click="useKunCopy(text)">
<span>{{ name ? name : text }}</span>
<span>{{ decodeIfEncoded(name ? name : text) }}</span>
<Icon class="icon" name="lucide:copy" />
</span>
</template>
Expand Down
4 changes: 3 additions & 1 deletion composables/useKunCopy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export const useKunCopy = (text: string) => {
export const useKunCopy = (originText: string) => {
const text = decodeIfEncoded(originText)

navigator.clipboard
.writeText(text)
.then(() => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kun-galgame-nuxt3",
"version": "2.19.10",
"version": "2.19.11",
"packageManager": "[email protected]",
"private": true,
"scripts": {
Expand Down
8 changes: 8 additions & 0 deletions utils/decodeIfEncoded.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export const decodeIfEncoded = (text: string) => {
try {
const decoded = decodeURIComponent(text)
return decoded !== text ? decoded : text
} catch (e) {
return text
}
}

0 comments on commit 5d03e26

Please sign in to comment.