-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
91 lines (85 loc) · 2.4 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<!doctype html>
<html lang="de">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vue.js Beispiel</title>
<script src="https://cdn.jsdelivr.net/npm/vue@2"></script>
</head>
<body>
<div id="app">
<current-version-stat
version="1.0.0"
release-link="https://github.com/github-repo/releases"
owner="github"
repo="repo"
>
</current-version-stat>
</div>
<script type="text/x-template" id="current-version-stat-template">
<div>
<p v-if="loading">Loading...</p>
<p v-else-if="error">Error: {{ error.message }}</p>
<div v-else>
<p class="contentText">Version: {{ version }}</p>
<p class="contentText" :style="{ marginTop: '-10px' }">
Release:
<a v-if="releaseLink" :href="releaseLink" @click="handleClick">
github/AquaJo/hueFL/v0.0.2
</a>
<span v-else>No release link found</span>
</p>
</div>
</div>
</script>
<script>
Vue.component('current-version-stat', {
template: '#current-version-stat-template',
props: {
version: String,
releaseLink: String,
owner: String,
repo: String,
},
data() {
return {
loading: true,
error: null,
};
},
async mounted() {
try {
const response = await fetch(
`https://api.github.com/repos/${this.owner}/${this.repo}/releases`
);
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
const data = await response.json();
console.log(data); // Daten in der Konsole ausgeben
this.loading = false;
} catch (error) {
console.error('Fehler beim Abrufen der Releases:', error);
this.error = error;
this.loading = false;
}
},
methods: {
handleClick(event) {
event.preventDefault();
alert('Open link: ' + this.releaseLink);
},
},
});
new Vue({
el: '#app',
});
</script>
<style>
.contentText {
font-size: 16px;
color: #333;
}
</style>
</body>
</html>