From b4df527126cd293b8ae587f06a9750b4cd94842a Mon Sep 17 00:00:00 2001 From: xuyisheng Date: Fri, 7 Aug 2020 20:06:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0juejin=E7=9A=84API=E4=B8=BAgi?= =?UTF-8?q?thub=20api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .flutter-plugins-dependencies | 2 +- lib/pages/feed/feed_entity.dart | 746 ++++++++++++++++------------- lib/pages/feed/feeddetailpage.dart | 6 +- lib/pages/feed/feedmainpage.dart | 18 +- lib/pages/feed/restclient.dart | 12 +- lib/pages/feed/restclient.g.dart | 29 +- 6 files changed, 451 insertions(+), 362 deletions(-) diff --git a/.flutter-plugins-dependencies b/.flutter-plugins-dependencies index 7f84c3a..8824314 100644 --- a/.flutter-plugins-dependencies +++ b/.flutter-plugins-dependencies @@ -1 +1 @@ -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"path_provider","path":"/Users/ityw/Downloads/flutter/flutter/.pub-cache/hosted/pub.flutter-io.cn/path_provider-1.6.11/","dependencies":[]},{"name":"share","path":"/Users/ityw/Downloads/flutter/flutter/.pub-cache/hosted/pub.flutter-io.cn/share-0.6.4+3/","dependencies":[]},{"name":"shared_preferences","path":"/Users/ityw/Downloads/flutter/flutter/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences-0.5.8/","dependencies":[]},{"name":"sqflite","path":"/Users/ityw/Downloads/flutter/flutter/.pub-cache/hosted/pub.flutter-io.cn/sqflite-1.3.1/","dependencies":[]},{"name":"url_launcher","path":"/Users/ityw/Downloads/flutter/flutter/.pub-cache/hosted/pub.flutter-io.cn/url_launcher-5.5.0/","dependencies":[]},{"name":"webview_flutter","path":"/Users/ityw/Downloads/flutter/flutter/.pub-cache/hosted/pub.flutter-io.cn/webview_flutter-0.3.22+1/","dependencies":[]}],"android":[{"name":"path_provider","path":"/Users/ityw/Downloads/flutter/flutter/.pub-cache/hosted/pub.flutter-io.cn/path_provider-1.6.11/","dependencies":[]},{"name":"share","path":"/Users/ityw/Downloads/flutter/flutter/.pub-cache/hosted/pub.flutter-io.cn/share-0.6.4+3/","dependencies":[]},{"name":"shared_preferences","path":"/Users/ityw/Downloads/flutter/flutter/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences-0.5.8/","dependencies":[]},{"name":"sqflite","path":"/Users/ityw/Downloads/flutter/flutter/.pub-cache/hosted/pub.flutter-io.cn/sqflite-1.3.1/","dependencies":[]},{"name":"url_launcher","path":"/Users/ityw/Downloads/flutter/flutter/.pub-cache/hosted/pub.flutter-io.cn/url_launcher-5.5.0/","dependencies":[]},{"name":"webview_flutter","path":"/Users/ityw/Downloads/flutter/flutter/.pub-cache/hosted/pub.flutter-io.cn/webview_flutter-0.3.22+1/","dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"/Users/ityw/Downloads/flutter/flutter/.pub-cache/hosted/pub.flutter-io.cn/path_provider_macos-0.0.4+3/","dependencies":[]},{"name":"shared_preferences_macos","path":"/Users/ityw/Downloads/flutter/flutter/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences_macos-0.0.1+10/","dependencies":[]},{"name":"sqflite","path":"/Users/ityw/Downloads/flutter/flutter/.pub-cache/hosted/pub.flutter-io.cn/sqflite-1.3.1/","dependencies":[]},{"name":"url_launcher_macos","path":"/Users/ityw/Downloads/flutter/flutter/.pub-cache/hosted/pub.flutter-io.cn/url_launcher_macos-0.0.1+7/","dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"/Users/ityw/Downloads/flutter/flutter/.pub-cache/hosted/pub.flutter-io.cn/path_provider_linux-0.0.1+2/","dependencies":[]},{"name":"shared_preferences_linux","path":"/Users/ityw/Downloads/flutter/flutter/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences_linux-0.0.2+1/","dependencies":["path_provider_linux"]},{"name":"url_launcher_linux","path":"/Users/ityw/Downloads/flutter/flutter/.pub-cache/hosted/pub.flutter-io.cn/url_launcher_linux-0.0.1+1/","dependencies":[]}],"windows":[],"web":[{"name":"shared_preferences_web","path":"/Users/ityw/Downloads/flutter/flutter/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences_web-0.1.2+7/","dependencies":[]},{"name":"url_launcher_web","path":"/Users/ityw/Downloads/flutter/flutter/.pub-cache/hosted/pub.flutter-io.cn/url_launcher_web-0.1.2/","dependencies":[]}]},"dependencyGraph":[{"name":"path_provider","dependencies":["path_provider_macos","path_provider_linux"]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"share","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_linux","shared_preferences_macos","shared_preferences_web"]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]},{"name":"sqflite","dependencies":[]},{"name":"url_launcher","dependencies":["url_launcher_web","url_launcher_linux","url_launcher_macos"]},{"name":"url_launcher_linux","dependencies":[]},{"name":"url_launcher_macos","dependencies":[]},{"name":"url_launcher_web","dependencies":[]},{"name":"webview_flutter","dependencies":[]}],"date_created":"2020-08-06 18:20:19.879346","version":"1.20.0"} \ No newline at end of file +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"path_provider","path":"/Users/ityw/Downloads/flutter/flutter/.pub-cache/hosted/pub.flutter-io.cn/path_provider-1.6.11/","dependencies":[]},{"name":"share","path":"/Users/ityw/Downloads/flutter/flutter/.pub-cache/hosted/pub.flutter-io.cn/share-0.6.4+3/","dependencies":[]},{"name":"shared_preferences","path":"/Users/ityw/Downloads/flutter/flutter/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences-0.5.8/","dependencies":[]},{"name":"sqflite","path":"/Users/ityw/Downloads/flutter/flutter/.pub-cache/hosted/pub.flutter-io.cn/sqflite-1.3.1/","dependencies":[]},{"name":"url_launcher","path":"/Users/ityw/Downloads/flutter/flutter/.pub-cache/hosted/pub.flutter-io.cn/url_launcher-5.5.0/","dependencies":[]},{"name":"webview_flutter","path":"/Users/ityw/Downloads/flutter/flutter/.pub-cache/hosted/pub.flutter-io.cn/webview_flutter-0.3.22+1/","dependencies":[]}],"android":[{"name":"path_provider","path":"/Users/ityw/Downloads/flutter/flutter/.pub-cache/hosted/pub.flutter-io.cn/path_provider-1.6.11/","dependencies":[]},{"name":"share","path":"/Users/ityw/Downloads/flutter/flutter/.pub-cache/hosted/pub.flutter-io.cn/share-0.6.4+3/","dependencies":[]},{"name":"shared_preferences","path":"/Users/ityw/Downloads/flutter/flutter/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences-0.5.8/","dependencies":[]},{"name":"sqflite","path":"/Users/ityw/Downloads/flutter/flutter/.pub-cache/hosted/pub.flutter-io.cn/sqflite-1.3.1/","dependencies":[]},{"name":"url_launcher","path":"/Users/ityw/Downloads/flutter/flutter/.pub-cache/hosted/pub.flutter-io.cn/url_launcher-5.5.0/","dependencies":[]},{"name":"webview_flutter","path":"/Users/ityw/Downloads/flutter/flutter/.pub-cache/hosted/pub.flutter-io.cn/webview_flutter-0.3.22+1/","dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"/Users/ityw/Downloads/flutter/flutter/.pub-cache/hosted/pub.flutter-io.cn/path_provider_macos-0.0.4+3/","dependencies":[]},{"name":"shared_preferences_macos","path":"/Users/ityw/Downloads/flutter/flutter/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences_macos-0.0.1+10/","dependencies":[]},{"name":"sqflite","path":"/Users/ityw/Downloads/flutter/flutter/.pub-cache/hosted/pub.flutter-io.cn/sqflite-1.3.1/","dependencies":[]},{"name":"url_launcher_macos","path":"/Users/ityw/Downloads/flutter/flutter/.pub-cache/hosted/pub.flutter-io.cn/url_launcher_macos-0.0.1+7/","dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"/Users/ityw/Downloads/flutter/flutter/.pub-cache/hosted/pub.flutter-io.cn/path_provider_linux-0.0.1+2/","dependencies":[]},{"name":"shared_preferences_linux","path":"/Users/ityw/Downloads/flutter/flutter/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences_linux-0.0.2+1/","dependencies":["path_provider_linux"]},{"name":"url_launcher_linux","path":"/Users/ityw/Downloads/flutter/flutter/.pub-cache/hosted/pub.flutter-io.cn/url_launcher_linux-0.0.1+1/","dependencies":[]}],"windows":[],"web":[{"name":"shared_preferences_web","path":"/Users/ityw/Downloads/flutter/flutter/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences_web-0.1.2+7/","dependencies":[]},{"name":"url_launcher_web","path":"/Users/ityw/Downloads/flutter/flutter/.pub-cache/hosted/pub.flutter-io.cn/url_launcher_web-0.1.2/","dependencies":[]}]},"dependencyGraph":[{"name":"path_provider","dependencies":["path_provider_macos","path_provider_linux"]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"share","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_linux","shared_preferences_macos","shared_preferences_web"]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]},{"name":"sqflite","dependencies":[]},{"name":"url_launcher","dependencies":["url_launcher_web","url_launcher_linux","url_launcher_macos"]},{"name":"url_launcher_linux","dependencies":[]},{"name":"url_launcher_macos","dependencies":[]},{"name":"url_launcher_web","dependencies":[]},{"name":"webview_flutter","dependencies":[]}],"date_created":"2020-08-07 20:04:51.897760","version":"1.20.0"} \ No newline at end of file diff --git a/lib/pages/feed/feed_entity.dart b/lib/pages/feed/feed_entity.dart index b18eaf9..331d885 100644 --- a/lib/pages/feed/feed_entity.dart +++ b/lib/pages/feed/feed_entity.dart @@ -10,233 +10,39 @@ T asT(dynamic value) { class FeedEntity { FeedEntity({ - this.s, - this.m, - this.d, + this.totalCount, + this.incompleteResults, + this.items, }); - factory FeedEntity.fromJson(Map jsonRes) => jsonRes == null - ? null - : FeedEntity( - s: asT(jsonRes['s']), - m: asT(jsonRes['m']), - d: D.fromJson(asT>(jsonRes['d'])), - ); - - int s; - String m; - D d; - - Map toJson() => { - 's': s, - 'm': m, - 'd': d, - }; - - @override - String toString() { - return json.encode(this); - } -} - -class D { - D({ - this.total, - this.entrylist, - }); - - factory D.fromJson(Map jsonRes) { - if (jsonRes == null) { - return null; - } - - final List entrylist = jsonRes['entrylist'] is List ? [] : null; - if (entrylist != null) { - for (final dynamic item in jsonRes['entrylist']) { - if (item != null) { - entrylist.add(EntryDetail.fromJson(asT>(item))); - } - } - } - return D( - total: asT(jsonRes['total']), - entrylist: entrylist, - ); - } - - int total; - List entrylist; - - Map toJson() => { - 'total': total, - 'entrylist': entrylist, - }; - - @override - String toString() { - return json.encode(this); - } -} - -class EntryDetail { - EntryDetail({ - this.collectionCount, - this.userRankIndex, - this.buildTime, - this.commentsCount, - this.gfw, - this.objectId, - this.checkStatus, - this.isEvent, - this.entryView, - this.subscribersCount, - this.ngxCachedTime, - this.verifyStatus, - this.tags, - this.updatedAt, - this.rankIndex, - this.hot, - this.autoPass, - this.originalUrl, - this.verifyCreatedAt, - this.createdAt, - this.user, - this.author, - this.screenshot, - this.original, - this.hotIndex, - this.content, - this.title, - this.lastCommentTime, - this.type, - this.english, - this.category, - this.viewsCount, - this.summaryInfo, - this.isCollected, - }); - - factory EntryDetail.fromJson(Map jsonRes) { + factory FeedEntity.fromJson(Map jsonRes) { if (jsonRes == null) { return null; } - final List tags = jsonRes['tags'] is List ? [] : null; - if (tags != null) { - for (final dynamic item in jsonRes['tags']) { + final List items = jsonRes['items'] is List ? [] : null; + if (items != null) { + for (final dynamic item in jsonRes['items']) { if (item != null) { - tags.add(Tags.fromJson(asT>(item))); + items.add(Items.fromJson(asT>(item))); } } } - return EntryDetail( - collectionCount: asT(jsonRes['collectionCount']), - userRankIndex: asT(jsonRes['userRankIndex']), - buildTime: asT(jsonRes['buildTime']), - commentsCount: asT(jsonRes['commentsCount']), - gfw: asT(jsonRes['gfw']), - objectId: asT(jsonRes['objectId']), - checkStatus: asT(jsonRes['checkStatus']), - isEvent: asT(jsonRes['isEvent']), - entryView: asT(jsonRes['entryView']), - subscribersCount: asT(jsonRes['subscribersCount']), - ngxCachedTime: asT(jsonRes['ngxCachedTime']), - verifyStatus: asT(jsonRes['verifyStatus']), - tags: tags, - updatedAt: asT(jsonRes['updatedAt']), - rankIndex: asT(jsonRes['rankIndex']), - hot: asT(jsonRes['hot']), - autoPass: asT(jsonRes['autoPass']), - originalUrl: asT(jsonRes['originalUrl']), - verifyCreatedAt: asT(jsonRes['verifyCreatedAt']), - createdAt: asT(jsonRes['createdAt']), - user: User.fromJson(asT>(jsonRes['user'])), - author: asT(jsonRes['author']), - screenshot: asT(jsonRes['screenshot']), - original: asT(jsonRes['original']), - hotIndex: asT(jsonRes['hotIndex']), - content: asT(jsonRes['content']), - title: asT(jsonRes['title']), - lastCommentTime: asT(jsonRes['lastCommentTime']), - type: asT(jsonRes['type']), - english: asT(jsonRes['english']), - category: Category.fromJson(asT>(jsonRes['category'])), - viewsCount: asT(jsonRes['viewsCount']), - summaryInfo: asT(jsonRes['summaryInfo']), - isCollected: asT(jsonRes['isCollected']), + return FeedEntity( + totalCount: asT(jsonRes['total_count']), + incompleteResults: asT(jsonRes['incomplete_results']), + items: items, ); } - int collectionCount; - double userRankIndex; - double buildTime; - int commentsCount; - bool gfw; - String objectId; - bool checkStatus; - bool isEvent; - String entryView; - int subscribersCount; - int ngxCachedTime; - bool verifyStatus; - List tags; - String updatedAt; - double rankIndex; - bool hot; - bool autoPass; - String originalUrl; - String verifyCreatedAt; - String createdAt; - User user; - String author; - String screenshot; - bool original; - double hotIndex; - String content; - String title; - String lastCommentTime; - String type; - bool english; - Category category; - int viewsCount; - String summaryInfo; - bool isCollected; + int totalCount; + bool incompleteResults; + List items; Map toJson() => { - 'collectionCount': collectionCount, - 'userRankIndex': userRankIndex, - 'buildTime': buildTime, - 'commentsCount': commentsCount, - 'gfw': gfw, - 'objectId': objectId, - 'checkStatus': checkStatus, - 'isEvent': isEvent, - 'entryView': entryView, - 'subscribersCount': subscribersCount, - 'ngxCachedTime': ngxCachedTime, - 'verifyStatus': verifyStatus, - 'tags': tags, - 'updatedAt': updatedAt, - 'rankIndex': rankIndex, - 'hot': hot, - 'autoPass': autoPass, - 'originalUrl': originalUrl, - 'verifyCreatedAt': verifyCreatedAt, - 'createdAt': createdAt, - 'user': user, - 'author': author, - 'screenshot': screenshot, - 'original': original, - 'hotIndex': hotIndex, - 'content': content, - 'title': title, - 'lastCommentTime': lastCommentTime, - 'type': type, - 'english': english, - 'category': category, - 'viewsCount': viewsCount, - 'summaryInfo': summaryInfo, - 'isCollected': isCollected, + 'total_count': totalCount, + 'incomplete_results': incompleteResults, + 'items': items, }; @override @@ -245,33 +51,313 @@ class EntryDetail { } } -class Tags { - Tags({ - this.ngxCachedTime, - this.ngxCached, - this.title, +class Items { + Items({ this.id, + this.nodeId, + this.name, + this.fullName, + this.private, + this.owner, + this.htmlUrl, + this.description, + this.fork, + this.url, + this.forksUrl, + this.keysUrl, + this.collaboratorsUrl, + this.teamsUrl, + this.hooksUrl, + this.issueEventsUrl, + this.eventsUrl, + this.assigneesUrl, + this.branchesUrl, + this.tagsUrl, + this.blobsUrl, + this.gitTagsUrl, + this.gitRefsUrl, + this.treesUrl, + this.statusesUrl, + this.languagesUrl, + this.stargazersUrl, + this.contributorsUrl, + this.subscribersUrl, + this.subscriptionUrl, + this.commitsUrl, + this.gitCommitsUrl, + this.commentsUrl, + this.issueCommentUrl, + this.contentsUrl, + this.compareUrl, + this.mergesUrl, + this.archiveUrl, + this.downloadsUrl, + this.issuesUrl, + this.pullsUrl, + this.milestonesUrl, + this.notificationsUrl, + this.labelsUrl, + this.releasesUrl, + this.deploymentsUrl, + this.createdAt, + this.updatedAt, + this.pushedAt, + this.gitUrl, + this.sshUrl, + this.cloneUrl, + this.svnUrl, + this.homepage, + this.size, + this.stargazersCount, + this.watchersCount, + this.language, + this.hasIssues, + this.hasProjects, + this.hasDownloads, + this.hasWiki, + this.hasPages, + this.forksCount, + this.mirrorUrl, + this.archived, + this.disabled, + this.openIssuesCount, + this.license, + this.forks, + this.openIssues, + this.watchers, + this.defaultBranch, + this.score, }); - factory Tags.fromJson(Map jsonRes) => jsonRes == null + factory Items.fromJson(Map jsonRes) => jsonRes == null ? null - : Tags( - ngxCachedTime: asT(jsonRes['ngxCachedTime']), - ngxCached: asT(jsonRes['ngxCached']), - title: asT(jsonRes['title']), - id: asT(jsonRes['id']), + : Items( + id: asT(jsonRes['id']), + nodeId: asT(jsonRes['node_id']), + name: asT(jsonRes['name']), + fullName: asT(jsonRes['full_name']), + private: asT(jsonRes['private']), + owner: Owner.fromJson(asT>(jsonRes['owner'])), + htmlUrl: asT(jsonRes['html_url']), + description: asT(jsonRes['description']), + fork: asT(jsonRes['fork']), + url: asT(jsonRes['url']), + forksUrl: asT(jsonRes['forks_url']), + keysUrl: asT(jsonRes['keys_url']), + collaboratorsUrl: asT(jsonRes['collaborators_url']), + teamsUrl: asT(jsonRes['teams_url']), + hooksUrl: asT(jsonRes['hooks_url']), + issueEventsUrl: asT(jsonRes['issue_events_url']), + eventsUrl: asT(jsonRes['events_url']), + assigneesUrl: asT(jsonRes['assignees_url']), + branchesUrl: asT(jsonRes['branches_url']), + tagsUrl: asT(jsonRes['tags_url']), + blobsUrl: asT(jsonRes['blobs_url']), + gitTagsUrl: asT(jsonRes['git_tags_url']), + gitRefsUrl: asT(jsonRes['git_refs_url']), + treesUrl: asT(jsonRes['trees_url']), + statusesUrl: asT(jsonRes['statuses_url']), + languagesUrl: asT(jsonRes['languages_url']), + stargazersUrl: asT(jsonRes['stargazers_url']), + contributorsUrl: asT(jsonRes['contributors_url']), + subscribersUrl: asT(jsonRes['subscribers_url']), + subscriptionUrl: asT(jsonRes['subscription_url']), + commitsUrl: asT(jsonRes['commits_url']), + gitCommitsUrl: asT(jsonRes['git_commits_url']), + commentsUrl: asT(jsonRes['comments_url']), + issueCommentUrl: asT(jsonRes['issue_comment_url']), + contentsUrl: asT(jsonRes['contents_url']), + compareUrl: asT(jsonRes['compare_url']), + mergesUrl: asT(jsonRes['merges_url']), + archiveUrl: asT(jsonRes['archive_url']), + downloadsUrl: asT(jsonRes['downloads_url']), + issuesUrl: asT(jsonRes['issues_url']), + pullsUrl: asT(jsonRes['pulls_url']), + milestonesUrl: asT(jsonRes['milestones_url']), + notificationsUrl: asT(jsonRes['notifications_url']), + labelsUrl: asT(jsonRes['labels_url']), + releasesUrl: asT(jsonRes['releases_url']), + deploymentsUrl: asT(jsonRes['deployments_url']), + createdAt: asT(jsonRes['created_at']), + updatedAt: asT(jsonRes['updated_at']), + pushedAt: asT(jsonRes['pushed_at']), + gitUrl: asT(jsonRes['git_url']), + sshUrl: asT(jsonRes['ssh_url']), + cloneUrl: asT(jsonRes['clone_url']), + svnUrl: asT(jsonRes['svn_url']), + homepage: asT(jsonRes['homepage']), + size: asT(jsonRes['size']), + stargazersCount: asT(jsonRes['stargazers_count']), + watchersCount: asT(jsonRes['watchers_count']), + language: asT(jsonRes['language']), + hasIssues: asT(jsonRes['has_issues']), + hasProjects: asT(jsonRes['has_projects']), + hasDownloads: asT(jsonRes['has_downloads']), + hasWiki: asT(jsonRes['has_wiki']), + hasPages: asT(jsonRes['has_pages']), + forksCount: asT(jsonRes['forks_count']), + mirrorUrl: asT(jsonRes['mirror_url']), + archived: asT(jsonRes['archived']), + disabled: asT(jsonRes['disabled']), + openIssuesCount: asT(jsonRes['open_issues_count']), + license: License.fromJson(asT>(jsonRes['license'])), + forks: asT(jsonRes['forks']), + openIssues: asT(jsonRes['open_issues']), + watchers: asT(jsonRes['watchers']), + defaultBranch: asT(jsonRes['default_branch']), + score: asT(jsonRes['score']), ); - int ngxCachedTime; - bool ngxCached; - String title; - String id; + int id; + String nodeId; + String name; + String fullName; + bool private; + Owner owner; + String htmlUrl; + String description; + bool fork; + String url; + String forksUrl; + String keysUrl; + String collaboratorsUrl; + String teamsUrl; + String hooksUrl; + String issueEventsUrl; + String eventsUrl; + String assigneesUrl; + String branchesUrl; + String tagsUrl; + String blobsUrl; + String gitTagsUrl; + String gitRefsUrl; + String treesUrl; + String statusesUrl; + String languagesUrl; + String stargazersUrl; + String contributorsUrl; + String subscribersUrl; + String subscriptionUrl; + String commitsUrl; + String gitCommitsUrl; + String commentsUrl; + String issueCommentUrl; + String contentsUrl; + String compareUrl; + String mergesUrl; + String archiveUrl; + String downloadsUrl; + String issuesUrl; + String pullsUrl; + String milestonesUrl; + String notificationsUrl; + String labelsUrl; + String releasesUrl; + String deploymentsUrl; + String createdAt; + String updatedAt; + String pushedAt; + String gitUrl; + String sshUrl; + String cloneUrl; + String svnUrl; + Object homepage; + int size; + int stargazersCount; + int watchersCount; + String language; + bool hasIssues; + bool hasProjects; + bool hasDownloads; + bool hasWiki; + bool hasPages; + int forksCount; + Object mirrorUrl; + bool archived; + bool disabled; + int openIssuesCount; + License license; + int forks; + int openIssues; + int watchers; + String defaultBranch; + int score; Map toJson() => { - 'ngxCachedTime': ngxCachedTime, - 'ngxCached': ngxCached, - 'title': title, 'id': id, + 'node_id': nodeId, + 'name': name, + 'full_name': fullName, + 'private': private, + 'owner': owner, + 'html_url': htmlUrl, + 'description': description, + 'fork': fork, + 'url': url, + 'forks_url': forksUrl, + 'keys_url': keysUrl, + 'collaborators_url': collaboratorsUrl, + 'teams_url': teamsUrl, + 'hooks_url': hooksUrl, + 'issue_events_url': issueEventsUrl, + 'events_url': eventsUrl, + 'assignees_url': assigneesUrl, + 'branches_url': branchesUrl, + 'tags_url': tagsUrl, + 'blobs_url': blobsUrl, + 'git_tags_url': gitTagsUrl, + 'git_refs_url': gitRefsUrl, + 'trees_url': treesUrl, + 'statuses_url': statusesUrl, + 'languages_url': languagesUrl, + 'stargazers_url': stargazersUrl, + 'contributors_url': contributorsUrl, + 'subscribers_url': subscribersUrl, + 'subscription_url': subscriptionUrl, + 'commits_url': commitsUrl, + 'git_commits_url': gitCommitsUrl, + 'comments_url': commentsUrl, + 'issue_comment_url': issueCommentUrl, + 'contents_url': contentsUrl, + 'compare_url': compareUrl, + 'merges_url': mergesUrl, + 'archive_url': archiveUrl, + 'downloads_url': downloadsUrl, + 'issues_url': issuesUrl, + 'pulls_url': pullsUrl, + 'milestones_url': milestonesUrl, + 'notifications_url': notificationsUrl, + 'labels_url': labelsUrl, + 'releases_url': releasesUrl, + 'deployments_url': deploymentsUrl, + 'created_at': createdAt, + 'updated_at': updatedAt, + 'pushed_at': pushedAt, + 'git_url': gitUrl, + 'ssh_url': sshUrl, + 'clone_url': cloneUrl, + 'svn_url': svnUrl, + 'homepage': homepage, + 'size': size, + 'stargazers_count': stargazersCount, + 'watchers_count': watchersCount, + 'language': language, + 'has_issues': hasIssues, + 'has_projects': hasProjects, + 'has_downloads': hasDownloads, + 'has_wiki': hasWiki, + 'has_pages': hasPages, + 'forks_count': forksCount, + 'mirror_url': mirrorUrl, + 'archived': archived, + 'disabled': disabled, + 'open_issues_count': openIssuesCount, + 'license': license, + 'forks': forks, + 'open_issues': openIssues, + 'watchers': watchers, + 'default_branch': defaultBranch, + 'score': score, }; @override @@ -280,97 +366,89 @@ class Tags { } } -class User { - User({ - this.community, - this.collectedEntriesCount, - this.company, - this.followersCount, - this.followeesCount, - this.role, - this.postedPostsCount, - this.level, - this.isAuthor, - this.postedEntriesCount, - this.totalCommentsCount, - this.ngxCachedTime, - this.ngxCached, - this.viewedEntriesCount, - this.jobTitle, - this.subscribedTagsCount, - this.totalCollectionsCount, - this.username, - this.avatarLarge, - this.objectId, +class Owner { + Owner({ + this.login, + this.id, + this.nodeId, + this.avatarUrl, + this.gravatarId, + this.url, + this.htmlUrl, + this.followersUrl, + this.followingUrl, + this.gistsUrl, + this.starredUrl, + this.subscriptionsUrl, + this.organizationsUrl, + this.reposUrl, + this.eventsUrl, + this.receivedEventsUrl, + this.type, + this.siteAdmin, }); - factory User.fromJson(Map jsonRes) => jsonRes == null + factory Owner.fromJson(Map jsonRes) => jsonRes == null ? null - : User( - community: asT(jsonRes['community']), - collectedEntriesCount: asT(jsonRes['collectedEntriesCount']), - company: asT(jsonRes['company']), - followersCount: asT(jsonRes['followersCount']), - followeesCount: asT(jsonRes['followeesCount']), - role: asT(jsonRes['role']), - postedPostsCount: asT(jsonRes['postedPostsCount']), - level: asT(jsonRes['level']), - isAuthor: asT(jsonRes['isAuthor']), - postedEntriesCount: asT(jsonRes['postedEntriesCount']), - totalCommentsCount: asT(jsonRes['totalCommentsCount']), - ngxCachedTime: asT(jsonRes['ngxCachedTime']), - ngxCached: asT(jsonRes['ngxCached']), - viewedEntriesCount: asT(jsonRes['viewedEntriesCount']), - jobTitle: asT(jsonRes['jobTitle']), - subscribedTagsCount: asT(jsonRes['subscribedTagsCount']), - totalCollectionsCount: asT(jsonRes['totalCollectionsCount']), - username: asT(jsonRes['username']), - avatarLarge: asT(jsonRes['avatarLarge']), - objectId: asT(jsonRes['objectId']), + : Owner( + login: asT(jsonRes['login']), + id: asT(jsonRes['id']), + nodeId: asT(jsonRes['node_id']), + avatarUrl: asT(jsonRes['avatar_url']), + gravatarId: asT(jsonRes['gravatar_id']), + url: asT(jsonRes['url']), + htmlUrl: asT(jsonRes['html_url']), + followersUrl: asT(jsonRes['followers_url']), + followingUrl: asT(jsonRes['following_url']), + gistsUrl: asT(jsonRes['gists_url']), + starredUrl: asT(jsonRes['starred_url']), + subscriptionsUrl: asT(jsonRes['subscriptions_url']), + organizationsUrl: asT(jsonRes['organizations_url']), + reposUrl: asT(jsonRes['repos_url']), + eventsUrl: asT(jsonRes['events_url']), + receivedEventsUrl: asT(jsonRes['received_events_url']), + type: asT(jsonRes['type']), + siteAdmin: asT(jsonRes['site_admin']), ); - Object community; - int collectedEntriesCount; - String company; - int followersCount; - int followeesCount; - String role; - int postedPostsCount; - int level; - bool isAuthor; - int postedEntriesCount; - int totalCommentsCount; - int ngxCachedTime; - bool ngxCached; - int viewedEntriesCount; - String jobTitle; - int subscribedTagsCount; - int totalCollectionsCount; - String username; - String avatarLarge; - String objectId; + String login; + int id; + String nodeId; + String avatarUrl; + String gravatarId; + String url; + String htmlUrl; + String followersUrl; + String followingUrl; + String gistsUrl; + String starredUrl; + String subscriptionsUrl; + String organizationsUrl; + String reposUrl; + String eventsUrl; + String receivedEventsUrl; + String type; + bool siteAdmin; Map toJson() => { - 'community': community, - 'collectedEntriesCount': collectedEntriesCount, - 'company': company, - 'followersCount': followersCount, - 'followeesCount': followeesCount, - 'role': role, - 'postedPostsCount': postedPostsCount, - 'level': level, - 'isAuthor': isAuthor, - 'postedEntriesCount': postedEntriesCount, - 'totalCommentsCount': totalCommentsCount, - 'ngxCachedTime': ngxCachedTime, - 'ngxCached': ngxCached, - 'viewedEntriesCount': viewedEntriesCount, - 'jobTitle': jobTitle, - 'subscribedTagsCount': subscribedTagsCount, - 'totalCollectionsCount': totalCollectionsCount, - 'username': username, - 'avatarLarge': avatarLarge, - 'objectId': objectId, + 'login': login, + 'id': id, + 'node_id': nodeId, + 'avatar_url': avatarUrl, + 'gravatar_id': gravatarId, + 'url': url, + 'html_url': htmlUrl, + 'followers_url': followersUrl, + 'following_url': followingUrl, + 'gists_url': gistsUrl, + 'starred_url': starredUrl, + 'subscriptions_url': subscriptionsUrl, + 'organizations_url': organizationsUrl, + 'repos_url': reposUrl, + 'events_url': eventsUrl, + 'received_events_url': receivedEventsUrl, + 'type': type, + 'site_admin': siteAdmin, }; @override @@ -379,37 +457,37 @@ class User { } } -class Category { - Category({ - this.ngxCached, - this.title, - this.id, +class License { + License({ + this.key, this.name, - this.ngxCachedTime, + this.spdxId, + this.url, + this.nodeId, }); - factory Category.fromJson(Map jsonRes) => jsonRes == null + factory License.fromJson(Map jsonRes) => jsonRes == null ? null - : Category( - ngxCached: asT(jsonRes['ngxCached']), - title: asT(jsonRes['title']), - id: asT(jsonRes['id']), + : License( + key: asT(jsonRes['key']), name: asT(jsonRes['name']), - ngxCachedTime: asT(jsonRes['ngxCachedTime']), + spdxId: asT(jsonRes['spdx_id']), + url: asT(jsonRes['url']), + nodeId: asT(jsonRes['node_id']), ); - bool ngxCached; - String title; - String id; + String key; String name; - int ngxCachedTime; + String spdxId; + String url; + String nodeId; Map toJson() => { - 'ngxCached': ngxCached, - 'title': title, - 'id': id, + 'key': key, 'name': name, - 'ngxCachedTime': ngxCachedTime, + 'spdx_id': spdxId, + 'url': url, + 'node_id': nodeId, }; @override diff --git a/lib/pages/feed/feeddetailpage.dart b/lib/pages/feed/feeddetailpage.dart index dbb2535..b804e0f 100644 --- a/lib/pages/feed/feeddetailpage.dart +++ b/lib/pages/feed/feeddetailpage.dart @@ -6,7 +6,7 @@ import 'package:share/share.dart'; import 'package:webview_flutter/webview_flutter.dart'; class FeedDetailPage extends StatefulWidget { - final EntryDetail article; + final Items article; const FeedDetailPage({Key key, this.article}) : super(key: key); @@ -49,14 +49,14 @@ class _FeedDetailPageState extends State { actions: [ IconButton( icon: Icon(Icons.share), - onPressed: () => Share.share(widget.article.originalUrl), + onPressed: () => Share.share(widget.article.htmlUrl), ), ], ), body: SafeArea( bottom: false, child: WebView( - initialUrl: widget.article.originalUrl, + initialUrl: widget.article.htmlUrl, javascriptMode: JavascriptMode.unrestricted, navigationDelegate: (NavigationRequest request) { if (!request.url.startsWith('http')) { diff --git a/lib/pages/feed/feedmainpage.dart b/lib/pages/feed/feedmainpage.dart index 95ae262..e979296 100644 --- a/lib/pages/feed/feedmainpage.dart +++ b/lib/pages/feed/feedmainpage.dart @@ -44,14 +44,14 @@ class FeedMainPage extends StatelessWidget { Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ - detail.screenshot.isEmpty + detail.owner.avatarUrl.isEmpty ? Image.asset( 'images/book.jpg', width: 60, height: 80, ) : Image.network( - '${detail.screenshot}', + '${detail.owner.avatarUrl}', width: 60, height: 80, ), @@ -63,12 +63,12 @@ class FeedMainPage extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Text( - '${detail.title}', + '${detail.fullName}', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold), ), SizedBox(height: 8), Text( - '${detail.summaryInfo}', + '${detail.description}', maxLines: 4, overflow: TextOverflow.ellipsis, style: TextStyle( @@ -88,11 +88,11 @@ class FeedMainPage extends StatelessWidget { children: [ CircleAvatar( radius: 12, - backgroundImage: NetworkImage('${detail.user.avatarLarge}'), + backgroundImage: NetworkImage('${detail.owner.avatarUrl}'), ), SizedBox(width: 24), Text( - '${detail.user.username}', + '${detail.owner.login}', style: TextStyle( fontSize: 12, color: Colors.grey.shade500, @@ -125,12 +125,12 @@ class FeedMainPage extends StatelessWidget { } class FeedListViewModel with ChangeNotifier { - List feedList = List(); + List feedList = List(); int pageIndex = 0; void getFlutterFeedList() async { - var feedEntity = await client.getTagDataList('web', '5a96291f6fb9a0535b535438', pageIndex, 20, 'createdAt'); - var list = feedEntity.d.entrylist; + var feedEntity = await client.getTagDataList('android+in:description,name', 'updated', 'desc', pageIndex, 10); + var list = feedEntity.items; if (list.length > 0) { pageIndex++; feedList.addAll(list); diff --git a/lib/pages/feed/restclient.dart b/lib/pages/feed/restclient.dart index f770398..52838e5 100644 --- a/lib/pages/feed/restclient.dart +++ b/lib/pages/feed/restclient.dart @@ -4,17 +4,17 @@ import 'package:retrofit/retrofit.dart'; part 'restclient.g.dart'; -@RestApi(baseUrl: 'https://timeline-merger-ms.juejin.im/v1/') +@RestApi(baseUrl: 'https://api.github.com/search/') abstract class RestClient { factory RestClient(Dio dio, {String baseUrl}) = _RestClient; - @GET('/get_tag_entry') + @GET('/repositories') Future getTagDataList( - @Query('src') String src, - @Query('tagId') String tagId, - @Query('page') int page, - @Query('pageSize') int pageSize, + @Query('q') String q, @Query('sort') String sort, + @Query('order') String order, + @Query('page') int page, + @Query('per_page') int perPage, ); } diff --git a/lib/pages/feed/restclient.g.dart b/lib/pages/feed/restclient.g.dart index ba23ba4..141bd58 100644 --- a/lib/pages/feed/restclient.g.dart +++ b/lib/pages/feed/restclient.g.dart @@ -9,7 +9,7 @@ part of 'restclient.dart'; class _RestClient implements RestClient { _RestClient(this._dio, {this.baseUrl}) { ArgumentError.checkNotNull(_dio, '_dio'); - this.baseUrl ??= 'https://timeline-merger-ms.juejin.im/v1/'; + this.baseUrl ??= 'https://api.github.com/search/'; } final Dio _dio; @@ -17,18 +17,29 @@ class _RestClient implements RestClient { String baseUrl; @override - getTagDataList(src, tagId, page, pageSize, sort) async { - ArgumentError.checkNotNull(src, 'src'); - ArgumentError.checkNotNull(tagId, 'tagId'); - ArgumentError.checkNotNull(page, 'page'); - ArgumentError.checkNotNull(pageSize, 'pageSize'); + getTagDataList(q, sort, order, page, per_page) async { + ArgumentError.checkNotNull(q, 'q'); ArgumentError.checkNotNull(sort, 'sort'); + ArgumentError.checkNotNull(order, 'order'); + ArgumentError.checkNotNull(page, 'page'); + ArgumentError.checkNotNull(per_page, 'per_page'); const _extra = {}; - final queryParameters = {r'src': src, r'tagId': tagId, r'page': page, r'pageSize': pageSize, r'sort': sort}; + final queryParameters = { + r'q': q, + r'sort': sort, + r'order': order, + r'page': page, + r'per_page': per_page + }; final _data = {}; - final Response> _result = await _dio.request('/get_tag_entry', + final Response> _result = await _dio.request( + '/repositories', queryParameters: queryParameters, - options: RequestOptions(method: 'GET', headers: {}, extra: _extra, baseUrl: baseUrl), + options: RequestOptions( + method: 'GET', + headers: {}, + extra: _extra, + baseUrl: baseUrl), data: _data); final value = FeedEntity.fromJson(_result.data); return value;