fix(frontend): ロールのタイトルのバグを解決、Reactivity Transformで型エラーを出さないように (#10729)

* fix: #10569を解決

* fix: ロールが存在しない場合、タイトルにエラーメッセージを表示させる

* fix: Reactivity Transformで型エラーを出さないように

* feat: i18n対応

* feat: タブでエラー表示

* fix: エラーメッセージを分ける

* fix: 使う変数の間違えを修正

* productionビルドできない問題を修正

---------

Co-authored-by: tamaina <tamaina@hotmail.co.jp>
This commit is contained in:
Chocolate Pie 2023-04-29 23:36:28 +09:00 committed by GitHub
parent 351bee325b
commit 149ddebf16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 177 additions and 18 deletions

View File

@ -943,6 +943,7 @@ didYouLikeMisskey: "Misskeyを気に入っていただけましたか"
pleaseDonate: "Misskeyは{host}が使用している無料のソフトウェアです。これからも開発を続けられるように、ぜひ寄付をお願いします!"
roles: "ロール"
role: "ロール"
noRole: "ロールはありません"
normalUser: "一般ユーザー"
undefined: "未定義"
assign: "アサイン"

View File

@ -22,6 +22,7 @@
"@syuilo/aiscript": "0.13.1",
"@tabler/icons-webfont": "2.16.0",
"@vitejs/plugin-vue": "4.1.0",
"@vue-macros/reactivity-transform": "^0.3.5",
"@vue/compiler-sfc": "3.2.47",
"autosize": "5.0.2",
"blurhash": "2.0.5",

View File

@ -1,8 +1,16 @@
<template>
<MkStickyContainer>
<template #header><MkPageHeader v-model:tab="tab" :tabs="headerTabs"/></template>
<MkSpacer v-if="tab === 'users'" :content-max="1200">
<MKSpacer v-if="!(typeof error === 'undefined')" :content-max="1200">
<div :class="$style.root">
<img :class="$style.img" src="https://xn--931a.moe/assets/error.jpg" class="_ghost"/>
<p :class="$style.text">
<i class="ti ti-alert-triangle"></i>
{{ error }}
</p>
</div>
</MKSpacer>
<MkSpacer v-else-if="tab === 'users'" :content-max="1200">
<div class="_gaps_s">
<div v-if="role">{{ role.description }}</div>
<MkUserList :pagination="users" :extractor="(item) => item.user"/>
@ -13,7 +21,6 @@
</MkSpacer>
</MkStickyContainer>
</template>
<script lang="ts" setup>
import { computed, watch } from 'vue';
import * as os from '@/os';
@ -21,6 +28,7 @@ import MkUserList from '@/components/MkUserList.vue';
import { definePageMetadata } from '@/scripts/page-metadata';
import { i18n } from '@/i18n';
import MkTimeline from '@/components/MkTimeline.vue';
import { instanceName } from '@/config';
const props = withDefaults(defineProps<{
role: string;
@ -31,12 +39,21 @@ const props = withDefaults(defineProps<{
let tab = $ref(props.initialTab);
let role = $ref();
let error = $ref();
watch(() => props.role, () => {
os.api('roles/show', {
roleId: props.role,
}).then(res => {
role = res;
document.title = `${role?.name} | ${instanceName}`;
}).catch((err) => {
if (err.code === 'NO_SUCH_ROLE') {
error = i18n.ts.noRole;
} else {
error = i18n.ts.somethingHappened;
}
document.title = `${error} | ${instanceName}`;
});
}, { immediate: true });
@ -63,4 +80,23 @@ definePageMetadata(computed(() => ({
icon: 'ti ti-badge',
})));
</script>
<style lang="scss" module>
.root {
padding: 32px;
text-align: center;
align-items: center;
}
.text {
margin: 0 0 8px 0;
}
.img {
vertical-align: bottom;
width: 128px;
height: 128px;
margin-bottom: 16px;
border-radius: 16px;
}
</style>

View File

@ -27,10 +27,12 @@
},
"typeRoots": [
"node_modules/@types",
"node_modules/@vue-macros",
"@types",
],
"types": [
"vite/client",
"reactivity-transform/macros-global"
],
"lib": [
"esnext",

View File

@ -2,6 +2,8 @@ import path from 'path';
import pluginReplace from '@rollup/plugin-replace';
import pluginVue from '@vitejs/plugin-vue';
import { type UserConfig, defineConfig } from 'vite';
// @ts-expect-error https://github.com/sxzz/unplugin-vue-macros/issues/257#issuecomment-1410752890
import ReactivityTransform from '@vue-macros/reactivity-transform/vite';
import locales from '../../locales';
import meta from '../../package.json';
@ -46,6 +48,7 @@ export function getConfig(): UserConfig {
pluginVue({
reactivityTransform: true,
}),
ReactivityTransform(),
pluginJson5(),
...process.env.NODE_ENV === 'production'
? [

146
pnpm-lock.yaml generated
View File

@ -609,6 +609,9 @@ importers:
'@vitejs/plugin-vue':
specifier: 4.1.0
version: 4.1.0(vite@4.2.2)(vue@3.2.47)
'@vue-macros/reactivity-transform':
specifier: ^0.3.5
version: 0.3.5(rollup@3.20.6)(vue@3.2.47)
'@vue/compiler-sfc':
specifier: 3.2.47
version: 3.2.47
@ -2057,7 +2060,7 @@ packages:
'@babel/helper-compilation-targets': 7.21.4(@babel/core@7.21.3)
'@babel/helper-module-transforms': 7.21.2
'@babel/helpers': 7.21.0
'@babel/parser': 7.21.3
'@babel/parser': 7.21.4
'@babel/template': 7.20.7
'@babel/traverse': 7.21.3
'@babel/types': 7.21.4
@ -2332,6 +2335,14 @@ packages:
hasBin: true
dependencies:
'@babel/types': 7.21.4
dev: true
/@babel/parser@7.21.4:
resolution: {integrity: sha512-alVJj7k7zIxqBZ7BTRhz0IqJFxW1VJbm6N8JbcYhQ186df9ZBPbZBmWSqAMXwHGsCJdYks7z/voa3ibiS5bCIw==}
engines: {node: '>=6.0.0'}
hasBin: true
dependencies:
'@babel/types': 7.21.4
/@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression@7.18.6(@babel/core@7.21.3):
resolution: {integrity: sha512-Dgxsyg54Fx1d4Nge8UnvTrED63vrwOdPmyvPzlNN/boaliRP54pm3pGzZD1SJUwrBA+Cs/xdG8kXX6Mn/RfISQ==}
@ -3308,7 +3319,7 @@ packages:
engines: {node: '>=6.9.0'}
dependencies:
'@babel/code-frame': 7.18.6
'@babel/parser': 7.21.3
'@babel/parser': 7.21.4
'@babel/types': 7.21.4
dev: true
@ -3322,7 +3333,7 @@ packages:
'@babel/helper-function-name': 7.21.0
'@babel/helper-hoist-variables': 7.18.6
'@babel/helper-split-export-declaration': 7.18.6
'@babel/parser': 7.21.3
'@babel/parser': 7.21.4
'@babel/types': 7.21.4
debug: 4.3.4(supports-color@8.1.1)
globals: 11.12.0
@ -5483,7 +5494,7 @@ packages:
resolution: {integrity: sha512-xKOjuAlFuUOWO6JmhcEqUGTSGds9hbGSLYg0bh2BueWRvqhT3kvHqE4OKWmEfhfl4UDxIKbfEbJOxxVNni14gg==}
dependencies:
'@babel/generator': 7.21.3
'@babel/parser': 7.21.3
'@babel/parser': 7.21.4
'@babel/traverse': 7.21.3
'@babel/types': 7.21.4
'@storybook/csf': 0.1.0
@ -6269,7 +6280,7 @@ packages:
/@types/babel__template@7.4.1:
resolution: {integrity: sha512-azBFKemX6kMg5Io+/rdGT0dkGreboUVR0Cdm3fz9QJWpaQGJRQXl7C+6hOTCZcMll7KFyEQpgbYI2lHdsS4U7g==}
dependencies:
'@babel/parser': 7.21.3
'@babel/parser': 7.21.4
'@babel/types': 7.21.4
dev: true
@ -7163,24 +7174,76 @@ packages:
- typescript
dev: true
/@vue-macros/common@1.3.0(rollup@3.20.6)(vue@3.2.47):
resolution: {integrity: sha512-oRK9vdKryXtJbfucRla8XdnQiWVVNHEBid0waacdfMJn+LOunWeU/3k8VoZZc328HmmZj69MGkUoMWixsHCHGg==}
engines: {node: '>=14.19.0'}
peerDependencies:
vue: ^2.7.0 || ^3.2.25
peerDependenciesMeta:
vue:
optional: true
dependencies:
'@babel/types': 7.21.4
'@rollup/pluginutils': 5.0.2(rollup@3.20.6)
'@vue/compiler-sfc': 3.3.0-beta.2
local-pkg: 0.4.3
magic-string-ast: 0.1.2
vue: 3.2.47
transitivePeerDependencies:
- rollup
dev: false
/@vue-macros/reactivity-transform@0.3.5(rollup@3.20.6)(vue@3.2.47):
resolution: {integrity: sha512-HDWPMytAp32uC4aXuLITsBkxGI8yppmthGSSYJENXPvovnIctGV7q6mMNkr9cJMjyr6pjE1rv0y0Vc7SUhx/Xw==}
engines: {node: '>=14.19.0'}
peerDependencies:
vue: ^2.7.0 || ^3.2.25
dependencies:
'@babel/parser': 7.21.4
'@vue-macros/common': 1.3.0(rollup@3.20.6)(vue@3.2.47)
'@vue/compiler-core': 3.3.0-beta.2
'@vue/shared': 3.3.0-beta.2
magic-string: 0.30.0
unplugin: 1.3.1
vue: 3.2.47
transitivePeerDependencies:
- rollup
dev: false
/@vue/compiler-core@3.2.47:
resolution: {integrity: sha512-p4D7FDnQb7+YJmO2iPEv0SQNeNzcbHdGByJDsT4lynf63AFkOTFN07HsiRSvjGo0QrxR/o3d0hUyNCUnBU2Tig==}
dependencies:
'@babel/parser': 7.21.3
'@babel/parser': 7.21.4
'@vue/shared': 3.2.47
estree-walker: 2.0.2
source-map: 0.6.1
/@vue/compiler-core@3.3.0-beta.2:
resolution: {integrity: sha512-Z2VZCL9Rr1gVgyALHIRP+lNFjgfs/K4aTxvJYQ2vhgEAaI0/L6wtG5sr/gOP+MgxwGQV0PvA+iDG3Y3PC7rTEg==}
dependencies:
'@babel/parser': 7.21.4
'@vue/shared': 3.3.0-beta.2
estree-walker: 2.0.2
source-map-js: 1.0.2
dev: false
/@vue/compiler-dom@3.2.47:
resolution: {integrity: sha512-dBBnEHEPoftUiS03a4ggEig74J2YBZ2UIeyfpcRM2tavgMWo4bsEfgCGsu+uJIL/vax9S+JztH8NmQerUo7shQ==}
dependencies:
'@vue/compiler-core': 3.2.47
'@vue/shared': 3.2.47
/@vue/compiler-dom@3.3.0-beta.2:
resolution: {integrity: sha512-9LPRdCj66OwmUiPa9nuKiaoyKxlFT56j+io8nK/aW5OLl1UkY//Lj661fmDkTY20oLmArt73fAuHD913w4hRqA==}
dependencies:
'@vue/compiler-core': 3.3.0-beta.2
'@vue/shared': 3.3.0-beta.2
dev: false
/@vue/compiler-sfc@2.7.14:
resolution: {integrity: sha512-aNmNHyLPsw+sVvlQFQ2/8sjNuLtK54TC6cuKnVzAY93ks4ZBrvwQSnkkIh7bsbNhum5hJBS00wSDipQ937f5DA==}
dependencies:
'@babel/parser': 7.21.3
'@babel/parser': 7.21.4
postcss: 8.4.21
source-map: 0.6.1
dev: false
@ -7199,21 +7262,53 @@ packages:
postcss: 8.4.21
source-map: 0.6.1
/@vue/compiler-sfc@3.3.0-beta.2:
resolution: {integrity: sha512-5FmcQ5LIpM/Y22dTxnxWPD04jC2gr6XSVVqQNY0y776F1P9x4f06fIpMibL58aKU07Th2z4Ab3oPg/Cg1QNVmA==}
dependencies:
'@babel/parser': 7.21.4
'@vue/compiler-core': 3.3.0-beta.2
'@vue/compiler-dom': 3.3.0-beta.2
'@vue/compiler-ssr': 3.3.0-beta.2
'@vue/reactivity-transform': 3.3.0-beta.2
'@vue/shared': 3.3.0-beta.2
estree-walker: 2.0.2
magic-string: 0.30.0
postcss: 8.4.21
source-map-js: 1.0.2
dev: false
/@vue/compiler-ssr@3.2.47:
resolution: {integrity: sha512-wVXC+gszhulcMD8wpxMsqSOpvDZ6xKXSVWkf50Guf/S+28hTAXPDYRTbLQ3EDkOP5Xz/+SY37YiwDquKbJOgZw==}
dependencies:
'@vue/compiler-dom': 3.2.47
'@vue/shared': 3.2.47
/@vue/compiler-ssr@3.3.0-beta.2:
resolution: {integrity: sha512-Xg9od6GvHwfEpnTxMQR+KlKG1nbOHWRLHCiSA0FENiSDTjCDHh0ClzZLhIZUZJD75miyE9ia5ZQF6vpw680rCw==}
dependencies:
'@vue/compiler-dom': 3.3.0-beta.2
'@vue/shared': 3.3.0-beta.2
dev: false
/@vue/reactivity-transform@3.2.47:
resolution: {integrity: sha512-m8lGXw8rdnPVVIdIFhf0LeQ/ixyHkH5plYuS83yop5n7ggVJU+z5v0zecwEnX7fa7HNLBhh2qngJJkxpwEEmYA==}
dependencies:
'@babel/parser': 7.21.3
'@babel/parser': 7.21.4
'@vue/compiler-core': 3.2.47
'@vue/shared': 3.2.47
estree-walker: 2.0.2
magic-string: 0.25.9
/@vue/reactivity-transform@3.3.0-beta.2:
resolution: {integrity: sha512-EUL53/rsd+hrqhCa/SrhXQ6PzMZJfLQt39xQlzr0Sxsdv/bg5lqbcK9YtGkjYohRuSp1QneFU78LEsQ9j4B2Dw==}
dependencies:
'@babel/parser': 7.21.4
'@vue/compiler-core': 3.3.0-beta.2
'@vue/shared': 3.3.0-beta.2
estree-walker: 2.0.2
magic-string: 0.30.0
dev: false
/@vue/reactivity@3.2.47:
resolution: {integrity: sha512-7khqQ/75oyyg+N/e+iwV6lpy1f5wq759NdlS1fpAhFXa8VeAIKGgk2E/C4VF59lx5b+Ezs5fpp/5WsRYXQiKxQ==}
dependencies:
@ -7244,6 +7339,10 @@ packages:
/@vue/shared@3.2.47:
resolution: {integrity: sha512-BHGyyGN3Q97EZx0taMQ+OLNuZcW3d37ZEVmEAyeoA9ERdGvm9Irc/0Fua8SNyOtV1w6BS4q25wbMzJujO9HIfQ==}
/@vue/shared@3.3.0-beta.2:
resolution: {integrity: sha512-AsHYKYiYUnL/LHog6iV/G9tctFZYOsaxHDbSnfeyip94rjndO46XSDbHek7wDlcj3NHGaf8jAQQKfva/7mypjA==}
dev: false
/@vue/test-utils@2.3.2(vue@3.2.47):
resolution: {integrity: sha512-hJnVaYhbrIm0yBS0+e1Y0Sj85cMyAi+PAbK4JHqMRUZ6S622Goa+G7QzkRSyvCteG8wop7tipuEbHoZo26wsSA==}
peerDependencies:
@ -9270,7 +9369,7 @@ packages:
/constantinople@4.0.1:
resolution: {integrity: sha512-vCrqcSIq4//Gx74TXXCGnHpulY1dskqLTFGDmhrGxzeXL8lF8kvXv6mpNWlJj1uD4DW23D4ljAqbY4RRaaUZIw==}
dependencies:
'@babel/parser': 7.21.3
'@babel/parser': 7.21.4
'@babel/types': 7.21.4
/content-disposition@0.5.4:
@ -12899,7 +12998,7 @@ packages:
engines: {node: '>=8'}
dependencies:
'@babel/core': 7.21.3
'@babel/parser': 7.21.3
'@babel/parser': 7.21.4
'@istanbuljs/schema': 0.1.3
istanbul-lib-coverage: 3.2.0
semver: 6.3.0
@ -13541,7 +13640,7 @@ packages:
'@babel/preset-env': ^7.1.6
dependencies:
'@babel/core': 7.21.3
'@babel/parser': 7.21.3
'@babel/parser': 7.21.4
'@babel/plugin-proposal-class-properties': 7.18.6(@babel/core@7.21.3)
'@babel/plugin-proposal-nullish-coalescing-operator': 7.18.6(@babel/core@7.21.3)
'@babel/plugin-proposal-optional-chaining': 7.21.0(@babel/core@7.21.3)
@ -13938,7 +14037,6 @@ packages:
/local-pkg@0.4.3:
resolution: {integrity: sha512-SFppqq5p42fe2qcZQqqEOiVRXl+WCP1MdT6k7BDEW1j++sp5fIY+/fdRQitvKgB5BrBcmrs5m/L0v2FrU5MY1g==}
engines: {node: '>=14'}
dev: true
/locate-path@3.0.0:
resolution: {integrity: sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==}
@ -14172,6 +14270,13 @@ packages:
hasBin: true
dev: true
/magic-string-ast@0.1.2:
resolution: {integrity: sha512-P53AZrzq7hclCU6HWj88xNZHmP15DKjMmK/vBytO1qnpYP3ul4IEZlyCE0aU3JRnmgWmZPmoTKj4Bls7v0pMyA==}
engines: {node: '>=14.19.0'}
dependencies:
magic-string: 0.30.0
dev: false
/magic-string@0.25.9:
resolution: {integrity: sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ==}
dependencies:
@ -14188,7 +14293,6 @@ packages:
engines: {node: '>=12'}
dependencies:
'@jridgewell/sourcemap-codec': 1.4.14
dev: true
/mailcheck@1.1.1:
resolution: {integrity: sha512-3WjL8+ZDouZwKlyJBMp/4LeziLFXgleOdsYu87piGcMLqhBzCsy2QFdbtAwv757TFC/rtqd738fgJw1tFQCSgA==}
@ -19021,6 +19125,15 @@ packages:
webpack-virtual-modules: 0.4.6
dev: true
/unplugin@1.3.1:
resolution: {integrity: sha512-h4uUTIvFBQRxUKS2Wjys6ivoeofGhxzTe2sRWlooyjHXVttcVfV/JiavNd3d4+jty0SVV0dxGw9AkY9MwiaCEw==}
dependencies:
acorn: 8.8.2
chokidar: 3.5.3
webpack-sources: 3.2.3
webpack-virtual-modules: 0.5.0
dev: false
/unset-value@1.0.0:
resolution: {integrity: sha512-PcA2tsuGSF9cnySLHTLSh2qrQiJ70mn+r+Glzxv2TWZblxsxCC52BDlZoPCsz7STd9pN7EZetkWZBAvk4cgZdQ==}
engines: {node: '>=0.10.0'}
@ -19571,12 +19684,15 @@ packages:
/webpack-sources@3.2.3:
resolution: {integrity: sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w==}
engines: {node: '>=10.13.0'}
dev: true
/webpack-virtual-modules@0.4.6:
resolution: {integrity: sha512-5tyDlKLqPfMqjT3Q9TAqf2YqjwmnUleZwzJi1A5qXnlBCdj2AtOJ6wAWdglTIDOPgOiOrXeBeFcsQ8+aGQ6QbA==}
dev: true
/webpack-virtual-modules@0.5.0:
resolution: {integrity: sha512-kyDivFZ7ZM0BVOUteVbDFhlRt7Ah/CSPwJdi8hBpkK7QLumUqdLtVfm/PX/hkcnrvr0i77fO5+TjZ94Pe+C9iw==}
dev: false
/websocket@1.0.34:
resolution: {integrity: sha512-PRDso2sGwF6kM75QykIesBijKSVceR6jL2G8NGYyq2XrItNC2P5/qL5XeR056GhA+Ly7JMFvJb9I312mJfmqnQ==}
engines: {node: '>=4.0.0'}
@ -19702,7 +19818,7 @@ packages:
resolution: {integrity: sha512-RNGKj82nUPg3g5ygxkQl0R937xLyho1J24ItRCBTr/m1YnZkzJy1hUiHUJrc/VlsDQzsCnInEGSg3bci0Lmd4w==}
engines: {node: '>= 10.0.0'}
dependencies:
'@babel/parser': 7.21.3
'@babel/parser': 7.21.4
'@babel/types': 7.21.4
assert-never: 1.2.1
babel-walk: 3.0.0-canary-5