forked from xuzhenjun130/hostsSwitchHelper
-
Notifications
You must be signed in to change notification settings - Fork 19
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
34 changed files
with
226 additions
and
11,995 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
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,6 @@ | ||
web-ui-src/node_modules | ||
web-ui-src/.cache | ||
web-ui-src/package-lock.json | ||
web-ui-src/yarn.lock | ||
.build | ||
dist |
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 |
---|---|---|
@@ -1,28 +1,29 @@ | ||
# hostsSwitchHelper | ||
# hostsSwitchHelper - Hosts切换助手 | ||
|
||
hosts切换助手 | ||
hosts切换助手调用系统安装的Chromium 内核浏览器创建应用程序, | ||
只要安装了Chrome、EDGE、2345、360.....这些浏览器之一都可以运行。 | ||
`生成的EXE文件打包以后只有700KB`,体积只有SwitchHosts的50分之一, | ||
并且可以支持WinXP 到 Win 10的所有流行操作系统( 支持Win10文件夺权解决不能编辑问题 )。 | ||
|
||
 | ||
|
||
功能基本参考SwitchHosts,SwitchHosts 基于Electron,兼容多系统,但是文件体积比较大50M+。在最新版chrome浏览器已经无法使用remote debugging protocol 来清理DNS缓存了,于是自己动手写一个。 | ||
|
||
hosts切换助手调用系统安装的chrome浏览器创建应用程序。只能在windows下使用,但是文件体积压缩后不到1M。 | ||
|
||
前端使用element-ui,快速创建一个还算漂亮的界面。 | ||
此软件功能基本参考SwitchHosts,考虑到SwitchHosts 基于Electron,文件体积比较大(50M+), | ||
不支持XP操作系统,在Win10上也用不了。而且在最新版chrome浏览器已经无法使用remote debugging protocol 来清理DNS缓存了,于是自己动手写一个。 | ||
|
||
桌面程序使用aardio开发。 | ||
|
||
|
||
|
||
build 步骤: | ||
 | ||
