← 返回

应用详情

📦

小程序商店

版本 v1 · 3.1 KB
ID: app_524_store
⬇ 下载 CIP 🔍 返回列表
📝 应用描述
浏览旧聊小程序商店,支持分页浏览、详情查看与下载链接 | Developed by STARDUST
📋 详细信息
应用ID app_524_store
名称 小程序商店
版本 v1
文件大小 3.1 KB
上传时间 2026-07-30 18:35:05
状态 ✅ 已启用
权限 network_external, storage
允许主机 app.524090.xyz
💡 界面预览 (main.lua)
📄 Lua 源码
local apps_data = {}
local current_page = 1
local total_pages = 1
local PER_PAGE = 10
local MAX_SLOTS = 20

local function showSection(section)
  app.set_visible("list_section", section == "list")
  app.set_visible("detail_section", section == "detail")
  app.set_visible("about_section", section == "about")
end

local function showPage()
  local total = #apps_data
  total_pages = math.max(1, math.ceil(total / PER_PAGE))
  if current_page > total_pages then current_page = total_pages end
  local start_idx = (current_page - 1) * PER_PAGE + 1
  local end_idx = math.min(start_idx + PER_PAGE - 1, total)
  for i = 1, MAX_SLOTS do
    app.set_visible("card_" .. i, i >= start_idx and i <= end_idx)
  end
  app.set_text("status", "第 " .. start_idx .. "-" .. end_idx .. " 个,共 " .. total .. " 个")
  app.set_text("page_info", "第 " .. current_page .. " / " .. total_pages .. " 页")
  app.set_enabled("btn_prev", current_page > 1)
  app.set_enabled("btn_next", current_page < total_pages)
end

local function filterApps(keyword)
  keyword = (keyword or ""):lower()
  local filtered = {}
  for _, a in ipairs(apps_data) do
    local name = (a.name or ""):lower()
    local desc = (a.description or ""):lower()
    if keyword == "" or name:find(keyword, 1, true) or desc:find(keyword, 1, true) then
      table.insert(filtered, a)
    end
  end
  apps_data = filtered
  current_page = 1
  showPage()
end

local function loadApps()
  app.set_visible("loading", true)
  app.set_visible("error", false)
  app.set_visible("list_section", false)
  app.set_text("loading_text", "正在获取小程序列表...")

  app.http_get("https://app.524090.xyz/api.php?action=list", function(body, err)
    if err then app.set_text("error_text", "网络请求失败\n" .. (err or "无法连接到服务器")); app.set_visible("loading", false); app.set_visible("error", true); return end
    if not body then app.set_text("error_text", "服务器返回空数据"); app.set_visible("loading", false); app.set_visible("error", true); return end
    local data = app.json_decode(body)
    if not data then app.set_text("error_text", "数据解析失败,请检查网络后重试"); app.set_visible("loading", false); app.set_visible("error", true); return end
    if not data.success then app.set_text("error_text", "服务器返回错误:" .. (data.error or "未知错误")); app.set_visible("loading", false); app.set_visible("error", true); return end
    if not data.apps or #data.apps == 0 then app.set_text("error_text", "暂未发现可用小程序"); app.set_visible("loading", false); app.set_visible("error", true); return end

    apps_data = data.apps
    local count = #apps_data
    for i = 1, math.min(count, MAX_SLOTS) do
      local a = apps_data[i]
      app.set_text("name_" .. i, "📦 " .. a.name)
      app.set_text("desc_" .. i, a.description or "暂无描述信息")
      local dateStr = (a.uploaded_at or ""):gsub("^(%d+-%d+-%d+).*", "%1")
      app.set_text("meta_" .. i, "版本V" .. tostring(a.version) .. "  ·  " .. dateStr)
      app.set_visible("card_" .. i, false)
    end
    for i = count + 1, MAX_SLOTS do
      app.set_visible("card_" .. i, false)
    end
    current_page = 1
    showPage()
    app.set_visible("loading", false)
    app.set_visible("list_section", true)
    app.toast("已加载 " .. count .. " 个小程序")
  end)
