This commit is contained in:
syuilo 2022-03-01 21:36:20 +09:00
parent 645dbebd86
commit b80ec1fa3f
9 changed files with 40 additions and 47 deletions

View File

@ -57,7 +57,7 @@ const lib = emojilist.filter(x => x.category !== 'flags');
const char2file = (char: string) => { const char2file = (char: string) => {
let codes = Array.from(char).map(x => x.codePointAt(0)?.toString(16)); let codes = Array.from(char).map(x => x.codePointAt(0)?.toString(16));
if (!codes.includes('200d')) codes = codes.filter(x => x != 'fe0f'); if (!codes.includes('200d')) codes = codes.filter(x => x !== 'fe0f');
return codes.filter(x => x && x.length).join('-'); return codes.filter(x => x && x.length).join('-');
}; };
@ -208,7 +208,7 @@ function exec() {
}); });
} }
} else if (props.type === 'hashtag') { } else if (props.type === 'hashtag') {
if (!props.q || props.q == '') { if (!props.q || props.q === '') {
hashtags.value = JSON.parse(localStorage.getItem('hashtags') || '[]'); hashtags.value = JSON.parse(localStorage.getItem('hashtags') || '[]');
fetching.value = false; fetching.value = false;
} else { } else {
@ -231,7 +231,7 @@ function exec() {
} }
} }
} else if (props.type === 'emoji') { } else if (props.type === 'emoji') {
if (!props.q || props.q == '') { if (!props.q || props.q === '') {
// 使 // 使
emojis.value = defaultStore.state.recentlyUsedEmojis.map(emoji => emojiDb.find(e => e.emoji == emoji)).filter(x => x) as EmojiDef[]; emojis.value = defaultStore.state.recentlyUsedEmojis.map(emoji => emojiDb.find(e => e.emoji == emoji)).filter(x => x) as EmojiDef[];
return; return;
@ -241,37 +241,37 @@ function exec() {
const max = 30; const max = 30;
emojiDb.some(x => { emojiDb.some(x => {
if (x.name.startsWith(props.q || '') && !x.aliasOf && !matched.some(y => y.emoji == x.emoji)) matched.push(x); if (x.name.startsWith(props.q ?? '') && !x.aliasOf && !matched.some(y => y.emoji === x.emoji)) matched.push(x);
return matched.length == max; return matched.length === max;
}); });
if (matched.length < max) { if (matched.length < max) {
emojiDb.some(x => { emojiDb.some(x => {
if (x.name.startsWith(props.q || '') && !matched.some(y => y.emoji == x.emoji)) matched.push(x); if (x.name.startsWith(props.q ?? '') && !matched.some(y => y.emoji === x.emoji)) matched.push(x);
return matched.length == max; return matched.length === max;
}); });
} }
if (matched.length < max) { if (matched.length < max) {
emojiDb.some(x => { emojiDb.some(x => {
if (x.name.includes(props.q || '') && !matched.some(y => y.emoji == x.emoji)) matched.push(x); if (x.name.includes(props.q ?? '') && !matched.some(y => y.emoji === x.emoji)) matched.push(x);
return matched.length == max; return matched.length === max;
}); });
} }
emojis.value = matched; emojis.value = matched;
} else if (props.type === 'mfmTag') { } else if (props.type === 'mfmTag') {
if (!props.q || props.q == '') { if (!props.q || props.q === '') {
mfmTags.value = MFM_TAGS; mfmTags.value = MFM_TAGS;
return; return;
} }
mfmTags.value = MFM_TAGS.filter(tag => tag.startsWith(props.q || '')); mfmTags.value = MFM_TAGS.filter(tag => tag.startsWith(props.q ?? ''));
} }
} }
function onMousedown(e: Event) { function onMousedown(e: Event) {
if (!contains(rootEl.value, e.target) && (rootEl.value != e.target)) props.close(); if (!contains(rootEl.value, e.target) && (rootEl.value !== e.target)) props.close();
} }
function onKeydown(e: KeyboardEvent) { function onKeydown(e: KeyboardEvent) {
@ -348,7 +348,7 @@ function chooseUser() {
onUpdated(() => { onUpdated(() => {
setPosition(); setPosition();
items.value = suggests.value?.children || []; items.value = suggests.value?.children ?? [];
}); });
onMounted(() => { onMounted(() => {

View File

@ -93,7 +93,7 @@ function requestRender() {
} }
function callback(response?: string) { function callback(response?: string) {
emit('update:modelValue', typeof response == 'string' ? response : null); emit('update:modelValue', typeof response === 'string' ? response : null);
} }
onMounted(() => { onMounted(() => {

View File

@ -53,8 +53,8 @@ export default defineComponent({
if (el.key == null && item.id) el.key = item.id; if (el.key == null && item.id) el.key = item.id;
if ( if (
i != props.items.length - 1 && i !== props.items.length - 1 &&
new Date(item.createdAt).getDate() != new Date(props.items[i + 1].createdAt).getDate() new Date(item.createdAt).getDate() !== new Date(props.items[i + 1].createdAt).getDate()
) { ) {
const separator = h('div', { const separator = h('div', {
class: 'separator', class: 'separator',

View File

@ -45,7 +45,7 @@ export default defineComponent({
}, },
render() { render() {
if (this.text == null || this.text == '') return; if (this.text == null || this.text === '') return;
const ast = (this.plain ? mfm.parsePlain : mfm.parse)(this.text, { fnNameList: MFM_TAGS }); const ast = (this.plain ? mfm.parsePlain : mfm.parse)(this.text, { fnNameList: MFM_TAGS });

View File

@ -6,33 +6,26 @@
</div> </div>
</template> </template>
<script lang="ts"> <script lang="ts" setup>
import { defineComponent } from 'vue'; import { onMounted } from 'vue';
import XNotification from './notification.vue'; import XNotification from './notification.vue';
import * as os from '@/os'; import * as os from '@/os';
export default defineComponent({ defineProps<{
components: { notification: any; // TODO
XNotification }>();
},
props: { const emit = defineEmits<{
notification: { (ev: 'closed'): void;
type: Object, }>();
required: true
} const zIndex = os.claimZIndex('high');
}, let showing = $ref(true);
emits: ['closed'],
data() { onMounted(() => {
return { window.setTimeout(() => {
showing: true, showing = false;
zIndex: os.claimZIndex('high'), }, 6000);
};
},
mounted() {
window.setTimeout(() => {
this.showing = false;
}, 6000);
}
}); });
</script> </script>

View File

@ -22,12 +22,12 @@ const emit = defineEmits<{
(e: 'closed'): void; (e: 'closed'): void;
}>(); }>();
const showing = ref(true);
const zIndex = os.claimZIndex('high'); const zIndex = os.claimZIndex('high');
let showing = $ref(true);
onMounted(() => { onMounted(() => {
window.setTimeout(() => { window.setTimeout(() => {
showing.value = false; showing = false;
}, 4000); }, 4000);
}); });
</script> </script>

View File

@ -67,7 +67,7 @@ let tweetHeight = $ref(150);
const requestUrl = new URL(props.url); const requestUrl = new URL(props.url);
if (requestUrl.hostname == 'twitter.com') { if (requestUrl.hostname === 'twitter.com') {
const m = requestUrl.pathname.match(/^\/.+\/status(?:es)?\/(\d+)/); const m = requestUrl.pathname.match(/^\/.+\/status(?:es)?\/(\d+)/);
if (m) tweetId = m[1]; if (m) tweetId = m[1];
} }

View File

@ -544,7 +544,7 @@ export const uploads = ref<{
}[]>([]); }[]>([]);
export function upload(file: File, folder?: any, name?: string, keepOriginal: boolean = defaultStore.state.keepOriginalUploading): Promise<Misskey.entities.DriveFile> { export function upload(file: File, folder?: any, name?: string, keepOriginal: boolean = defaultStore.state.keepOriginalUploading): Promise<Misskey.entities.DriveFile> {
if (folder && typeof folder == 'object') folder = folder.id; if (folder && typeof folder === 'object') folder = folder.id;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const id = Math.random().toString(); const id = Math.random().toString();

View File

@ -123,8 +123,8 @@ export default defineComponent({
const installedThemes = ref(getThemes()); const installedThemes = ref(getThemes());
const themes = computed(() => builtinThemes.concat(installedThemes.value)); const themes = computed(() => builtinThemes.concat(installedThemes.value));
const darkThemes = computed(() => themes.value.filter(t => t.base == 'dark' || t.kind == 'dark')); const darkThemes = computed(() => themes.value.filter(t => t.base === 'dark' || t.kind === 'dark'));
const lightThemes = computed(() => themes.value.filter(t => t.base == 'light' || t.kind == 'light')); const lightThemes = computed(() => themes.value.filter(t => t.base === 'light' || t.kind === 'light'));
const darkTheme = ColdDeviceStorage.ref('darkTheme'); const darkTheme = ColdDeviceStorage.ref('darkTheme');
const darkThemeId = computed({ const darkThemeId = computed({
get() { get() {