V2RayGCon手册

Release Badge

用户交互控件

Alert, Choice, Input
 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
function Main()
    local choices = {
        "显示当前时间(Alert演示)",
        "简单计算(Input演示)",
        "你喜欢什么水果(Choices演示)",
    }
        
    local idx = std.Misc:Choice("请选择演示内容(点'取消'退出)", choices, true)
    
    if idx == 1 then
        std.Misc:Alert(os.date('%Y-%m-%d %H:%M:%S'))
    end
    
    if idx == 2 then
        local expr = std.Misc:Input("请输入简单算式, 例如: 1+2*3", 1)
        local f = load('return ' .. expr)
        std.Misc:Alert("结果是:" .. tostring(f()))
    end
    
    if idx == 3 then
        ChooseFruit()
    end
    
    if idx < 1 then
        return false
    end
    return true
end

function ChooseFruit()
    local fruit = {
        "香蕉",
        "橙子",
        "鸭梨",
    }
    
    local choices = std.Misc:Choices("你喜欢吃什么水果?", fruit)
    local r = ""
    foreach index in choices do
        r = r .. fruit[index] .. ","
    end
    if string.isempty(r) then
        std.Misc:Alert("没一个喜欢的")
    else
        std.Misc:Alert(string.sub(r, 0, #r - 1))
    end
end

repeat
    local again = Main()
until not again
ShowData输出控件
 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
local utils = require('3rd/neolua/libs/utils')

function Main()
    local servs = std.Server:GetAllServers()
    local v = ShowDatas(servs)
    print(v)
end

function ShowDatas(servs)
    local rows = {}
    foreach coreServ in servs do
        local wserv = coreServ:Wrap()
        local row = {
            wserv:GetIndex(),
            wserv:GetLongName(),
            wserv:GetSummary(),
            wserv:GetMark(),
            utils.ToLuaDate(wserv:GetLastModifiedUtcTicks()),
            wserv:GetStatus(),
        }
        table.insert(rows, row)
    end
    -- print(table.dump(rows))
    local columns = {"序号", "名称", "摘要", "标记", "修改日期", "测速"}
    return std.Misc:ShowData("服务器列表:", columns, rows, 3)
end

Main()
Last updated on 26 Feb 2020
Published on 26 Feb 2020
Edit on GitHub