end

local function doSearch()
  local keyword = app.get_text("search_input") or ""
  if keyword == "" then loadApps(); return end
  filterApps(keyword)
end

local function showDetail(a)
  app.set_text("detail_name", "📦 " .. a.name)
  app.set_text("detail_desc", a.description or "暂无描述信息")
  local dateStr = (a.uploaded_at or ""):gsub("^(%d+-%d+-%d+).*", "%1")
  app.set_text("detail_ver", "版本号:V" .. tostring(a.version))
  app.set_text("detail_date", "更新日期:" .. dateStr)
  app.set_text("detail_appid", "应用标识:" .. a.id)
  local url = "https://app.524090.xyz/api.php?action=download&id=" .. a.id
  app.set_text("detail_url_label", "长按下方输入框复制下载链接")
  app.set_hint("detail_url", "")
  app.set_text("detail_url", url)
  showSection("detail")
end

local function prevPage()
  if current_page > 1 then current_page = current_page - 1; showPage() end
end

local function nextPage()
  if current_page < total_pages then current_page = current_page + 1; showPage() end
end

local cards = {}
for i = 1, MAX_SLOTS do
  local idx = i
  cards[i] = ui.list({
    id = "card_" .. i,
    visible = false,
    margin = 5,
    children = {
      ui.text({ id = "name_" .. i, text = "", size = 16, color = "#A4C639", margin = 5 }),
      ui.text({ id = "desc_" .. i, text = "", size = 12, color = "#999999", margin = 4 }),
      ui.list({
        margin = 4,
        children = {
          ui.text({ id = "meta_" .. i, text = "", size = 11, color = "#A4C639" }),
          ui.button({
            id = "btn_detail_" .. i,
            text = "查看详情",
            color = "#A4C639",
            margin = 2,
            on_click = function()
              local a = apps_data[idx]
              if a then showDetail(a) else app.toast("数据不可用") end
            end
          })
        }
      })
    }
  })
end

app.delay(300, loadApps)

