Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A merge from dev to main (v1.3.0) #15

Merged
merged 7 commits into from
May 27, 2024
Merged

A merge from dev to main (v1.3.0) #15

merged 7 commits into from
May 27, 2024

Conversation

Minemetero
Copy link
Collaborator

@Minemetero Minemetero commented May 26, 2024

备份功能: 添加了一个备份功能,现在在更新 hosts 文件之前会先创建一个原始 hosts 文件的备份。这样,用户在更新后出现问题时可以轻松恢复到原始状态。

恢复功能: 引入了一个新的命令 npm run restore,用于恢复原始的 hosts 文件。用户只需运行此命令,程序将自动将备份的 hosts 文件恢复为原始状态,方便快捷。

README-dev.md: 新增文件开发指南不过我也不知道为啥。。懒得写中文版了就这样了。。。

Log:更细致的log。会确认是否为权限不足引起的问题,避免很长的log取消过长的篇幅。

修改大大小小很多东西。。。一切都是优化

Minemetero and others added 4 commits May 14, 2024 20:51
* 补:更新 README.md

* 再补:更新 README.md

艹,没补好

---------

Co-authored-by: Lingbo <ilovemc@zohomail.cn>
@Minemetero Minemetero requested a review from lingbopro May 26, 2024 11:43
@lingbopro
Copy link
Owner

我到中午看一下吧

@lingbopro lingbopro added 增强 新功能或请求 合并 从其他分支合并到主分支 labels May 27, 2024
Copy link
Owner

@lingbopro lingbopro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

看了一些,回头仔细看

@@ -34,6 +34,7 @@ npm install

确保你有执行权限:
```shell
#似乎这只是Linux的专属指令
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个写在上面的文字那吧,别放在代码块里了
而且,这就是Linux的命令,Windows不用改权限

docs/README-dev.md Outdated Show resolved Hide resolved
updateHosts.js Show resolved Hide resolved
updateHosts.js Show resolved Hide resolved
Comment on lines -242 to -243
console.log(`${appName}: Please try running this program as Administrator (or super user).`);
console.log(`${appName}: If the error occurred again, please report an issue at https://github.com/lingbopro/easy-github-hosts/issues`);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

所以为啥把这个提示删了

Copy link
Collaborator Author

@Minemetero Minemetero May 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

针对本体进行优化,对症下药

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

删除这些日志输出可能是为了减少冗余信息,让日志输出更加简洁和有针对性

《可能》
一股GPT味(bushi

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

话说是不是可以加一个功能:日志分类

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好的,那么这个任务就交给你了

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好的,那么这个任务就交给你了

彳亍口巴

updateHosts.js Show resolved Hide resolved
@Minemetero
Copy link
Collaborator Author

看了一些,回头仔细看

叫你朋友来看。。。我自己开始晕了

Comment on lines 79 to -132
/**
* @function sortArrayByItemProperty
* 根据数组中每个对象的属性排序数组
* @param {array} array - 数组
* @param {string} prop - 属性名
* @returns {array} - 排序后的数组
* 创建 HOSTS 文件的备份
* @param {string} hostsPath - HOSTS 文件路径
* @returns {string} - 备份文件路径
*/
function sortArrayByItemProperty(array, prop) {
for (let a = 0; a < array.length; a++) {
for (let b = a + 1; b < array.length; b++) {
if (array[a][prop] > array[b][prop]) {
let temp = array[a];
array[a] = array[b];
array[b] = temp;
}
function createBackup(hostsPath) {
const backupPath = `${hostsPath}.backup`;
try {
fs.copyFileSync(hostsPath, backupPath);
console.log(`${appName}: Created backup at ${backupPath}`);
return backupPath;
} catch (err) {
if (err.code === 'EPERM') {
console.error(`${appName}: ERROR - Permission denied while creating backup. Please run this program as Administrator (or super user).`);
} else {
console.error(`${appName}: ERROR - Error creating backup:`, err);
}
process.exit(1);
}
return array;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为什么要删这个排序呢
不按字母顺序排我难受(

Copy link
Collaborator Author

@Minemetero Minemetero May 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

啊。。。。好的那么,这个任务交给你了

Comment on lines +55 to +57
return content.split(/\r?\n/)
.map((line, index) => ({ ...parseHostsRecord(line), line: index + 1 }))
.filter(record => record.ip || record.description);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

妙啊

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这是人类智慧的结晶(bushi

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

其实我不是人类 :)

@lingbopro
Copy link
Owner

看了一些,回头仔细看

叫你朋友来看。。。我自己开始晕了

彳亍
不过他今天不一定有时间

@lingbopro
Copy link
Owner

看了一些,回头仔细看

叫你朋友来看。。。我自己开始晕了

史山+不写注释+回调地狱的后果(doge

@lingbopro
Copy link
Owner

我打算并了

@lingbopro lingbopro merged commit 6d38d94 into main May 27, 2024
@Minemetero
Copy link
Collaborator Author

Minemetero commented May 27, 2024

我打算并了

你是看累了吧

@Minemetero Minemetero deleted the dev branch May 28, 2024 09:38
@lingbopro
Copy link
Owner

我打算并了

你是看累了吧

绝对不是(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
合并 从其他分支合并到主分支 增强 新功能或请求
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants