-
Notifications
You must be signed in to change notification settings - Fork 8
/
main.aardio
154 lines (138 loc) · 5.7 KB
/
main.aardio
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
//amod 第三方库管理工具
//todo:
//缓存的库文件的路径应该加上版本以区分不同版本
//git clone 和 下载 url 应该新建一个lock文件写入版本,下次下载应该下载或 clone 指定版本hash
//为远程库建立库提交规范
//为每个库函数建立单元测试文件
import fonts.fontAwesome;
import win.ui;
/*DSG{{*/
mainForm = win.form(text="amod";right=1040;bottom=682;bgcolor=15793151;border="none";max=false)
mainForm.add(
bkplus2={cls="bkplus";left=0;top=646;right=1042;bottom=685;bgcolor=633981;dl=1;dr=1;dt=1;forecolor=702855;linearGradient=4;z=1};
caption={cls="bkplus";text="AMOD 包管理";left=22;top=12;right=147;bottom=30;color=15780518;dl=1;dt=1;font=LOGFONT(h=-14;weight=700);z=5};
custom={cls="custom";left=0;top=40;right=1041;bottom=647;bgcolor=16777215;db=1;dl=1;dr=1;dt=1;repeat="scale";z=2};
fork={cls="plus";text="Fork | 100k";left=907;top=651;right=1023;bottom=680;align="left";border={color=-10066330;radius=8;width=2};dl=1;dt=1;iconStyle={align="left";font=LOGFONT(h=-16;name='FontAwesome');padding={left=11;top=4}};iconText='\uF287';notify=1;paddingLeft=1;paddingRight=1;paddingTop=3;textPadding={left=35;bottom=1};x=0.5;y=0.2;z=9};
log={cls="plus";text="启动成功 ";left=216;top=656;right=756;bottom=678;color=128;z=12};
navNewLib={cls="plus";text="新建";left=359;top=5;right=453;bottom=40;align="left";color=16777215;dl=1;dt=1;font=LOGFONT(h=-16);iconStyle={align="left";font=LOGFONT(h=-19;name='FontAwesome');padding={left=12;top=4}};iconText='\uF002';notify=1;paddingLeft=1;paddingRight=1;paddingTop=3;textPadding={left=39;bottom=1};x=0.5;y=0.2;z=13};
navRemote={cls="plus";text="远程";left=260;top=5;right=354;bottom=40;align="left";color=16777215;dl=1;dt=1;font=LOGFONT(h=-16);iconStyle={align="left";font=LOGFONT(h=-19;name='FontAwesome');padding={left=12;top=4}};iconText='\uF002';notify=1;paddingLeft=1;paddingRight=1;paddingTop=3;textPadding={left=39;bottom=1};x=0.5;y=0.2;z=6};
navSetting={cls="plus";text="管理";left=166;top=5;right=260;bottom=40;align="left";color=16777215;dl=1;dt=1;font=LOGFONT(h=-16);iconStyle={align="left";font=LOGFONT(h=-19;name='FontAwesome');padding={left=12;top=4}};iconText='\uF0AD';notify=1;paddingLeft=1;paddingRight=1;paddingTop=3;textPadding={left=39;bottom=1};x=0.5;y=0.2;z=4};
plus2={cls="plus";left=11;top=7;right=39;bottom=30;background="\res\logo_ico.ico";repeat="scale";z=7};
qq={cls="plus";text="QQ: 37791537";left=119;top=657;right=213;bottom=679;align="left";z=10};
star={cls="plus";text="Star | 100k";left=770;top=651;right=886;bottom=680;align="left";border={color=-10066330;radius=8;width=2};dl=1;dt=1;iconStyle={align="left";font=LOGFONT(h=-16;name='FontAwesome');padding={left=11;top=4}};iconText='\uF006';notify=1;paddingLeft=1;paddingRight=1;paddingTop=3;textPadding={left=35;bottom=1};x=0.5;y=0.2;z=8};
titleBar={cls="bkplus";left=0;top=0;right=1042;bottom=40;bgcolor=14977280;dl=1;dr=1;dt=1;z=3};
version={cls="plus";text="v 0.0.1";left=52;top=656;right=121;bottom=678;align="left";z=14};
versionStr={cls="plus";text="版本:";left=7;top=656;right=55;bottom=678;align="left";z=11}
)
/*}}*/
import win.dlg.message
import win.ui.tabs;
import win.ui.simpleWindow;
import config
import win.ui.atom
var atom,hwndConflict = mainForm.atom("E4F46764-614B-4C2B-A317-CC5224067F3D");
if(!atom){
/*为窗口设置原子值可以避免一个程序重复运行多个实例*/
win.quitMessage(); return;
};
subscribe("log",function(...){
msg = string.concat(...)
mainForm.log.text = msg
} )
publish("log","启动成功")
tbs = win.ui.tabs(
mainForm.navSetting,
mainForm.navRemote,
mainForm.navNewLib
);
tbs.skin({
foreground={
active=0xFFFFFFFF;
default=0x00FFFFFF;
hover=0x38FFFFFF
};
color={
default=0xFFFFFFFF;
};
checked={
foreground={default=0xFFFFFFFF;};
color={default=0xFF42A875;};
}
})
tbs.loadForm(1,"\dlg\setting.aardio" );
tbs.loadForm(2,"\dlg\remote.aardio" );
tbs.loadForm(3,"\dlg\newlib.aardio" );
mainForm.star.oncommand = function(id,event){
import process;
process.execute("https://github.com/zzerding/amod");
}
tbs.onSelchange = function(idx,strip,form){
select(idx) {
case 1,2 {
tbs.selForm.reloadList()
}
}
}
mainForm.fork.oncommand = function(id,event){
import process;
process.execute("https://github.com/zzerding/amod");
}
tbs.selIndex = 1
win.ui.simpleWindow( mainForm )
//update github start count
thread.invoke(
function(mainForm){
import win;
import web.rest.github
var clent = web.rest.github()
try{
var githubRespose = clent.api().repos["zzerding/amod"].get()
if(githubRespose){
mainForm.star.text = "Star | "+ githubRespose.stargazers_count
mainForm.fork.text = "Fork | " + githubRespose.forks_count
}
}
catch(e){
mainForm.publish("log","github 连接失败")
}
}
,mainForm)
//update package
mainForm.version.text = config.toml.version
function getRemoteTag(){
return ..win.invoke(
function(mainForm){
import win;
import web.rest.github
var clent = web.rest.github()
var tag,err
try{
var githubRespose = clent.api().repos["zzerding/amod"].tags.get()
tag = githubRespose[1].name
}
catch(e){
err = e
}
return tag,err;
}
)
}
function updata(){
publish("log","检查更新...")
var remoteTag,err = getRemoteTag()
if(err){
return publish("log","检查更新失败,因为无法连接到 api.github.com")
}
if(remoteTag==config.toml.version) return publish("log","已经是最新版");
var isUpdate = mainForm.msgAsk("最新版本为: "+remoteTag+" 是否更新")
if(!isUpdate) return ;
if(io.exist("/.git")){
loadcodex("\res\amod_install_git.aardio");
}else{
loadcodex("\res\amod_install.aardio")
}
}
mainForm.setTimeout(updata,2000)
mainForm.enableDpiScaling()
mainForm.show();
return win.loopMessage();