简单网站css或js下载练习

tanzh 2023-8-15 853

import win.ui;
/*DSG{{*/
var winform = win.form(text="下载网站css或js";right=664;bottom=290;max=false)
winform.add(
buttonClose={cls="button";text="退出";left=348;top=204;right=498;bottom=262;color=14120960;font=LOGFONT(h=-14);note=" ";z=4};
buttonSave={cls="button";text="保存";left=162;top=204;right=312;bottom=262;color=14120960;font=LOGFONT(h=-14);note=" ";z=2};
editUrl={cls="edit";left=79;top=36;right=538;bottom=182;edge=1;multiline=1;style=1539;z=1};
static={cls="static";text="下载网址(自动换行)";left=79;top=12;right=368;bottom=33;transparent=1;z=3}
)
/*}}*/

import process;
import inet.http;
http = inet.http()

winform.editUrl.text = "http://cdn.staticfile.org/layui/2.8.12/layui.js";

winform.buttonSave.oncommand = function(id,event){
	path = "/"++string.match(winform.editUrl.text,".*\/(.*)")
	string.save(path,http.get(url));
	winform.msgbox("保存完成");
	process.exploreSelect(path)
}

winform.buttonClose.oncommand = function(id,event){
	win.quitMessage()
}

winform.show();
win.loopMessage();


最新回复 (4)
  • 光庆 2023-8-15
    0 2
    顶顶更健康
  • 小肥羊 2023-8-16
    0 3

    两个建议哈。

    1、下载单文件可以用,inet.httpFile

    2、process.exploreSelect 在win11中实测是存在问题的,稳定性不太对

    import win.ui;
    /*DSG{{*/
    var winform = win.form(text="下载网站css或js";right=664;bottom=290;max=false)
    winform.add(
    buttonClose={cls="button";text="退出";left=348;top=204;right=498;bottom=262;color=14120960;font=LOGFONT(h=-14);note=" ";z=4};
    buttonSave={cls="button";text="保存";left=162;top=204;right=312;bottom=262;color=14120960;font=LOGFONT(h=-14);note=" ";z=2};
    editUrl={cls="edit";left=79;top=36;right=538;bottom=182;edge=1;multiline=1;style=1539;z=1};
    static={cls="static";text="下载网址(自动换行)";left=79;top=12;right=368;bottom=33;transparent=1;z=3}
    )
    /*}}*/
    
    import process;
    import inet.httpFile;
    import console;
    
    winform.editUrl.text = "http://cdn.staticfile.org/layui/2.8.12/layui.js";
    
    winform.buttonSave.oncommand = function(id,event){
        path = "/"++string.match(winform.editUrl.text,".*\/(.*)")
        http = inet.httpFile(winform.editUrl.text,path);   
        res = http.download() 
        if(res && http.complete){
            http.close();
        	process.execute('/')    
        }
    	
    }
    
    winform.buttonClose.oncommand = function(id,event){
        win.quitMessage()
    }
    
    winform.show();
    win.loopMessage();


  • Viewer8122 2023-8-17
    0 4
    666,学习了。
  • tanzh 2023-8-17
    0 5
    感谢大佬指点
返回