diff --git a/src/app/dashboard/[subdomain]/page-component.tsx b/src/app/dashboard/[subdomain]/page-component.tsx index bfa336b4..7bc16723 100644 --- a/src/app/dashboard/[subdomain]/page-component.tsx +++ b/src/app/dashboard/[subdomain]/page-component.tsx @@ -39,45 +39,59 @@ export default function SubdomainIndex() { const statMap = [ { icon: "icon-[mingcute--news-line]", - name: "Published posts", - value: stat.data?.notesCount, + name: "Creation", + value: stat.data?.notesCount ?? "-", url: `/dashboard/${subdomain}/posts`, }, { icon: "icon-[mingcute--comment-line]", - name: "Received comments", - value: stat.data?.commentsCount, + name: "Comments", + value: stat.data?.commentsCount ?? "-", url: `/dashboard/${subdomain}/comments`, }, { icon: "icon-[mingcute--heart-line]", - name: "Received tips", + name: "Tips1", value: `${ tips.data?.pages?.[0]?.list ?.map((i) => +i.amount) - .reduce((acr, cur) => acr + cur, 0) ?? 0 + .reduce((acr, cur) => acr + cur, 0) ?? "-" } MIRA`, url: `/dashboard/${subdomain}/tokens`, }, { - icon: "icon-[mingcute--user-follow-line]", - name: "Followers", - value: stat.data?.subscriptionCount, + icon: "icon-[mingcute--thumb-up-2-line]", + name: "Likes", + value: stat.data?.likesCount ?? "-", url: getSiteLink({ subdomain, }), }, + { + icon: "icon-[mingcute--user-follow-line]", + name: "Followers", + value: stat.data?.subscriptionCount ?? "-", + url: getSiteLink({ + subdomain, + }), + }, + { + icon: "icon-[mingcute--trophy-line]", + name: "Achievements", + value: stat.data?.achievements ?? "-", + url: `/dashboard/${subdomain}/achievements`, + }, { icon: "icon-[mingcute--eye-line]", name: "Viewed", - value: stat.data?.viewsCount, + value: stat.data?.viewsCount ?? "-", url: getSiteLink({ subdomain, }), }, { icon: "icon-[mingcute--history-line]", - name: "Site Duration", + name: "Become xLogger for", value: date.dayjs().diff(date.dayjs(stat.data?.createdAt), "day") + " " + diff --git a/src/lib/i18n/locales/en/dashboard.json b/src/lib/i18n/locales/en/dashboard.json index 56b5f053..a38d7766 100644 --- a/src/lib/i18n/locales/en/dashboard.json +++ b/src/lib/i18n/locales/en/dashboard.json @@ -1,4 +1,5 @@ { + "Tips1": "Tips", "link post-vs-page": "https://wordpress.com/zh-cn/support/post-vs-page/", "delete_confirmation_post": "Are you sure you want to DELETE this post?", "delete_confirmation_page": "Are you sure you want to DELETE this page?", diff --git a/src/lib/i18n/locales/ja/dashboard.json b/src/lib/i18n/locales/ja/dashboard.json index 6dde6f3c..6e9ddd2d 100644 --- a/src/lib/i18n/locales/ja/dashboard.json +++ b/src/lib/i18n/locales/ja/dashboard.json @@ -6,11 +6,6 @@ "Unread notifications": "未読の通知", "Settings": "設定", "Site Stats": "サイトの統計情報", - "Total Posts": "記事数", - "Total Comments": "コメント数", - "Total Followers": "フォロワー数", - "Total Views": "閲覧数", - "Site Duration": "サイトの運営期間", "days": "日", "Deleted!": "削除されました!", "Fail to Deleted.": "削除できませんでした。", diff --git a/src/lib/i18n/locales/zh-TW/dashboard.json b/src/lib/i18n/locales/zh-TW/dashboard.json index 1d47ed22..656f67ec 100644 --- a/src/lib/i18n/locales/zh-TW/dashboard.json +++ b/src/lib/i18n/locales/zh-TW/dashboard.json @@ -8,12 +8,11 @@ "Events": "活動", "New Events": "新活動", "Site Stats": "網站統計", - "Published posts": "文章", - "Received comments": "留言", + "Likes": "讚", + "Tips1": "打賞", "Followers": "粉絲", "Viewed": "瀏覽量", - "Received tips": "Donate", - "Site Duration": "Blog 誕生", + "Become xLogger for": "成為 xLogger", "days": "天", "Deleted!": "刪掉了哦!", "Fail to Deleted.": "删除失败", diff --git a/src/lib/i18n/locales/zh/dashboard.json b/src/lib/i18n/locales/zh/dashboard.json index 53cab38d..a5892996 100644 --- a/src/lib/i18n/locales/zh/dashboard.json +++ b/src/lib/i18n/locales/zh/dashboard.json @@ -8,12 +8,11 @@ "Events": "活动", "New Events": "新活动", "Site Stats": "站点统计", - "Published posts": "发布的文章", - "Received comments": "收到的评论", + "Likes": "点赞", + "Tips1": "打赏", "Followers": "关注者", "Viewed": "浏览量", - "Received tips": "收到的打赏", - "Site Duration": "站点运行时间", + "Become xLogger for": "成为 xLogger", "days": "天", "Deleted!": "已删除!", "Fail to Deleted.": "删除失败", diff --git a/src/models/site.model.ts b/src/models/site.model.ts index 51a06607..5b9a1277 100644 --- a/src/models/site.model.ts +++ b/src/models/site.model.ts @@ -199,25 +199,49 @@ export async function removeOperator( export async function getStat({ characterId }: { characterId: number }) { if (characterId) { - const [stat, site, subscriptions, comments, notes] = await Promise.all([ - ( - await fetch( - `https://indexer.crossbell.io/v1/stat/characters/${characterId}`, - ) - ).json(), - indexer.character.get(characterId), - indexer.link.getBacklinksOfCharacter(characterId, { limit: 0 }), - indexer.note.getMany({ - limit: 0, - toCharacterId: characterId, - }), - indexer.note.getMany({ - characterId, - sources: "xlog", - tags: ["post"], - limit: 0, - }), - ]) + const [stat, site, subscriptions, comments, notes, likes, achievement] = + await Promise.all([ + ( + await fetch( + `https://indexer.crossbell.io/v1/stat/characters/${characterId}`, + ) + ).json(), + indexer.character.get(characterId), + indexer.link.getBacklinksOfCharacter(characterId, { + limit: 0, + linkType: "follow", + }), + indexer.note.getMany({ + limit: 0, + toCharacterId: characterId, + }), + indexer.note.getMany({ + characterId, + sources: "xlog", + limit: 0, + }), + await client + .query( + gql` + query getLinklistCount($characterId: Int!) { + linkCount( + where: { + linkType: { equals: "like" } + toCharacterId: { equals: $characterId } + } + ) + } + `, + { + characterId, + }, + ) + .toPromise(), + await indexer.achievement.getMany(characterId, { + status: ["MINTED"], + }), + ]) + return { viewsCount: stat.viewNoteCount, createdAt: site?.createdAt, @@ -225,6 +249,10 @@ export async function getStat({ characterId }: { characterId: number }) { subscriptionCount: subscriptions?.count, commentsCount: comments?.count, notesCount: notes?.count, + likesCount: likes?.data?.linkCount, + achievements: achievement?.list.reduce((acc, cur) => { + return acc + cur.groups.length + }, 0), } } }