return ui.page({
  title = "",
  children = {

    -- ==================== 列表页 ====================
    ui.list({ id = "list_section", visible = true, margin = 4, children = {

      ui.text({ text = "📱 小程序商店", size = 20, color = "#A4C639", center = true, margin = 8 }),
      ui.button({ text = "ℹ 关于", color = "#888888", margin = 4, on_click = function() showSection("about") end }),

      ui.spacer({ height = 4 }),

      ui.input({ id = "search_input", hint = "搜索小程序名称或描述...", margin = 6 }),
      ui.button({ text = "🔍 搜索", margin = 4, on_click = doSearch }),
      ui.button({ text = "🔄 刷新", color = "#A4C639", margin = 4, on_click = loadApps }),

      ui.text({ id = "status", text = "", size = 12, color = "#888888", center = true, margin = 4 }),

      ui.list({ id = "loading", visible = false, margin = 20, children = {
        ui.text({ id = "loading_text", text = "", size = 15, color = "#A4C639", center = true, margin = 6 })
      }}),

      ui.list({ id = "error", visible = false, margin = 10, children = {
        ui.text({ id = "error_text", text = "", size = 14, color = "#FF6B6B", center = true, margin = 8 }),
        ui.button({ text = "🔄 重试", margin = 6, on_click = loadApps })
      }}),

      ui.list({ margin = 2, children = cards }),

      ui.spacer({ height = 4 }),

      ui.list({ margin = 4, children = {
        ui.button({ id = "btn_prev", text = "◀ 上一页", margin = 2, on_click = prevPage }),
        ui.text({ id = "page_info", text = "第 1 / 1 页", size = 12, color = "#888888", center = true, margin = 4 }),
        ui.button({ id = "btn_next", text = "下一页 ▶", margin = 2, on_click = nextPage })
      }}),

      ui.text({ text = "Developed by STARDUST", size = 9, color = "#555555", center = true, margin = 4 })
    }}),

    -- ==================== 详情页 ====================
    ui.list({ id = "detail_section", visible = false, margin = 8, children = {

      ui.button({ text = "〈 返回列表", color = "#A4C639", margin = 4, on_click = function() showSection("list") end }),

      ui.spacer({ height = 10 }),

      ui.text({ id = "detail_name", text = "", size = 22, color = "#A4C639", margin = 6 }),
      ui.spacer({ height = 4 }),

      ui.text({ id = "detail_desc", text = "", size = 14, color = "#999999", margin = 6 }),
      ui.spacer({ height = 10 }),

      ui.text({ id = "detail_appid", text = "", size = 12, color = "#999999", margin = 4 }),
      ui.text({ id = "detail_ver", text = "", size = 12, color = "#999999", margin = 4 }),
      ui.text({ id = "detail_date", text = "", size = 12, color = "#999999", margin = 4 }),

      ui.spacer({ height = 12 }),

      ui.text({ text = "── 下载链接 ──", size = 12, color = "#A4C639", center = true, margin = 4 }),
      ui.text({ id = "detail_url_label", text = "", size = 11, color = "#FFB800", center = true, margin = 2 }),
      ui.spacer({ height = 4 }),
      ui.input({ id = "detail_url", text = "", hint = "点击加载下载链接", margin = 4, single_line = false, max_length = 200 }),

      ui.spacer({ height = 10 }),

      ui.button({ text = "〈 返回列表", margin = 4, on_click = function() showSection("list") end })
    }}),

    -- ==================== 关于页 ====================
    ui.list({ id = "about_section", visible = false, margin = 8, children = {

      ui.button({ text = "〈 返回商店", color = "#A4C639", margin = 4, on_click = function() showSection("list") end }),

      ui.spacer({ height = 16 }),

      ui.text({ text = "📱 小程序商店", size = 22, color = "#A4C639", center = true, margin = 6 }),
      ui.text({ text = " 浏览旧聊小程序商店", size = 13, color = "#999999", center = true, margin = 4 }),
      ui.text({ text = "支持搜索、分页、详情查看", size = 12, color = "#888888", center = true, margin = 2 }),

      ui.spacer({ height = 16 }),

      ui.text({ text = "── 开发者信息 ──", size = 12, color = "#A4C639", center = true, margin = 6 }),

      ui.spacer({ height = 8 }),

      ui.text({ text = "Developed by", size = 12, color = "#888888", center = true, margin = 2 }),
      ui.text({ text = "STARDUST", size = 20, color = "#A4C639", center = true, margin = 4 }),

      ui.spacer({ height = 12 }),

      ui.text({ text = "版本:V1", size = 12, color = "#888888", center = true, margin = 2 }),
      ui.text({ text = "数据来源:app.524090.xyz", size = 12, color = "#888888", center = true, margin = 2 }),

      ui.spacer({ height = 16 }),

      ui.text({ text = "── 功能特性 ──", size = 12, color = "#A4C639", center = true, margin = 6 }),

      ui.spacer({ height = 6 }),

      ui.text({ text = "✦ 每页 10 个分页浏览", size = 12, color = "#999999", center = true, margin = 2 }),
      ui.text({ text = "✦ 搜索过滤小程序", size = 12, color = "#999999", center = true, margin = 2 }),
      ui.text({ text = "✦ 查看应用详情", size = 12, color = "#999999", center = true, margin = 2 }),
      ui.text({ text = "✦ 一键获取下载链接", size = 12, color = "#999999", center = true, margin = 2 }),

      ui.spacer({ height = 16 }),

      ui.text({ text = "✦ STARDUST ✦", size = 10, color = "#555555", center = true, margin = 4 }),

      ui.spacer({ height = 10 }),

      ui.button({ text = "〈 返回商店", margin = 4, on_click = function() showSection("list") end })
    }})
  }
})
⬇ 下载 CIP 文件 🔍 返回列表