-
Notifications
You must be signed in to change notification settings - Fork 159
/
Copy pathindex.html
116 lines (106 loc) · 3.22 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ds猫源在线配置主页</title>
<style>
body {
margin: 0;
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background-color: #f3f4f6;
color: #333;
text-align: center;
}
.container {
padding: 20px;
border: 1px solid #ddd;
border-radius: 8px;
background-color: #fff;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
max-width: 90%;
width: 400px;
}
h1 {
font-size: 24px;
margin-bottom: 20px;
}
.link {
display: inline-block;
font-size: 16px;
color: #007bff;
text-decoration: none;
margin-bottom: 10px;
word-wrap: break-word;
}
.link:hover {
text-decoration: underline;
}
.copy-button {
display: inline-block;
padding: 8px 16px;
font-size: 14px;
color: #fff;
background-color: #007bff;
border: none;
border-radius: 4px;
cursor: pointer;
transition: background-color 0.3s;
}
.copy-button:hover {
background-color: #0056b3;
}
.message {
margin-top: 10px;
font-size: 14px;
color: #28a745;
}
</style>
</head>
<body>
<div class="container">
<h1>欢迎使用DS猫源</h1>
<a href="#" class="link" id="link">$catLink</a>
<button class="copy-button" id="copyButton">复制地址</button>
<div class="message" id="message" style="display: none;">链接已复制到剪切板!</div>
</div>
<script>
function copyToClipboard(text) {
if (navigator.clipboard && navigator.clipboard.writeText) {
navigator.clipboard.writeText(text)
.then(() => {
console.log('Text copied to clipboard!');
})
.catch(err => {
console.error('Failed to copy text: ', err);
});
} else {
console.warn('Clipboard API not supported. Falling back to legacy method.');
fallbackCopyToClipboard(text);
}
}
function fallbackCopyToClipboard(text) {
const textarea = document.createElement('textarea');
textarea.value = text;
document.body.appendChild(textarea);
textarea.select();
try {
document.execCommand('copy');
console.log('Fallback: Text copied to clipboard!');
} catch (err) {
console.error('Fallback: Failed to copy text: ', err);
}
document.body.removeChild(textarea);
}
document.getElementById('copyButton').addEventListener('click', function () {
const link = document.getElementById('link').textContent;
copyToClipboard(link);
alert('已复制到剪切板');
});
</script>
</body>
</html>