client: remove scripts/search

This commit is contained in:
Johann150 2022-11-19 19:21:06 +01:00
parent 7ffe2181a9
commit d86f826458
Signed by untrusted user: Johann150
GPG key ID: 9EE6577A2A06F8F1
5 changed files with 9 additions and 71 deletions

View file

@ -30,8 +30,8 @@ import * as sound from '@/scripts/sound';
import { $i, refreshAccount, login, updateAccount, signout } from '@/account';
import { defaultStore, ColdDeviceStorage } from '@/store';
import { fetchInstance, instance } from '@/instance';
import { mainRouter } from '@/router';
import { makeHotkey } from '@/scripts/hotkey';
import { search } from '@/scripts/search';
import { deviceKind } from '@/scripts/device-kind';
import { initializeSw } from '@/scripts/initialize-sw';
import { reloadChannel } from '@/scripts/unison-reload';
@ -332,7 +332,9 @@ import { getAccountFromId } from '@/scripts/get-account-from-id';
'd': (): void => {
defaultStore.set('darkMode', !defaultStore.state.darkMode);
},
's': search,
's': (): void => {
mainRouter.push('/search');
},
};
if ($i) {

View file

@ -1,7 +1,6 @@
import { computed, ref, reactive } from 'vue';
import { $i } from '@/account';
import { mainRouter } from '@/router';
import { search } from '@/scripts/search';
import * as os from '@/os';
import { i18n } from '@/i18n';
import { ui } from '@/config';
@ -49,7 +48,7 @@ export const menuDef = reactive({
search: {
title: 'search',
icon: 'fas fa-search',
action: () => search(),
to: '/search',
},
lists: {
title: 'lists',

View file

@ -1,63 +0,0 @@
import * as os from '@/os';
import { i18n } from '@/i18n';
import { mainRouter } from '@/router';
export async function search() {
const { canceled, result: query } = await os.inputText({
title: i18n.ts.search,
});
if (canceled || query == null || query === '') return;
const q = query.trim();
if (q.startsWith('@') && !q.includes(' ')) {
mainRouter.push(`/${q}`);
return;
}
if (q.startsWith('#')) {
mainRouter.push(`/tags/${encodeURIComponent(q.substr(1))}`);
return;
}
// like 2018/03/12
if (/^[0-9]{4}\/[0-9]{2}\/[0-9]{2}/.test(q.replace(/-/g, '/'))) {
const date = new Date(q.replace(/-/g, '/'));
// 日付しか指定されてない場合、例えば 2018/03/12 ならユーザーは
// 2018/03/12 のコンテンツを「含む」結果になることを期待するはずなので
// 23時間59分進める(そのままだと 2018/03/12 00:00:00 「まで」の
// 結果になってしまい、2018/03/12 のコンテンツは含まれない)
if (q.replace(/-/g, '/').match(/^[0-9]{4}\/[0-9]{2}\/[0-9]{2}$/)) {
date.setHours(23, 59, 59, 999);
}
// TODO
//v.$root.$emit('warp', date);
os.alert({
icon: 'fas fa-history',
iconOnly: true, autoClose: true,
});
return;
}
if (q.startsWith('https://')) {
const promise = os.api('ap/show', {
uri: q,
});
os.promiseDialog(promise, null, null, i18n.ts.fetchingAsApObject);
const res = await promise;
if (res.type === 'User') {
mainRouter.push(`/@${res.object.username}@${res.object.host}`);
} else if (res.type === 'Note') {
mainRouter.push(`/notes/${res.object.id}`);
}
return;
}
mainRouter.push(`/search?q=${encodeURIComponent(q)}`);
}

View file

@ -50,7 +50,6 @@ import { ComputedRef, onMounted, provide } from 'vue';
import XHeader from './header.vue';
import XKanban from './kanban.vue';
import { host, instanceName } from '@/config';
import { search } from '@/scripts/search';
import * as os from '@/os';
import MkPagination from '@/components/ui/pagination.vue';
import XSigninDialog from '@/components/signin-dialog.vue';
@ -87,7 +86,9 @@ const keymap = $computed(() => {
if (ColdDeviceStorage.get('syncDeviceDarkMode')) return;
defaultStore.set('darkMode', !defaultStore.state.darkMode);
},
's': search,
's': () => {
mainRouter.push('/search');
},
};
});

View file

@ -18,7 +18,7 @@
</button>
</div>
<div class="right">
<button class="_button search" @click="search()"><i class="fas fa-search icon"></i><span>{{ i18n.ts.search }}</span></button>
<MkA to="/search" class="link search" active-class="active"><i class="fas fa-search icon"></i><span>{{ i18n.ts.search }}</span></MkA>
<button class="_buttonPrimary signup" @click="signup()">{{ i18n.ts.signup }}</button>
<button class="_button login" @click="signin()">{{ i18n.ts.login }}</button>
</div>
@ -46,7 +46,6 @@ import { onMounted, ref, Ref } from 'vue';
import XSigninDialog from '@/components/signin-dialog.vue';
import XSignupDialog from '@/components/signup-dialog.vue';
import * as os from '@/os';
import { search } from '@/scripts/search';
import { i18n } from '@/i18n';
defineProps<{