Skip to content

Commit a5b9fb1

Browse files
committed
重构
1 parent a6b7b9d commit a5b9fb1

34 files changed

+226
-11995
lines changed

.build/default.Manifest.xml

Lines changed: 0 additions & 61 deletions
This file was deleted.

.build/default.init.aardio

Lines changed: 0 additions & 2 deletions
This file was deleted.

.build/default.main.aardio

Lines changed: 0 additions & 6 deletions
This file was deleted.

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
web-ui-src/node_modules
2+
web-ui-src/.cache
3+
web-ui-src/package-lock.json
4+
web-ui-src/yarn.lock
5+
.build
6+
dist

README.md

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
1-
# hostsSwitchHelper
1+
# hostsSwitchHelper - Hosts切换助手
22

3-
hosts切换助手
3+
hosts切换助手调用系统安装的Chromium 内核浏览器创建应用程序,
4+
只要安装了Chrome、EDGE、2345、360.....这些浏览器之一都可以运行。
5+
`生成的EXE文件打包以后只有700KB`,体积只有SwitchHosts的50分之一,
6+
并且可以支持WinXP 到 Win 10的所有流行操作系统( 支持Win10文件夺权解决不能编辑问题 )。
47

5-
![](https://github.com/xuzhenjun130/hostsSwitchHelper/blob/master/res/main.png?raw=true)
6-
7-
功能基本参考SwitchHosts,SwitchHosts 基于Electron,兼容多系统,但是文件体积比较大50M+。在最新版chrome浏览器已经无法使用remote debugging protocol 来清理DNS缓存了,于是自己动手写一个。
8-
9-
hosts切换助手调用系统安装的chrome浏览器创建应用程序。只能在windows下使用,但是文件体积压缩后不到1M。
10-
11-
前端使用element-ui,快速创建一个还算漂亮的界面。
8+
此软件功能基本参考SwitchHosts,考虑到SwitchHosts 基于Electron,文件体积比较大(50M+),
9+
不支持XP操作系统,在Win10上也用不了。而且在最新版chrome浏览器已经无法使用remote debugging protocol 来清理DNS缓存了,于是自己动手写一个。
1210

13-
桌面程序使用aardio开发。
14-
15-
16-
17-
build 步骤:
11+
![](https://github.com/xuzhenjun130/hostsSwitchHelper/blob/master/res/main.png?raw=true)
1812

19-
- 1. ui目录安装依赖后 `npm run build`
20-
- 2. arrdio软件打开项目 -> 发布。
21-
- 3. Publish为软件发布目录,可以看到编译生成的 `Hosts切换助手.exe` 及前端资目录 `res`
13+
前端使用 vue / element-ui,快速创建一个还算漂亮的界面。
14+
桌面程序使用aardio开发( http://www.aardio.com )。
2215

16+
构建步骤:
2317

18+
- 1. 使用aardio开发环境打开 default.aproj 工程文件
19+
- 2. 在aardio工程中右键点“前端源码”,
20+
在弹出菜单中选择“用外部编辑器打开”,默认会在VS Code中打开,然后执行命令:
21+
`npm i` 安装所有node依赖模块
22+
`npm run build` 就可以编译前端代码
23+
- 3. 在 aardio 开发环境中点击“发布”生成EXE文件。
24+
dist 为软件发布目录,可以看到编译生成的 `Hosts切换助手.exe`
2425

25-
[下载地址](https://github.com/xuzhenjun130/hostsSwitchHelper/releases)
26+
[下载地址](https://github.com/aardio/hostsSwitchHelper/releases)
2627

2728

2829

default.aproj

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<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">
2+
<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">
33
<file name="main.aardio" path="main.aardio" comment="main.aardio"/>
4-
<folder name="Js渲染进程" path="res" embed="true">
5-
<file name="favicon.ico" path="res\favicon.ico" comment="窗口图标"/>
6-
<file name="index.aardio" path="res\index.aardio" comment="res\index.aardio"/>
4+
<folder name="前端" path="web-ui" embed="true" local="true">
5+
<file name="favicon.ico" path="web-ui\favicon.ico" comment="web-ui\favicon.ico"/>
6+
<file name="index.aardio" path="web-ui\index.aardio" comment="web-ui\index.aardio"/>
77
</folder>
8+
<folder name="前端源码 (请勿同步)" path="web-ui-src" embed="false" comment="目录" local="false"/>
89
</project>

lib/iniHosts.aardio

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import fsys.ini;
2+
import fsys.hosts;
3+
4+
fsys.hosts.ownCacls(); //hosts夺权,修正一些系统hosts无法编辑
5+
6+
class iniHosts{
7+
ctor(){
8+
this.path = ..io.appData("aardio/hosts-switch.ini");
9+
this.ini = ..fsys.ini(this.path);
10+
if( ! #this.ini.getSectionNames() ){
11+
sec = this.ini.getSection("备份hosts");
12+
sec.status = "on";
13+
sec.hosts = ..string.hex( ..fsys.hosts.loadText() ) // 转16进制
14+
sec.name = "备份hosts";
15+
sec.save()
16+
}
17+
};
18+
saveToSystemHosts = function(){
19+
var content = "";
20+
for section in this.ini.eachSection() {
21+
if(section.status=="on"){
22+
content += ..string.unhex(section.hosts) + '\r\n' //16进转字符串
23+
}
24+
}
25+
..fsys.hosts.saveText(content)
26+
};
27+
createSection = function(name){
28+
sec = this.ini.getSection(name)
29+
sec.status = "on"
30+
sec.hosts = "# " + name
31+
sec.name = name
32+
sec.save()
33+
return "create ok"
34+
};
35+
getAllSections = function(){
36+
var tab = {}
37+
for section in this.ini.eachSection() {
38+
section.hosts = ..string.unhex(section.hosts) //16进转字符串
39+
..table.push(tab,section)
40+
}
41+
return tab;
42+
};
43+
updateSection = function(oldName,newName,status,data){
44+
if(oldName != newName){
45+
this.ini.write(oldName,null,)
46+
}
47+
48+
sec = this.ini.getSection(newName)
49+
sec.status = status
50+
sec.hosts = ..string.hex(data) // 转16进制
51+
sec.name = newName
52+
sec.save()
53+
this.saveToSystemHosts()
54+
return "update ok"
55+
};
56+
delSection = function(name){
57+
this.ini.write(name,null)
58+
this.saveToSystemHosts()
59+
return "del ok"
60+
};
61+
}
62+
63+
/**intellisense()
64+
iniHosts() = 创建host配置文件\n!iniHostsObject.
65+
end intellisense**/
66+
67+
/**intellisense(!iniHostsObject)
68+
saveToSystemHosts() = 导出到系统hosts文件
69+
createSection(.(name) = 创建hosts配置小节
70+
getAllSections() = 返回所有hosts配置小节
71+
updateSection(.(oldName,newName,status,data) = 更新hosts配置小节
72+
delSection(.(name) = 删除hosts配置节
73+
end intellisense**/

0 commit comments

Comments
 (0)