mirror of
https://github.com/Fabio286/antares.git
synced 2025-02-15 03:00:41 +01:00
feat: support to links in changelog
This commit is contained in:
parent
8c4c93cb07
commit
ad7e459c68
@ -18,6 +18,7 @@ import { marked } from 'marked';
|
||||
import BaseLoader from '@/components/BaseLoader.vue';
|
||||
import { useApplicationStore } from '@/stores/application';
|
||||
import { ref } from 'vue';
|
||||
import { shell } from 'electron';
|
||||
|
||||
const { appVersion } = useApplicationStore();
|
||||
|
||||
@ -26,6 +27,10 @@ const isLoading = ref(true);
|
||||
const error = ref('');
|
||||
const isError = ref(false);
|
||||
|
||||
const openOutside = (link: string) => {
|
||||
shell.openExternal(link);
|
||||
};
|
||||
|
||||
const getChangelog = async () => {
|
||||
try {
|
||||
const apiRes = await fetch(`https://api.github.com/repos/antares-sql/antares/releases/tags/v${appVersion}`, {
|
||||
@ -40,7 +45,7 @@ const getChangelog = async () => {
|
||||
|
||||
const renderer = {
|
||||
link (href: string, title: string, text: string) {
|
||||
return text;
|
||||
return `<a class="changelog-link" href="${href}" title="${title || ''}" target="_blank">${text}</a>`;
|
||||
},
|
||||
listitem (text: string) {
|
||||
return `<li>${text.replace(/ *\([^)]*\) */g, '')}</li>`;
|
||||
@ -57,6 +62,17 @@ const getChangelog = async () => {
|
||||
}
|
||||
|
||||
isLoading.value = false;
|
||||
|
||||
setTimeout(() => {
|
||||
const links = document.querySelectorAll<HTMLAnchorElement>('.changelog-link');
|
||||
|
||||
for (const link of links) {
|
||||
link.addEventListener('click', e => {
|
||||
e.preventDefault();
|
||||
openOutside(link.href);
|
||||
});
|
||||
}
|
||||
}, 0);
|
||||
};
|
||||
|
||||
getChangelog();
|
||||
|
Loading…
x
Reference in New Issue
Block a user