elykia 1.0.0 → 1.0.2

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.
package/SAO-Notify.js ADDED
@@ -0,0 +1,44 @@
1
+ function SAONotify(title,message,action){
2
+ // 先移除旧有弹窗,确保不会重叠。
3
+ var notifyWindow = document.getElementById('SAO-Notify');
4
+ if(notifyWindow){
5
+ notifyWindow.remove();
6
+ }
7
+ //样式文件
8
+ var tempstyle = `#SAO-Notify{z-index:9999;background:rgba(204,204,207,0.8);font-family:'SAOUI',Langar,-apple-system,sans-serif;font-weight:bolder;text-shadow:0.5px 0.5px 0.5px#888;height:240px;width:350px;position:fixed;bottom:0;right:0;left:0;top:0;margin:auto auto;border-radius:5px;box-shadow:2px 2px 10px#888;display:block;animation:flashOpen 1s ease alternate}.notify-title{background:rgba(249,249,249,0.8);color:rgba(60,60,61,0.7);height:60px;width:100%;display:block;font-size:20px;text-align:center;border-top-left-radius:5px;border-top-right-radius:5px;padding-top:10px}.notify-alert::-webkit-scrollbar{display:none}.notify-alert{background:rgba(220,220,220,0.8);color:rgba(60,60,61,0.7);height:120px;overflow:scroll;width:100%;display:flex;justify-content:space-around;align-items:center;box-shadow:0px 0px 15px#bcbcbc inset;flex-wrap:wrap;padding:5px 25px;}.notify-button{background:rgba(249,249,249,0.8);height:60px;width:100%;display:block;text-align:center;border-bottom-left-radius:5px;border-bottom-right-radius:5px;padding-top:12.5px}.notify-confirm{background:rgba(47,121,212,0);border-radius:50%;display:inline-block;width:36px;height:36px;margin-inline:60px;border:1px solid;border-color:#2f79d4}.notify-confirm button{background:#2f79d4;text-align:center;border-radius:50%;font-size:18px;color:#fff;display:block;width:30px;height:30px;margin:2px}.notify-cancel{background:rgba(203,55,73,0);border-radius:50%;display:inline-block;width:36px;height:36px;margin-inline:60px;border:1px solid;border-color:#cb3749}.notify-cancel button{background:#cb3749;text-align:center;border-radius:50%;font-size:18px;font-weight:bolder;color:#fff;display:block;width:30px;height:30px;margin:2px}.notify-receive{background:rgba(47,121,212,0);border-radius:50%;display:inline-block;width:36px;height:36px;margin-inline:60px;border:1px solid;border-color:#eda60c}.notify-receive button{background:#eda60c;text-align:center;border-radius:50%;font-size:18px;color:#fff;display:block;width:30px;height:30px;margin:2px}@-moz-keyframes flashOpen{from{transform:rotateX(90deg)}to{transform:rotateX(0deg)}}@-webkit-keyframes flashOpen{from{transform:rotateX(90deg)}to{transform:rotateX(0deg)}}@-o-keyframes flashOpen{from{transform:rotateX(90deg)}to{transform:rotateX(0deg)}}@keyframes flashOpen{from{transform:rotateX(90deg)}to{transform:rotateX(0deg)}}@-moz-keyframes flashClose{from{transform:rotateX(0deg)}to{transform:rotateX(90deg)}}@-webkit-keyframes flashClose{from{transform:rotateX(0deg)}to{transform:rotateX(90deg)}}@-o-keyframes flashClose{from{transform:rotateX(0deg)}to{transform:rotateX(90deg)}}@keyframes flashClose{from{transform:rotateX(0deg)}to{transform:rotateX(90deg)}}`;
9
+ //若定义了action执行代码片段,则输出有双选项的弹窗
10
+ if (action){
11
+ var template =`<div id="SAO-Notify"><style>` + tempstyle +`</style><div class="notify-title">` + `${title}` + `</div><div class="notify-alert"> `+ `${message}` + `</div><div class="notify-button"><span class="notify-confirm"><button class="far fa-circle" type="button" name="confirm" onclick="clickAudio();setTimeout(function(){` + `${action}` + `},500);cancelNotify()"></button></span><span class="notify-cancel"><button class="fa fa-times" type="button" name="cancel" onclick="panelAudio();cancelNotify()"></button></span></div><audio id="SAO-Notify-Panel" src="https://npm.elemecdn.com/akilar-candyassets/audio/Panel.mp3"></audio><audio id="SAO-Notify-Click" src="https://npm.elemecdn.com/akilar-candyassets/audio/Click.mp3"></audio>
12
+ </div>`
13
+ } else { //若未定义action代码片段,则仅输出单选项的弹窗
14
+ var template =`<div id="SAO-Notify"><style>` + tempstyle +`</style><div class="notify-title">` + `${title}` + `</div><div class="notify-alert"> `+ `${message}` + `</div><div class="notify-button"><span class="notify-receive"><button class="fas fa-check" type="button" name="receive" onclick="panelAudio();cancelNotify()"></button></span></div><audio id="SAO-Notify-Panel" src="https://npm.elemecdn.com/akilar-candyassets/audio/Panel.mp3"></audio><audio id="SAO-Notify-Click" src="https://npm.elemecdn.com/akilar-candyassets/audio/Click.mp3"></audio>
15
+ </div>`
16
+ };
17
+
18
+ document.body.insertAdjacentHTML('beforeend',template);
19
+ }
20
+
21
+
22
+ //按钮确认选项音效
23
+ function clickAudio() {
24
+ var clickAudio = document.getElementById("SAO-Notify-Click");
25
+ if (clickAudio) {
26
+ clickAudio.play();//有音频时播放
27
+ }
28
+ }
29
+ //按钮取消选项音效
30
+ function panelAudio() {
31
+ var panelAudio = document.getElementById("SAO-Notify-Panel");
32
+ if (panelAudio) {
33
+ panelAudio.play();//有音频时播放
34
+ }
35
+ }
36
+ // 关闭通知栏
37
+ function cancelNotify(){
38
+ var notifyWindow = document.getElementById('SAO-Notify');
39
+ notifyWindow.style.animation = 'flashClose 1.5s ease alternate ';
40
+ setTimeout(function() {
41
+ notifyWindow.remove();
42
+ }, 1e3);
43
+
44
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "elykia",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
package/welcome.js CHANGED
@@ -1,4 +1,4 @@
1
- const Elykia = {
1
+ const elykia = {
2
2
  // 欢迎语
3
3
  setWelcome_info: async () => {
4
4
  if (!document.getElementById("welcome-info")) return;
@@ -17,7 +17,7 @@ const Elykia = {
17
17
  // console.info(data);
18
18
  ipLoacation = data;
19
19
  saveToLocal.set('welcome-info', ipLoacation, 0.5);
20
- Elykia.showWelcome(ipLoacation);
20
+ elykia.showWelcome(ipLoacation);
21
21
  resolve();
22
22
  } else {
23
23
  reject(new Error('Failed to fetch location data'));
@@ -29,7 +29,7 @@ const Elykia = {
29
29
  });
30
30
  } else {
31
31
  await Promise.resolve(); // 确保在同步代码路径上也能保持异步风格
32
- Elykia.showWelcome(ipLoacation);
32
+ elykia.showWelcome(ipLoacation);
33
33
  }
34
34
  } catch (err) {
35
35
  console.error("Error fetching data:", err);
@@ -54,7 +54,7 @@ const Elykia = {
54
54
  showWelcome: (ipStore) => {
55
55
  const WelcomeInfo = document.getElementById("welcome-info"),
56
56
  IP = ipStore.result.ip || "未知";
57
- let dist = Elykia.getDistance(113.625000, 34.747201, ipStore.result.location.lng, ipStore.result.location.lat),
57
+ let dist = elykia.getDistance(113.625000, 34.747201, ipStore.result.location.lng, ipStore.result.location.lat),
58
58
  address,
59
59
  welcome_info;
60
60
  //根据国家、省份、城市信息自定义欢迎语