feat: impl dashboard & issue list

This commit is contained in:
2026-05-06 01:42:38 +08:00
parent bef3a0b9ed
commit 7de0039d38
36 changed files with 2381 additions and 107 deletions

View File

@@ -1,19 +1,52 @@
use crate::api::QueryContext;
use crate::query;
use serde::Deserialize;
use crate::{api, query};
#[derive(Debug, Deserialize)]
pub struct Repository {
pub id: u64,
pub name: String,
pub full_name: String,
pub private: bool,
pub html_url: String,
pub description: Option<String>,
pub default_branch: String,
pub owner: Owner,
}
#[derive(Debug, Deserialize)]
pub struct Owner {
pub login: String,
pub id: api::user::Id,
pub avatar_url: String,
pub html_url: String,
}
#[derive(Clone)]
pub struct List;
impl query::QueryFn for List {
type Data = ();
type Error = ();
type Context = QueryContext;
type Data = Vec<Repository>;
type Error = api::Error;
type Context = api::QueryContext;
fn key(&self) -> &'static str {
"repo.list"
fn key(&self) -> query::Key {
"repo/list".into()
}
async fn run(&self, _c: &Self::Context) -> Result<Self::Data, Self::Error> {
Ok(())
async fn run(&self, c: &Self::Context) -> Result<Self::Data, Self::Error> {
#[cfg(debug_assertions)]
if c.should_use_fixtures {
return super::mock::list_repos();
}
let params = [("sort", "updated"), ("per_page", "100")];
let res = c
.github_request(reqwest::Method::GET, "/user/repos")?
.query(&params)
.send()
.await?;
api::parse_response(res).await
}
}