|
||
- 1. ui目录安装依赖后 `npm run build` | ||
- 2. arrdio软件打开项目 -> 发布。 | ||
- 3. Publish为软件发布目录,可以看到编译生成的 `Hosts切换助手.exe` 及前端资目录 `res` | ||
前端使用 vue / element-ui,快速创建一个还算漂亮的界面。 | ||
桌面程序使用aardio开发( http://www.aardio.com )。 | ||
|
||
构建步骤: | ||
|
||
- 1. 使用aardio开发环境打开 default.aproj 工程文件 | ||
- 2. 在aardio工程中右键点“前端源码”, | ||
在弹出菜单中选择“用外部编辑器打开”,默认会在VS Code中打开,然后执行命令: | ||
`npm i` 安装所有node依赖模块 | ||
`npm run build` 就可以编译前端代码 | ||
- 3. 在 aardio 开发环境中点击“发布”生成EXE文件。 | ||
dist 为软件发布目录,可以看到编译生成的 `Hosts切换助手.exe` | ||
|
||
[下载地址](https://github.com/xuzhenjun130/hostsSwitchHelper/releases) | ||
[下载地址](https://github.com/aardio/hostsSwitchHelper/releases) | ||
|
||
|
||
|
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 |
---|---|---|
@@ -1,8 +1,9 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<project ver="10" name="Hosts切换助手" libEmbed="true" icon="res\favicon.ico" ui="win" output="Hosts切换助手.exe" CompanyName="手盟网络" FileDescription="Hosts切换助手 412530435@qq.com" LegalCopyright="Copyright (C) sherman 2019" ProductName="Hosts切换助手" InternalName="switchHosts" FileVersion="0.0.0.11" ProductVersion="0.0.0.11" publishDir="/Publish/" dstrip="false"> | ||
<project ver="10" name="Hosts切换助手" libEmbed="true" icon="\web-ui\favicon.ico" ui="win" output="Hosts切换助手.exe" CompanyName="手盟网络" FileDescription="Hosts切换助手 412530435@qq.com" LegalCopyright="Copyright (C) sherman 2019" ProductName="Hosts切换助手" InternalName="switchHosts" FileVersion="1.0.0.0" ProductVersion="1.0.0.0" publishDir="\dist\" dstrip="false" local="false"> | ||
<file name="main.aardio" path="main.aardio" comment="main.aardio"/> | ||
<folder name="Js渲染进程" path="res" embed="true"> | ||
<file name="favicon.ico" path="res\favicon.ico" comment="窗口图标"/> | ||
<file name="index.aardio" path="res\index.aardio" comment="res\index.aardio"/> | ||
<folder name="前端" path="web-ui" embed="true" local="true"> | ||
<file name="favicon.ico" path="web-ui\favicon.ico" comment="web-ui\favicon.ico"/> | ||
<file name="index.aardio" path="web-ui\index.aardio" comment="web-ui\index.aardio"/> | ||
</folder> | ||
<folder name="前端源码 (请勿同步)" path="web-ui-src" embed="false" comment="目录" local="false"/> | ||
</project> |
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,73 @@ | ||
import fsys.ini; | ||
import fsys.hosts; | ||
|
||
fsys.hosts.ownCacls(); //hosts夺权,修正一些系统hosts无法编辑 | ||
|
||
class iniHosts{ | ||
ctor(){ | ||
this.path = ..io.appData("aardio/hosts-switch.ini"); | ||
this.ini = ..fsys.ini(this.path); | ||
if( ! #this.ini.getSectionNames() ){ | ||
sec = this.ini.getSection("备份hosts"); | ||
sec.status = "on"; | ||
sec.hosts = ..string.hex( ..fsys.hosts.loadText() ) // 转16进制 | ||
sec.name = "备份hosts"; | ||
sec.save() | ||
} | ||
}; | ||
saveToSystemHosts = function(){ | ||
var content = ""; | ||
for section in this.ini.eachSection() { | ||
if(section.status=="on"){ | ||
content += ..string.unhex(section.hosts) + '\r\n' //16进转字符串 | ||
} | ||
} | ||
..fsys.hosts.saveText(content) | ||
}; | ||
createSection = function(name){ | ||
sec = this.ini.getSection(name) | ||
sec.status = "on" | ||
sec.hosts = "# " + name | ||
sec.name = name | ||
sec.save() | ||
return "create ok" | ||
}; | ||
getAllSections = function(){ | ||
var tab = {} | ||
for section in this.ini.eachSection() { | ||
section.hosts = ..string.unhex(section.hosts) //16进转字符串 | ||
..table.push(tab,section) | ||
} | ||
return tab; | ||
}; | ||
updateSection = function(oldName,newName,status,data){ | ||
if(oldName != newName){ | ||
this.ini.write(oldName,null,) | ||
} | ||
|
||
sec = this.ini.getSection(newName) | ||
sec.status = status | ||
sec.hosts = ..string.hex(data) // 转16进制 | ||
sec.name = newName | ||
sec.save() | ||
this.saveToSystemHosts() | ||
return "update ok" | ||
}; | ||
delSection = function(name){ | ||
this.ini.write(name,null) | ||
this.saveToSystemHosts() | ||
return "del ok" | ||
}; | ||
} | ||
|
||
/**intellisense() | ||
iniHosts() = 创建host配置文件\n!iniHostsObject. | ||
end intellisense**/ | ||
|
||
/**intellisense(!iniHostsObject) | ||
saveToSystemHosts() = 导出到系统hosts文件 | ||
createSection(.(name) = 创建hosts配置小节 | ||
getAllSections() = 返回所有hosts配置小节 | ||
updateSection(.(oldName,newName,status,data) = 更新hosts配置小节 | ||
delSection(.(name) = 删除hosts配置节 | ||
end intellisense**/ |
Oops, something went wrong.