elykia 1.0.18 → 1.0.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,21 +3,24 @@ const elykia = {
3
3
  setWelcome_info: async () => {
4
4
  if (!document.getElementById("welcome-info")) return;
5
5
 
6
- let ipLoacation = saveToLocal.get('welcome-info');
6
+ let ipLocation = localStorage.getItem('welcome-info');
7
+ if (ipLocation) ipLocation = JSON.parse(ipLocation);
7
8
 
8
9
  try {
9
- if (!ipLoacation) {
10
+ if (!ipLocation) {
10
11
  return new Promise((resolve, reject) => {
11
12
  var script = document.createElement('script');
12
- var url = `https://apis.map.qq.com/ws/location/v1/ip?key=TNLBZ-FS2LQ-4X257-4ACX6-OP673-62BFJ&output=jsonp`;
13
+ var url = `https://apis.map.qq.com/ws/location/v1/ip?key=TNLBZ-FS2LQ-4X257-4ACX6-OP673-62BFJ&output=jsonp&callback=QQmap`;
13
14
  script.src = url;
14
15
 
15
16
  window.QQmap = (data) => {
16
17
  if (data.status === 0) {
17
- // console.info(data);
18
- ipLoacation = data;
19
- saveToLocal.set('welcome-info', ipLoacation, 0.5);
20
- elykia.showWelcome(ipLoacation);
18
+ ipLocation = data;
19
+ localStorage.setItem('welcome-info', JSON.stringify({
20
+ data: ipLocation,
21
+ timestamp: Date.now()
22
+ }));
23
+ elykia.showWelcome(ipLocation);
21
24
  resolve();
22
25
  } else {
23
26
  reject(new Error('Failed to fetch location data'));
@@ -28,8 +31,7 @@ const elykia = {
28
31
  document.body.appendChild(script);
29
32
  });
30
33
  } else {
31
- await Promise.resolve(); // 确保在同步代码路径上也能保持异步风格
32
- elykia.showWelcome(ipLoacation);
34
+ elykia.showWelcome(ipLocation.data || ipLocation);
33
35
  }
34
36
  } catch (err) {
35
37
  console.error("Error fetching data:", err);
@@ -314,5 +316,9 @@ const elykia = {
314
316
  您的IP地址为:<strong>${IP}</strong><br>
315
317
  <strong>${timeChange}!</strong>`);
316
318
  },
317
- }
319
+ };
318
320
 
321
+ // 页面加载后执行
322
+ document.addEventListener('DOMContentLoaded', () => {
323
+ elykia.setWelcome_info();
324
+ });
package/license ADDED
@@ -0,0 +1 @@
1
+ eyJsaWNlbnNlTmFtZSI6ImxpY2Vuc2UtUGFuZWwtU0FIbFoiLCJhc3NpZ25lZU5hbWUiOiJFbHlraWEiLCJwcm9kdWN0cyI6W3sibmFtZSI6InByb2R1Y3QtMXBhbmVsLXBybyIsIm1heE5vZGVDb3VudCI6MH1dLCJ0cmlhbCI6ZmFsc2UsIm9mZmxpbmUiOmZhbHNlLCJhbm5vdGF0aW9ucyI6eyJseHdhcmUuY24vdXNlcm5hbWUiOiJlbHlraWEifX0=-CgNb9uQ9aFa28hH2Eaa7Dduoa4VN66DZMMNSzEv0z/tGmd9HOJbPKcWHm8ko7MtQ3jXdbsG2G+EhdDg7/7nil5MVPLbXHridP9siI9Xby0+aHCwWmJ4QRYe9UxcQMJ1M1Nv1qBLlIcznMY4KNAW8ZrQA9rTK50JYswU+0SRFCJRKqrQwZpukxFVHffh6BSsR/31HuQS9WBip8yRcOElZc0MlQgHNyLzNG98Wo+xRa5Rs3gXeLkcAwWI7LPTdVyHjNpHFkaVU+ZAhU0/R3K22j2y3rnbpTzM9SrBTuF/aZ2tC8dpy4/MGKY9bjWOwstgXqCtLYi4ajb8x5R943lmLog==-MIIFJTCCAw2gAwIBAgIIQf5HvitorHAwDQYJKoZIhvcNAQEMBQAwgZIxCzAJBgNVBAYTAkNOMRIwEAYDVQQIEwlHdWFuZ2RvbmcxETAPBgNVBAcTCFNoZW56aGVuMS4wLAYDVQQKEyVMaW5neGlhIChTaGVuemhlbikgU29mdHdhcmUgQ28uLCBMdGQuMRgwFgYDVQQLEw9MaW5nWGlhU29mdHdhcmUxEjAQBgNVBAMTCUxpbmdYaWFDQTAgFw0yNDA2MDMxNTU3NTRaGA8yMTI0MDUxMDE1NTc1NFowgZAxCzAJBgNVBAYTAkNOMRIwEAYDVQQIEwlHdWFuZ2Rvbmc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T0ypBz1p774gtqyHmAXLRFm3F9FyvtubObP2WvFJR2l48f19SVqdPYWtrd4vV9tDeb9MSDbU3x+S08kGnM4jrIX6lSRD2fXUJ3+ck2ntbflaDm7TdbqlSQByyszwlGAfzhCHB3xLksJmQVShX6WO+ydBYWDpj3UF5jQ95kWt4h81N7A4ddiV/KAbYiaRidRP7EpIenuYFJSzTykzwHDmZyXSumcd4PAS2tunFaa+jc6wg723lpN2Ydo9ZNmd4MxTvRcwiCU2VOUxnguR0jsnq95Aez/SfrwKHt4EWI5Pbl7sSh+nqj4hSGrNF7KXKyY5LBTo8VENMUB7KbN8hb+AG42/g1zT7g==
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "elykia",
3
- "version": "1.0.18",
3
+ "version": "1.0.19",
4
4
  "description": "",
5
5
  "license": "ISC",
6
6
  "author": "Elykia",
package/countdown.js DELETED
@@ -1,201 +0,0 @@
1
- const CountdownTimer = (() => {
2
- const config = {
3
- targetDate: "2025-12-20",
4
- targetName: "考研",
5
- units: {
6
- day: { text: "今日", divider: 1, unit: "小时" },
7
- week: { text: "本周", divider: 24, unit: "天" },
8
- month: { text: "本月", divider: 24, unit: "天" },
9
- year: { text: "本年", divider: 24, unit: "天" }
10
- }
11
- };
12
-
13
- function getTimeUnit(unit) {
14
- const now = new Date();
15
- const start = new Date(now.setHours(0, 0, 0, 0));
16
- const end = new Date(now.setHours(23, 59, 59, 999));
17
-
18
- if (unit === 'day') {
19
- const currentHour = new Date().getHours();
20
- const remaining = 24 - currentHour;
21
- const percentage = (currentHour / 24) * 100;
22
-
23
- return {
24
- name: config.units[unit].text,
25
- remaining: remaining,
26
- percentage: percentage.toFixed(2),
27
- unit: config.units[unit].unit
28
- };
29
- }
30
-
31
- const ranges = {
32
- week: () => {
33
- start.setDate(start.getDate() - start.getDay());
34
- end.setDate(end.getDate() - end.getDay() + 6);
35
- },
36
- month: () => {
37
- start.setDate(1);
38
- end.setMonth(end.getMonth() + 1, 0);
39
- },
40
- year: () => {
41
- start.setMonth(0, 1);
42
- end.setMonth(11, 31);
43
- }
44
- };
45
- ranges[unit]?.();
46
-
47
- const total = unit === "day" ? 24 : Math.floor((end - start) / 86400000) + 1;
48
- const passed = Math.floor((now - start) / (3600000 * config.units[unit].divider));
49
- const percentage = (passed / total) * 100;
50
-
51
- return {
52
- name: config.units[unit].text,
53
- remaining: total - passed,
54
- percentage: percentage.toFixed(2),
55
- unit: config.units[unit].unit
56
- };
57
- }
58
-
59
- function updateCountdown() {
60
- const elements = ['eventName', 'eventDate', 'daysUntil', 'countRight']
61
- .map(id => document.getElementById(id));
62
-
63
- if (elements.some(el => !el)) return;
64
-
65
- const [eventName, eventDate, daysUntil, countRight] = elements;
66
- const timeData = Object.keys(config.units).reduce((acc, unit) => ({...acc, [unit]: getTimeUnit(unit)}), {});
67
- const daysRemaining = Math.round((new Date(config.targetDate) - new Date().setHours(0,0,0,0)) / 86400000);
68
-
69
- eventName.textContent = config.targetName;
70
- eventDate.textContent = config.targetDate;
71
- daysUntil.textContent = daysRemaining;
72
- countRight.innerHTML = Object.entries(timeData)
73
- .map(([_, item]) => `
74
- <div class="cd-count-item">
75
- <div class="cd-item-name">${item.name}</div>
76
- <div class="cd-item-progress">
77
- <div class="cd-progress-bar" style="width: ${item.percentage}%; opacity: ${item.percentage/100}"></div>
78
- <span class="cd-percentage ${item.percentage >= 46 ? 'cd-many' : ''}">${item.percentage}%</span>
79
- <span class="cd-remaining ${item.percentage >= 60 ? 'cd-many' : ''}">
80
- <span class="cd-tip">还剩</span>${item.remaining}<span class="cd-tip">${item.unit}</span>
81
- </span>
82
- </div>
83
- </div>
84
- `).join('');
85
- }
86
-
87
- function injectStyles() {
88
- const styles = `
89
- .card-countdown .item-content {
90
- display: flex;
91
- }
92
- .cd-count-left {
93
- position: relative;
94
- display: flex;
95
- flex-direction: column;
96
- margin-right: 0.8rem;
97
- line-height: 1.5;
98
- align-items: center;
99
- justify-content: center;
100
- }
101
- .cd-count-left .cd-text {
102
- font-size: 14px;
103
- }
104
- .cd-count-left .cd-name {
105
- font-weight: bold;
106
- font-size: 18px;
107
- }
108
- .cd-count-left .cd-time {
109
- font-size: 30px;
110
- font-weight: bold;
111
- color: var(--anzhiyu-main);
112
- }
113
- .cd-count-left .cd-date {
114
- font-size: 12px;
115
- opacity: 0.6;
116
- }
117
- .cd-count-left::after {
118
- content: "";
119
- position: absolute;
120
- right: -0.8rem;
121
- width: 2px;
122
- height: 80%;
123
- background-color: var(--anzhiyu-main);
124
- opacity: 0.5;
125
- }
126
- .cd-count-right {
127
- flex: 1;
128
- margin-left: .8rem;
129
- display: flex;
130
- flex-direction: column;
131
- justify-content: space-between;
132
- }
133
- .cd-count-item {
134
- display: flex;
135
- flex-direction: row;
136
- align-items: center;
137
- height: 24px;
138
- }
139
- .cd-item-name {
140
- font-size: 14px;
141
- margin-right: 0.8rem;
142
- white-space: nowrap;
143
- }
144
- .cd-item-progress {
145
- position: relative;
146
- display: flex;
147
- flex-direction: row;
148
- align-items: center;
149
- justify-content: space-between;
150
- height: 100%;
151
- width: 100%;
152
- border-radius: 8px;
153
- background-color: var(--anzhiyu-background);
154
- overflow: hidden;
155
- }
156
- .cd-progress-bar {
157
- height: 100%;
158
- border-radius: 8px;
159
- background-color: var(--anzhiyu-main);
160
- }
161
- .cd-percentage,
162
- .cd-remaining {
163
- position: absolute;
164
- font-size: 12px;
165
- margin: 0 6px;
166
- transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
167
- }
168
- .cd-many {
169
- color: #fff;
170
- }
171
- .cd-remaining {
172
- opacity: 0;
173
- transform: translateX(10px);
174
- }
175
- .card-countdown .item-content:hover .cd-remaining {
176
- transform: translateX(0);
177
- opacity: 1;
178
- }
179
- .card-countdown .item-content:hover .cd-percentage {
180
- transform: translateX(-10px);
181
- opacity: 0;
182
- }
183
- `;
184
-
185
- const styleSheet = document.createElement("style");
186
- styleSheet.textContent = styles;
187
- document.head.appendChild(styleSheet);
188
- }
189
-
190
- let timer;
191
- const start = () => {
192
- injectStyles();
193
- updateCountdown();
194
- timer = setInterval(updateCountdown, 600000);
195
- };
196
-
197
- ['pjax:complete', 'DOMContentLoaded'].forEach(event => document.addEventListener(event, start));
198
- document.addEventListener('pjax:send', () => timer && clearInterval(timer));
199
-
200
- return { start, stop: () => timer && clearInterval(timer) };
201
- })();