refactor(frontend): remove $i

This commit is contained in:
syuilo 2023-04-01 13:52:07 +09:00
parent 7a8a756789
commit f16a7cbcf2
22 changed files with 34 additions and 19 deletions

View file

@ -1,12 +1,9 @@
/// <reference types="vue/macros-global" />
import type { $i } from '@/account';
import type { instance } from '@/instance';
import type { i18n } from '@/i18n';
declare module 'vue' {
interface ComponentCustomProperties {
$i: typeof $i;
$t: typeof i18n['t'];
$ts: typeof i18n['ts'];
}

View file

@ -16,6 +16,7 @@
<script lang="ts" setup>
import { } from 'vue';
import { $i } from '@/account';
const props = defineProps<{
text: string;

View file

@ -22,6 +22,7 @@ import * as misskey from 'misskey-js';
import MkNoteHeader from '@/components/MkNoteHeader.vue';
import MkSubNoteContent from '@/components/MkSubNoteContent.vue';
import MkCwButton from '@/components/MkCwButton.vue';
import { $i } from '@/account';
const props = defineProps<{
note: misskey.entities.Note;

View file

@ -33,6 +33,7 @@ import MkCwButton from '@/components/MkCwButton.vue';
import { notePage } from '@/filters/note';
import * as os from '@/os';
import { i18n } from '@/i18n';
import { $i } from '@/account';
const props = withDefaults(defineProps<{
note: misskey.entities.Note;

View file

@ -36,6 +36,7 @@ import MkTextarea from '@/components/MkTextarea.vue';
import MkRadio from '@/components/MkRadio.vue';
import * as os from '@/os';
import * as config from '@/config';
import { $i } from '@/account';
export default defineComponent({
components: {
@ -51,6 +52,7 @@ export default defineComponent({
text: '',
flag: true,
radio: 'misskey',
$i,
mfm: `Hello world! This is an @example mention. BTW you are @${this.$i ? this.$i.username : 'guest'}.\nAlso, here is ${config.url} and [example link](${config.url}). for more details, see https://example.com.\nAs you know #misskey is open-source software.`,
};
},

View file

@ -27,6 +27,7 @@ import * as misskey from 'misskey-js';
import MkMediaList from '@/components/MkMediaList.vue';
import MkPoll from '@/components/MkPoll.vue';
import { i18n } from '@/i18n';
import { $i } from '@/account';
const props = defineProps<{
note: misskey.entities.Note;

View file

@ -33,6 +33,7 @@ import * as misskey from 'misskey-js';
import MkFollowButton from '@/components/MkFollowButton.vue';
import { userPage } from '@/filters/user';
import { i18n } from '@/i18n';
import { $i } from '@/account';
defineProps<{
user: misskey.entities.UserDetailed;

View file

@ -60,6 +60,7 @@ import { getUserMenu } from '@/scripts/get-user-menu';
import number from '@/filters/number';
import { i18n } from '@/i18n';
import { defaultStore } from '@/store';
import { $i } from '@/account';
const props = defineProps<{
showing: boolean;

View file

@ -17,6 +17,7 @@ import * as os from '@/os';
import { PostBlock } from '@/scripts/hpml/block';
import { Hpml } from '@/scripts/hpml/evaluator';
import { defaultStore } from '@/store';
import { $i } from '@/account';
export default defineComponent({
components: {
@ -55,7 +56,7 @@ export default defineComponent({
canvas.toBlob(blob => {
const formData = new FormData();
formData.append('file', blob);
formData.append('i', this.$i.token);
formData.append('i', $i.token);
if (defaultStore.state.uploadFolder) {
formData.append('folderId', defaultStore.state.uploadFolder);
}

View file

@ -6,11 +6,12 @@
</template>
<script lang="ts">
import { TextBlock } from '@/scripts/hpml/block';
import { Hpml } from '@/scripts/hpml/evaluator';
import { defineAsyncComponent, defineComponent, PropType } from 'vue';
import * as mfm from 'mfm-js';
import { TextBlock } from '@/scripts/hpml/block';
import { Hpml } from '@/scripts/hpml/evaluator';
import { extractUrlFromMfm } from '@/scripts/extract-url-from-mfm';
import { $i } from '@/account';
export default defineComponent({
components: {
@ -29,6 +30,7 @@ export default defineComponent({
data() {
return {
text: this.hpml.interpolate(this.block.text),
$i,
};
},
computed: {

View file

@ -200,7 +200,6 @@ if (_DEV_) {
// TODO: 廃止
app.config.globalProperties = {
$i,
$t: i18n.t,
$ts: i18n.ts,
};

View file

@ -32,13 +32,14 @@
<script lang="ts" setup>
import { watch } from 'vue';
import * as Misskey from 'misskey-js';
import XEmoji from './emojis.emoji.vue';
import MkButton from '@/components/MkButton.vue';
import MkInput from '@/components/MkInput.vue';
import MkFoldableSection from '@/components/MkFoldableSection.vue';
import { customEmojis, customEmojiCategories, getCustomEmojiTags } from '@/custom-emojis';
import { i18n } from '@/i18n';
import * as Misskey from 'misskey-js';
import { $i } from '@/account';
const customEmojiTags = getCustomEmojiTags();
let q = $ref('');

View file

@ -25,6 +25,7 @@ import MkButton from '@/components/MkButton.vue';
import * as os from '@/os';
import { i18n } from '@/i18n';
import { definePageMetadata } from '@/scripts/page-metadata';
import { $i } from '@/account';
const pagination = {
endpoint: 'announcements' as const,

View file

@ -64,6 +64,7 @@ import { createAiScriptEnv } from '@/scripts/aiscript/api';
import MkFolder from '@/components/MkFolder.vue';
import MkCode from '@/components/MkCode.vue';
import { defaultStore } from '@/store';
import { $i } from '@/account';
const props = defineProps<{
id: string;

View file

@ -68,6 +68,7 @@ import { useRouter } from '@/router';
import { i18n } from '@/i18n';
import { definePageMetadata } from '@/scripts/page-metadata';
import { defaultStore } from '@/store';
import { $i } from '@/account';
const router = useRouter();

View file

@ -77,6 +77,7 @@ import { i18n } from '@/i18n';
import { definePageMetadata } from '@/scripts/page-metadata';
import { pageViewInterruptors, defaultStore } from '@/store';
import { deepClone } from '@/scripts/clone';
import { $i } from '@/account';
const props = defineProps<{
pageName: string;

View file

@ -11,7 +11,7 @@
import FormInfo from '@/components/MkInfo.vue';
import MkButton from '@/components/MkButton.vue';
import * as os from '@/os';
import { signout } from '@/account';
import { signout, $i } from '@/account';
import { i18n } from '@/i18n';
import { definePageMetadata } from '@/scripts/page-metadata';

View file

@ -192,7 +192,7 @@ import { url } from '@/config';
import { userPage, acct } from '@/filters/user';
import { definePageMetadata } from '@/scripts/page-metadata';
import { i18n } from '@/i18n';
import { iAmAdmin, iAmModerator } from '@/account';
import { iAmAdmin, iAmModerator, $i } from '@/account';
import MkRolePreview from '@/components/MkRolePreview.vue';
const props = withDefaults(defineProps<{

View file

@ -5,30 +5,31 @@
<div class="_panel" :class="$style.content">
<div :class="$style.body">
<MkA v-if="note.replyId" class="reply" :to="`/notes/${note.replyId}`"><i class="ti ti-arrow-back-up"></i></MkA>
<Mfm v-if="note.text" :text="note.text" :author="note.user" :i="$i" />
<Mfm v-if="note.text" :text="note.text" :author="note.user" :i="$i"/>
<MkA v-if="note.renoteId" class="rp" :to="`/notes/${note.renoteId}`">RN: ...</MkA>
</div>
<div v-if="note.files.length > 0" :class="$style.richcontent">
<MkMediaList :media-list="note.files" />
<MkMediaList :media-list="note.files"/>
</div>
<div v-if="note.poll">
<MkPoll :note="note" :readOnly="true" />
<MkPoll :note="note" :read-only="true"/>
</div>
</div>
<MkReactionsViewer ref="reactionsViewer" :note="note" />
<MkReactionsViewer ref="reactionsViewer" :note="note"/>
</div>
</div>
</div>
</template>
<script lang="ts" setup>
import { Note } from 'misskey-js/built/entities';
import { onUpdated } from 'vue';
import MkReactionsViewer from '@/components/MkReactionsViewer.vue';
import MkMediaList from '@/components/MkMediaList.vue';
import MkPoll from '@/components/MkPoll.vue';
import * as os from '@/os';
import { Note } from 'misskey-js/built/entities';
import { onUpdated } from 'vue';
import { getScrollContainer } from '@/scripts/scroll';
import { $i } from '@/account';
let notes = $ref<Note[]>([]);
let isScrolling = $ref(false);

View file

@ -47,7 +47,7 @@ import { computed, defineAsyncComponent, toRef } from 'vue';
import { openInstanceMenu } from './common';
import * as os from '@/os';
import { navbarItemDef } from '@/navbar';
import { openAccountMenu as openAccountMenu_ } from '@/account';
import { $i, openAccountMenu as openAccountMenu_ } from '@/account';
import { defaultStore } from '@/store';
import { i18n } from '@/i18n';
import { instance } from '@/instance';

View file

@ -47,7 +47,7 @@ import { openInstanceMenu } from './_common_/common';
import { host } from '@/config';
import * as os from '@/os';
import { navbarItemDef } from '@/navbar';
import { openAccountMenu } from '@/account';
import { openAccountMenu, $i } from '@/account';
import MkButton from '@/components/MkButton.vue';
import { mainRouter } from '@/router';
import { defaultStore } from '@/store';
@ -67,6 +67,7 @@ export default defineComponent({
settingsWindowed: false,
defaultStore,
instance,
$i,
};
},

View file

@ -46,7 +46,7 @@ import { openInstanceMenu } from './_common_/common';
import { host } from '@/config';
import * as os from '@/os';
import { navbarItemDef } from '@/navbar';
import { openAccountMenu } from '@/account';
import { openAccountMenu, $i } from '@/account';
import MkButton from '@/components/MkButton.vue';
import { StickySidebar } from '@/scripts/sticky-sidebar';
import { mainRouter } from '@/router';
@ -70,6 +70,7 @@ export default defineComponent({
settingsWindowed: false,
defaultStore,
instance,
$i,
};
},