mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-27 09:13:09 +02:00
[Client] Resolve #3686
This commit is contained in:
parent
d059d7f972
commit
a5f09c90dd
2 changed files with 41 additions and 5 deletions
|
@ -14,16 +14,34 @@ export default Vue.extend({
|
|||
i18n: i18n('desktop/views/components/ui.header.search.vue'),
|
||||
data() {
|
||||
return {
|
||||
q: ''
|
||||
q: '',
|
||||
wait: false
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
onSubmit() {
|
||||
async onSubmit() {
|
||||
if (this.wait) return;
|
||||
|
||||
const q = this.q.trim();
|
||||
if (q.startsWith('@')) {
|
||||
this.$router.push(`/${q}`);
|
||||
} else if (q.startsWith('#')) {
|
||||
this.$router.push(`/tags/${encodeURIComponent(q.substr(1))}`);
|
||||
} else if (q.startsWith('https://')) {
|
||||
this.wait = true;
|
||||
try {
|
||||
const res = await this.$root.api('ap/show', {
|
||||
uri: q
|
||||
});
|
||||
if (res.type == 'User') {
|
||||
this.$router.push(`/@${res.object.username}@${res.object.host}`);
|
||||
} else if (res.type == 'Note') {
|
||||
this.$router.push(`/notes/${res.object.id}`);
|
||||
}
|
||||
} catch (e) {
|
||||
// TODO
|
||||
}
|
||||
this.wait = false;
|
||||
} else {
|
||||
this.$router.push(`/search?q=${encodeURIComponent(q)}`);
|
||||
}
|
||||
|
|
|
@ -60,7 +60,8 @@ export default Vue.extend({
|
|||
hasGameInvitation: false,
|
||||
connection: null,
|
||||
aboutUrl: `/docs/${lang}/about`,
|
||||
announcements: []
|
||||
announcements: [],
|
||||
searching: false,
|
||||
};
|
||||
},
|
||||
|
||||
|
@ -95,17 +96,34 @@ export default Vue.extend({
|
|||
|
||||
methods: {
|
||||
search() {
|
||||
if (this.searching) return;
|
||||
|
||||
this.$root.dialog({
|
||||
title: this.$t('search'),
|
||||
input: true
|
||||
}).then(({ canceled, result: query }) => {
|
||||
}).then(async ({ canceled, result: query }) => {
|
||||
if (canceled) return;
|
||||
|
||||
const q = query.trim();
|
||||
const q = this.q.trim();
|
||||
if (q.startsWith('@')) {
|
||||
this.$router.push(`/${q}`);
|
||||
} else if (q.startsWith('#')) {
|
||||
this.$router.push(`/tags/${encodeURIComponent(q.substr(1))}`);
|
||||
} else if (q.startsWith('https://')) {
|
||||
this.searching = true;
|
||||
try {
|
||||
const res = await this.$root.api('ap/show', {
|
||||
uri: q
|
||||
});
|
||||
if (res.type == 'User') {
|
||||
this.$router.push(`/@${res.object.username}@${res.object.host}`);
|
||||
} else if (res.type == 'Note') {
|
||||
this.$router.push(`/notes/${res.object.id}`);
|
||||
}
|
||||
} catch (e) {
|
||||
// TODO
|
||||
}
|
||||
this.searching = false;
|
||||
} else {
|
||||
this.$router.push(`/search?q=${encodeURIComponent(q)}`);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue