yuangs 1.0.0 → 1.0.1
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 +17 -9
- package/index.js +49 -18
- package/package.json +6 -5
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# yuangs
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
苑广山的个人工具箱与应用导航。
|
|
4
4
|
|
|
5
5
|
## 安装
|
|
6
6
|
|
|
@@ -8,18 +8,26 @@
|
|
|
8
8
|
npm install yuangs
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
##
|
|
11
|
+
## 功能
|
|
12
|
+
|
|
13
|
+
包含以下个人应用的快捷访问:
|
|
14
|
+
|
|
15
|
+
1. **古诗词 PWA**: [https://wealth.want.biz/shici/index.html](https://wealth.want.biz/shici/index.html)
|
|
16
|
+
2. **英语词典**: [https://wealth.want.biz/pages/dict.html](https://wealth.want.biz/pages/dict.html)
|
|
17
|
+
3. **Pong 游戏**: [https://wealth.want.biz/pages/pong.html](https://wealth.want.biz/pages/pong.html)
|
|
18
|
+
|
|
19
|
+
## 使用方法
|
|
12
20
|
|
|
13
21
|
```javascript
|
|
14
|
-
const
|
|
22
|
+
const yuangs = require("yuangs");
|
|
15
23
|
|
|
16
|
-
// 1.
|
|
17
|
-
|
|
18
|
-
// 输出: Hello, YGS! 恭喜你成功使用了 yuangs
|
|
24
|
+
// 1. 列出所有应用
|
|
25
|
+
yuangs.listApps();
|
|
19
26
|
|
|
20
|
-
// 2.
|
|
21
|
-
|
|
22
|
-
|
|
27
|
+
// 2. 在浏览器中打开应用 (支持 Mac/Windows/Linux)
|
|
28
|
+
yuangs.openShici(); // 打开古诗词
|
|
29
|
+
yuangs.openDict(); // 打开词典
|
|
30
|
+
yuangs.openPong(); // 打开游戏
|
|
23
31
|
```
|
|
24
32
|
|
|
25
33
|
## 维护者
|
package/index.js
CHANGED
|
@@ -1,25 +1,56 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return message;
|
|
10
|
-
}
|
|
1
|
+
const { exec } = require('child_process');
|
|
2
|
+
const os = require('os');
|
|
3
|
+
|
|
4
|
+
const APPS = {
|
|
5
|
+
shici: 'https://wealth.want.biz/shici/index.html',
|
|
6
|
+
dict: 'https://wealth.want.biz/pages/dict.html',
|
|
7
|
+
pong: 'https://wealth.want.biz/pages/pong.html'
|
|
8
|
+
};
|
|
11
9
|
|
|
12
10
|
/**
|
|
13
|
-
*
|
|
14
|
-
* @param {
|
|
15
|
-
* @param {number} b
|
|
16
|
-
* @returns {number}
|
|
11
|
+
* 打开 URL 的通用函数
|
|
12
|
+
* @param {string} url
|
|
17
13
|
*/
|
|
18
|
-
function
|
|
19
|
-
|
|
14
|
+
function openUrl(url) {
|
|
15
|
+
let command;
|
|
16
|
+
switch (process.platform) {
|
|
17
|
+
case 'darwin': // macOS
|
|
18
|
+
command = `open "${url}"`;
|
|
19
|
+
break;
|
|
20
|
+
case 'win32': // Windows
|
|
21
|
+
command = `start "${url}"`;
|
|
22
|
+
break;
|
|
23
|
+
default: // Linux
|
|
24
|
+
command = `xdg-open "${url}"`;
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
console.log(`正在打开: ${url} ...`);
|
|
29
|
+
exec(command, (error) => {
|
|
30
|
+
if (error) {
|
|
31
|
+
console.error(`打开失败: ${error.message}`);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
20
34
|
}
|
|
21
35
|
|
|
22
36
|
module.exports = {
|
|
23
|
-
|
|
24
|
-
|
|
37
|
+
// 导出链接常量
|
|
38
|
+
urls: APPS,
|
|
39
|
+
|
|
40
|
+
// 打开古诗词应用
|
|
41
|
+
openShici: () => openUrl(APPS.shici),
|
|
42
|
+
|
|
43
|
+
// 打开英语词典
|
|
44
|
+
openDict: () => openUrl(APPS.dict),
|
|
45
|
+
|
|
46
|
+
// 打开 Pong 游戏
|
|
47
|
+
openPong: () => openUrl(APPS.pong),
|
|
48
|
+
|
|
49
|
+
// 打印所有应用列表
|
|
50
|
+
listApps: () => {
|
|
51
|
+
console.log('--- YGS Apps ---');
|
|
52
|
+
console.log(`1. 古诗词 (PWA): ${APPS.shici}`);
|
|
53
|
+
console.log(`2. 英语词典: ${APPS.dict}`);
|
|
54
|
+
console.log(`3. Pong 游戏: ${APPS.pong}`);
|
|
55
|
+
}
|
|
25
56
|
};
|
package/package.json
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yuangs",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "苑广山的个人应用集合 (PWA, 词典, 游戏)",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
8
|
},
|
|
9
9
|
"keywords": [
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
10
|
+
"yuangs",
|
|
11
|
+
"pwa",
|
|
12
|
+
"game",
|
|
13
|
+
"tools"
|
|
13
14
|
],
|
|
14
15
|
"author": "yuanguangshan",
|
|
15
16
|
"license": "ISC",
|