From 10cb15b000d22e488521bbdf04bbce526e7b044f Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 30 Dec 2020 13:07:16 +0900 Subject: [PATCH] nanka iroiro --- locales/ja-JP.yml | 2 + src/client/components/global/i18n.ts | 7 +- src/client/components/page-window.vue | 2 +- src/client/pages/welcome.entrance.vue | 204 +++++++++++------- src/client/ui/visitor/b.vue | 6 +- src/client/widgets/index.ts | 2 + src/client/widgets/online-users.vue | 67 ++++++ .../api/endpoints/get-online-users-count.ts | 22 ++ 8 files changed, 225 insertions(+), 87 deletions(-) create mode 100644 src/client/widgets/online-users.vue create mode 100644 src/server/api/endpoints/get-online-users-count.ts diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 6b71acb1cf..b45ca0faf7 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -673,6 +673,7 @@ narrow: "狭い" reloadToApplySetting: "設定はページリロード後に反映されます。今すぐリロードしますか?" showTitlebar: "タイトルバーを表示する" clearCache: "キャッシュをクリア" +onlineUsersCount: "{n}人がオンライン" _aboutMisskey: about: "Misskeyはsyuiloによって2014年から開発されている、オープンソースのソフトウェアです。" @@ -1015,6 +1016,7 @@ _widgets: postForm: "投稿フォーム" slideshow: "スライドショー" button: "ボタン" + onlineUsers: "オンラインユーザー" _cw: hide: "隠す" diff --git a/src/client/components/global/i18n.ts b/src/client/components/global/i18n.ts index b1142caf96..abf0c96856 100644 --- a/src/client/components/global/i18n.ts +++ b/src/client/components/global/i18n.ts @@ -11,6 +11,11 @@ export default defineComponent({ required: false, default: 'span', }, + textTag: { + type: String, + required: false, + default: null, + }, }, render() { let str = this.src; @@ -32,6 +37,6 @@ export default defineComponent({ str = str.substr(nextBracketClose + 1); } - return h(this.tag, parsed.map(x => typeof x === 'string' ? x : this.$slots[x.arg]())); + return h(this.tag, parsed.map(x => typeof x === 'string' ? (this.textTag ? h(this.textTag, x) : x) : this.$slots[x.arg]())); } }); diff --git a/src/client/components/page-window.vue b/src/client/components/page-window.vue index 5ea0e08015..37342c403b 100644 --- a/src/client/components/page-window.vue +++ b/src/client/components/page-window.vue @@ -1,6 +1,6 @@ + + diff --git a/src/server/api/endpoints/get-online-users-count.ts b/src/server/api/endpoints/get-online-users-count.ts new file mode 100644 index 0000000000..7521104886 --- /dev/null +++ b/src/server/api/endpoints/get-online-users-count.ts @@ -0,0 +1,22 @@ +import define from '../define'; +import redis from '../../../db/redis'; +import config from '../../../config'; + +export const meta = { + tags: ['meta'], + + requireCredential: false as const, + + params: { + } +}; + +export default define(meta, (ps, user) => { + return new Promise((res, rej) => { + redis.pubsub('numsub', config.host, (_, x) => { + res({ + count: x[1] + }); + }); + }); +});