-
Notifications
You must be signed in to change notification settings - Fork 3
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
Conversation
* 补:更新 README.md * 再补:更新 README.md 艹,没补好 --------- Co-authored-by: Lingbo <ilovemc@zohomail.cn>
a fix
我到中午看一下吧 |
There was a problem hiding this 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的专属指令 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个写在上面的文字那吧,别放在代码块里了
而且,这就是Linux的命令,Windows不用改权限
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`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
所以为啥把这个提示删了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
针对本体进行优化,对症下药
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
删除这些日志输出可能是为了减少冗余信息,让日志输出更加简洁和有针对性
《可能》
一股GPT味(bushi
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
话说是不是可以加一个功能:日志分类
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
好的,那么这个任务就交给你了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
好的,那么这个任务就交给你了
彳亍口巴
叫你朋友来看。。。我自己开始晕了 |
/** | ||
* @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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为什么要删这个排序呢
不按字母顺序排我难受(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
啊。。。。好的那么,这个任务交给你了
return content.split(/\r?\n/) | ||
.map((line, index) => ({ ...parseHostsRecord(line), line: index + 1 })) | ||
.filter(record => record.ip || record.description); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
妙啊
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这是人类智慧的结晶(bushi
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
其实我不是人类 :)
彳亍 |
史山+不写注释+回调地狱的后果(doge |
我打算并了 |
你是看累了吧 |
绝对 |
备份功能: 添加了一个备份功能,现在在更新 hosts 文件之前会先创建一个原始 hosts 文件的备份。这样,用户在更新后出现问题时可以轻松恢复到原始状态。
恢复功能: 引入了一个新的命令 npm run restore,用于恢复原始的 hosts 文件。用户只需运行此命令,程序将自动将备份的 hosts 文件恢复为原始状态,方便快捷。
README-dev.md: 新增文件开发指南不过我也不知道为啥。。懒得写中文版了就这样了。。。
Log:更细致的log。会确认是否为权限不足引起的问题,避免很长的log取消过长的篇幅。
修改大大小小很多东西。。。
一切都是优化