-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
156 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import pkg from 'fs-extra'; | ||
const { ensureDirSync, copySync, readdirSync, lstatSync, chmodSync, existsSync } = pkg; | ||
import { join } from 'node:path'; | ||
import { spawn } from 'child_process'; | ||
|
||
export function copy(source, target) { | ||
/** | ||
* asar 里不能复制文件夹,需要用 mkdir 创建 | ||
*/ | ||
function step(src, dist) { | ||
if (!existsSync(src)) { | ||
return; | ||
} | ||
const fileStat = lstatSync(src); | ||
|
||
if (fileStat.isDirectory()) { | ||
ensureDirSync(dist); | ||
if (!fileStat.isSymbolicLink()) chmodSync(dist, 511); | ||
const list = readdirSync(src); | ||
for (const name of list) { | ||
step(join(src, name), join(dist, name)); | ||
} | ||
} else { | ||
copySync(src, dist); | ||
if (!fileStat.isSymbolicLink()) chmodSync(dist, 511); | ||
} | ||
} | ||
|
||
step(source, target); | ||
} | ||
|
||
// 创建一个软连接的文件夹 & 复制包含软连接的文件 | ||
const child = spawn('ln', ['-s', '/Users/alan/cocos/fe-team/packages-demos/cocos-plugin-vue2', '/Users/alan/cocos/fe-team/packages-demos/others/copy/test']); | ||
child.addListener('close', (code, signal) => { | ||
if (code === 0) { | ||
copy('/Users/alan/cocos/fe-team/packages-demos/others/copy/test', '/Users/alan/cocos/fe-team/packages-demos/others/copy/test-copy'); | ||
} else { | ||
console.log(code, signal); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
123 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/Users/alan/cocos/fe-team/packages-demos/cocos-plugin-vue2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
123 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import nodemailer from 'nodemailer'; | ||
|
||
// 创建一个 transporter 实例,配置 SMTP 服务提供商的凭据 | ||
const transporter = nodemailer.createTransport({ | ||
host: 'smtp.qq.com', // 替换为实际 SMTP 服务器主机名 | ||
port: 587, // 或其他适用端口,如 465(SSL)、25(非加密) | ||
secure: false, // 使用 SSL/TLS 连接,如果是非标准端口,通常应设为 true | ||
auth: { | ||
user: '741484865@qq.com', // 替换为您的邮箱用户名或邮箱地址 | ||
pass: 'lfqvfktuspembbbc', // 替换为您的邮箱密码或应用生成的授权码 | ||
}, | ||
// 其他可选配置,如 TLS 特定选项、代理设置等 | ||
}); | ||
|
||
// 定义邮件内容 | ||
const mailOptions = { | ||
from: '"袁炜海" <741484865@qq.com>', // 发件人姓名和地址 | ||
to: 'yuanweihai25@163.com', // 收件人地址,可以是单个或数组 ['user1@example.com', 'user2@example.com'] | ||
subject: '邮件主题', // 邮件主题 | ||
text: 'This is a plain-text email body.', // 纯文本邮件正文 | ||
// html: '<p>This is an <strong>HTML</strong> email body.</p>', // HTML 格式的邮件正文(可选) | ||
|
||
// 附件(可选) | ||
// attachments: [ | ||
// { | ||
// filename: 'example.txt', | ||
// path: './path/to/example.txt', | ||
// }, | ||
// { | ||
// filename: 'image.png', | ||
// path: './path/to/image.png', | ||
// cid: 'unique-image-id', // Content-Id for inline embedding | ||
// }, | ||
// ], | ||
}; | ||
|
||
// 发送邮件 | ||
transporter.sendMail(mailOptions, (error, info) => { | ||
if (error) { | ||
console.error('Failed to send email:', error); | ||
} else { | ||
console.log('Email sent successfully. Response:', info); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "others", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"fs-extra": "^11.2.0", | ||
"nodemailer": "^6.9.13" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters