Merge branch 'feat/ui-v0.4' of git.backyard.segmentfault.com:opensource/answer into feat/ui-v0.4

This commit is contained in:
shuai 2022-11-17 14:54:03 +08:00
commit 3770bce2a7
3 changed files with 6 additions and 4 deletions

View File

@ -337,6 +337,7 @@ export interface SearchResItem {
object_type: string; object_type: string;
object: { object: {
id: string; id: string;
question_id?: string;
title: string; title: string;
excerpt: string; excerpt: string;
created_at: number; created_at: number;

View File

@ -14,6 +14,10 @@ const Index: FC<Props> = ({ data }) => {
if (!data?.object_type) { if (!data?.object_type) {
return null; return null;
} }
let itemUrl = `/questions/${data.object.id}`;
if (data.object_type === 'answer') {
itemUrl = `/questions/${data.object.question_id}/${data.object.id}`;
}
return ( return (
<ListGroupItem className="py-3 px-0"> <ListGroupItem className="py-3 px-0">
<div className="mb-2 clearfix"> <div className="mb-2 clearfix">
@ -23,9 +27,7 @@ const Index: FC<Props> = ({ data }) => {
style={{ marginTop: '2px' }}> style={{ marginTop: '2px' }}>
{data.object_type === 'question' ? 'Q' : 'A'} {data.object_type === 'question' ? 'Q' : 'A'}
</Badge> </Badge>
<a <a className="h5 mb-0 link-dark text-break" href={itemUrl}>
className="h5 mb-0 link-dark text-break"
href={`/questions/${data.object.id}`}>
{data.object.title} {data.object.title}
{data.object.status === 'closed' {data.object.status === 'closed'
? ` [${t('closed', { keyPrefix: 'question' })}]` ? ` [${t('closed', { keyPrefix: 'question' })}]`

View File

@ -85,7 +85,6 @@ export const getCurrentLang = () => {
export const setupAppLanguage = async () => { export const setupAppLanguage = async () => {
const lang = getCurrentLang(); const lang = getCurrentLang();
console.log(lang);
if (!i18next.getDataByLanguage(lang)) { if (!i18next.getDataByLanguage(lang)) {
await addI18nResource(lang); await addI18nResource(lang);
} }