@karinjs/plugin-basic 1.0.8 → 1.1.0
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/README.md +5 -1
- package/config/config.json +2 -1
- package/dist/apps/login.d.ts +5 -0
- package/dist/apps/login.js +70 -0
- package/dist/apps/restart.js +2 -2
- package/dist/apps/status.js +3 -4
- package/dist/apps/update.js +2 -2
- package/dist/{chunk-FOHB2OK5.js → chunk-CUYZ6VZG.js} +12 -9
- package/dist/{chunk-UEURYWPB.js → chunk-DYA7JXHS.js} +3 -3
- package/dist/index.js +1 -1
- package/dist/web.config.d.ts +3 -1
- package/dist/web.config.js +9 -2
- package/package.json +5 -2
package/README.md
CHANGED
package/config/config.json
CHANGED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import {
|
|
2
|
+
config
|
|
3
|
+
} from "../chunk-DYA7JXHS.js";
|
|
4
|
+
import "../chunk-CUYZ6VZG.js";
|
|
5
|
+
|
|
6
|
+
// src/apps/login.ts
|
|
7
|
+
import karin, { common, contactFriend, logger, segment } from "node-karin";
|
|
8
|
+
import axios from "node-karin/axios";
|
|
9
|
+
import os from "os";
|
|
10
|
+
var url = { IPv4: ["https://4.ipw.cn"], IPv6: ["https://6.ipw.cn"] };
|
|
11
|
+
var login = karin.command(/#?(面板|web)登录$/i, async (e) => {
|
|
12
|
+
const net = os.networkInterfaces();
|
|
13
|
+
const cfg = config();
|
|
14
|
+
const IP = { lan: { ipv4: null, ipv6: null }, net: { ipv4: null, ipv6: null } };
|
|
15
|
+
for (const i in net) {
|
|
16
|
+
for (const iface of net[i]) {
|
|
17
|
+
if (iface.internal) continue;
|
|
18
|
+
if (iface.family === "IPv4") {
|
|
19
|
+
const ip = iface.address;
|
|
20
|
+
if (ip.startsWith("192.168.") || ip.startsWith("10.") || ip.startsWith("172.") && parseInt(ip.split(".")[1]) >= 16 && parseInt(ip.split(".")[1]) <= 31) {
|
|
21
|
+
IP.lan.ipv4 = ip;
|
|
22
|
+
}
|
|
23
|
+
} else if (iface.family === "IPv6") {
|
|
24
|
+
const ip = iface.address;
|
|
25
|
+
if (ip.startsWith("fd") || ip.startsWith("fe80:") || ip.startsWith("fc")) {
|
|
26
|
+
IP.lan.ipv6 = ip;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
IP.net.ipv4 = await getnetIP("IPv4");
|
|
32
|
+
IP.net.ipv6 = await getnetIP("IPv6");
|
|
33
|
+
const port = process.env.HTTP_PORT;
|
|
34
|
+
const token = process.env.HTTP_AUTH_KEY;
|
|
35
|
+
const msg = [segment.text("\u9762\u677F\u767B\u5F55\u5730\u5740\uFF1A")];
|
|
36
|
+
if (cfg.domain) msg.push(segment.text(`- \u81EA\u5B9A\u4E49\u57DF\u540D: ${cfg.domain}/web/login?token=${token}`));
|
|
37
|
+
msg.push(segment.text(`- \u5185\u7F51\u5730\u5740: ${IP.lan.ipv4 ? `http://${IP.lan.ipv4}:${port}/web/login?token=${token}` : `http://${IP.lan.ipv4}:${port}/web/login?token=${token}`}`));
|
|
38
|
+
if (IP.net.ipv4) msg.push(segment.text(`- \u5916\u7F51IPv4\u5730\u5740: http://${IP.net.ipv4}:${port}/web/login?token=${token}`));
|
|
39
|
+
if (IP.net.ipv6) msg.push(segment.text(`- \u5916\u7F51IPv6\u5730\u5740: http://${IP.net.ipv6}:${port}/web/login?token=${token}`));
|
|
40
|
+
try {
|
|
41
|
+
const content = common.makeForward(msg, e.selfId, e.bot.account.name);
|
|
42
|
+
await e.bot.sendForwardMsg(contactFriend(e.userId), content);
|
|
43
|
+
if (e.isGroup) await e.reply("\u767B\u5F55\u5730\u5740\u5DF2\u7ECF\u79C1\u4FE1\u7ED9\u4E3B\u4EBA\u4E86\u54E6~");
|
|
44
|
+
} catch (err) {
|
|
45
|
+
msg.forEach((item) => {
|
|
46
|
+
item.text = item.text + "\n";
|
|
47
|
+
});
|
|
48
|
+
await e.bot.sendMsg(contactFriend(e.userId), msg);
|
|
49
|
+
if (e.isGroup) await e.reply("\u767B\u5F55\u5730\u5740\u5DF2\u7ECF\u79C1\u4FE1\u7ED9\u4E3B\u4EBA\u4E86\u54E6~");
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
return true;
|
|
53
|
+
}, { name: "\u9762\u677F\u767B\u5F55", perm: "admin" });
|
|
54
|
+
async function getnetIP(type) {
|
|
55
|
+
for (const i of url[type] || []) {
|
|
56
|
+
try {
|
|
57
|
+
const res = await axios.get(i);
|
|
58
|
+
if (res.data) {
|
|
59
|
+
return res.data;
|
|
60
|
+
}
|
|
61
|
+
} catch (e) {
|
|
62
|
+
logger.error(`\u8BBF\u95EE${i}\u83B7\u53D6\u5916\u7F51${type}\u5730\u5740\u5931\u8D25: ${e}`);
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
export {
|
|
69
|
+
login
|
|
70
|
+
};
|
package/dist/apps/restart.js
CHANGED
package/dist/apps/status.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
config
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-DYA7JXHS.js";
|
|
4
|
+
import "../chunk-CUYZ6VZG.js";
|
|
5
5
|
|
|
6
6
|
// src/apps/status.ts
|
|
7
7
|
import moment from "node-karin/moment";
|
|
@@ -55,8 +55,7 @@ var uptime = () => {
|
|
|
55
55
|
const day = Math.floor(uptime2 / 86400);
|
|
56
56
|
const hour = Math.floor(uptime2 % 86400 / 3600);
|
|
57
57
|
const minute = Math.floor(uptime2 % 3600 / 60);
|
|
58
|
-
|
|
59
|
-
return `${day}\u5929${hour}\u5C0F\u65F6${minute}\u5206\u949F${seconds}\u79D2`;
|
|
58
|
+
return `${day > 0 ? `${day}\u5929` : ""}${hour}\u5C0F\u65F6${minute}\u5206\u949F`;
|
|
60
59
|
};
|
|
61
60
|
(() => {
|
|
62
61
|
if (!config().status) return;
|
package/dist/apps/update.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/apps/update.ts
|
|
2
|
-
import fs from "
|
|
3
|
-
import path from "
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import path from "path";
|
|
4
4
|
import { changelog, checkGitPluginUpdate, checkPkgUpdate, getCommit, getPlugins, getPkgVersion, karin, updateAllGitPlugin, updateAllPkg, updateGitPlugin, updatePkg } from "node-karin";
|
|
5
5
|
var cache = [];
|
|
6
6
|
var getAll = async () => {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// src/root.ts
|
|
2
|
-
import path from "
|
|
2
|
+
import path from "path";
|
|
3
3
|
|
|
4
4
|
// package.json
|
|
5
5
|
var package_default = {
|
|
6
6
|
name: "@karinjs/plugin-basic",
|
|
7
|
-
version: "1.0
|
|
7
|
+
version: "1.1.0",
|
|
8
8
|
description: "karin plugin for basic functions",
|
|
9
9
|
homepage: "https://github.com/KarinJS/karin-plugin-basic",
|
|
10
10
|
bugs: {
|
|
@@ -29,17 +29,17 @@ var package_default = {
|
|
|
29
29
|
build: "tsc && tsup",
|
|
30
30
|
pub: "npm publish --access public",
|
|
31
31
|
sort: "npx sort-package-json",
|
|
32
|
-
dev: "tsx src/
|
|
32
|
+
dev: "tsx src/app.ts",
|
|
33
33
|
watch: "tsx watch src/index.ts",
|
|
34
34
|
karin: "karin"
|
|
35
35
|
},
|
|
36
36
|
devDependencies: {
|
|
37
|
-
"@types/node": "^
|
|
38
|
-
eslint: "^9.
|
|
37
|
+
"@types/node": "^24.0.1",
|
|
38
|
+
eslint: "^9.29.0",
|
|
39
39
|
neostandard: "^0.12.1",
|
|
40
|
-
"node-karin": "^1.7
|
|
41
|
-
tsup: "^8.
|
|
42
|
-
tsx: "^4.
|
|
40
|
+
"node-karin": "^1.10.7",
|
|
41
|
+
tsup: "^8.5.0",
|
|
42
|
+
tsx: "^4.20.3",
|
|
43
43
|
typescript: "^5.8.3"
|
|
44
44
|
},
|
|
45
45
|
publishConfig: {
|
|
@@ -62,11 +62,14 @@ var package_default = {
|
|
|
62
62
|
],
|
|
63
63
|
"ts-web": "src/web.config.ts",
|
|
64
64
|
web: "dist/web.config.js"
|
|
65
|
+
},
|
|
66
|
+
dependencies: {
|
|
67
|
+
"internal-ip": "^8.0.0"
|
|
65
68
|
}
|
|
66
69
|
};
|
|
67
70
|
|
|
68
71
|
// src/root.ts
|
|
69
|
-
import { fileURLToPath } from "
|
|
72
|
+
import { fileURLToPath } from "url";
|
|
70
73
|
var __filename = fileURLToPath(import.meta.url);
|
|
71
74
|
var __dirname = path.dirname(__filename);
|
|
72
75
|
var __pluginDir = path.resolve(__dirname, "../");
|
package/dist/index.js
CHANGED
package/dist/web.config.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ interface Config {
|
|
|
10
10
|
restartMode: boolean;
|
|
11
11
|
/** 更新完成是否自动重启 */
|
|
12
12
|
restart: boolean;
|
|
13
|
+
/** 自定义登录域名 */
|
|
14
|
+
domain: string;
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
declare const _default: {
|
|
@@ -23,7 +25,7 @@ declare const _default: {
|
|
|
23
25
|
}[];
|
|
24
26
|
};
|
|
25
27
|
/** 动态渲染的组件 */
|
|
26
|
-
components: () => node_karin.SwitchProps[];
|
|
28
|
+
components: () => (node_karin.SwitchProps | node_karin.InputProps)[];
|
|
27
29
|
/** 前端点击保存之后调用的方法 */
|
|
28
30
|
save: (config: Config) => {
|
|
29
31
|
success: boolean;
|
package/dist/web.config.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
config,
|
|
3
3
|
writeConfig
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-DYA7JXHS.js";
|
|
5
5
|
import {
|
|
6
6
|
info
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-CUYZ6VZG.js";
|
|
8
8
|
|
|
9
9
|
// src/web.config.ts
|
|
10
10
|
import { components } from "node-karin";
|
|
@@ -47,6 +47,13 @@ var web_config_default = {
|
|
|
47
47
|
label: "\u81EA\u52A8\u91CD\u542F",
|
|
48
48
|
description: "\u66F4\u65B0\u5B8C\u6210\u662F\u5426\u81EA\u52A8\u91CD\u542F",
|
|
49
49
|
defaultSelected: cfg.restart
|
|
50
|
+
}),
|
|
51
|
+
components.input.string("domain", {
|
|
52
|
+
color: "success",
|
|
53
|
+
label: "\u81EA\u5B9A\u4E49\u57DF\u540D",
|
|
54
|
+
description: "Web\u767B\u5F55\u53D1\u9001\u7684\u81EA\u5B9A\u4E49\u57DF\u540D",
|
|
55
|
+
defaultValue: cfg.domain,
|
|
56
|
+
isRequired: false
|
|
50
57
|
})
|
|
51
58
|
];
|
|
52
59
|
return list;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@karinjs/plugin-basic",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "karin plugin for basic functions",
|
|
5
5
|
"homepage": "https://github.com/KarinJS/karin-plugin-basic",
|
|
6
6
|
"bugs": {
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"build": "tsc && tsup",
|
|
26
26
|
"pub": "npm publish --access public",
|
|
27
27
|
"sort": "npx sort-package-json",
|
|
28
|
-
"dev": "tsx src/
|
|
28
|
+
"dev": "tsx src/app.ts",
|
|
29
29
|
"watch": "tsx watch src/index.ts",
|
|
30
30
|
"karin": "karin"
|
|
31
31
|
},
|
|
@@ -49,5 +49,8 @@
|
|
|
49
49
|
],
|
|
50
50
|
"ts-web": "src/web.config.ts",
|
|
51
51
|
"web": "dist/web.config.js"
|
|
52
|
+
},
|
|
53
|
+
"dependencies": {
|
|
54
|
+
"internal-ip": "^8.0.0"
|
|
52
55
|
}
|
|
53
56
|
}
|