Merge branch 'feat/1.0.7/ui' of github.com:answerdev/answer into feat/1.0.7/ui

This commit is contained in:
shuai 2023-03-10 11:51:24 +08:00
commit c9119e6cd2
6 changed files with 27 additions and 10 deletions

View File

@ -4,7 +4,6 @@ const pattern = {
emoji: emojiRegex(),
email:
/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+\.)+[a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}))$/,
isAnswerId: /^1002\d{13}$/,
};
export default pattern;

View File

@ -1,4 +1,4 @@
import { FC, useEffect } from 'react';
import { FC, useEffect, useLayoutEffect } from 'react';
import { Helmet } from 'react-helmet-async';
import { brandingStore, pageTagStore, siteInfoStore } from '@/stores';
@ -23,10 +23,21 @@ const Index: FC = () => {
);
}
};
const setDocTitle = () => {
try {
if (pageTitle) {
document.title = pageTitle;
}
// eslint-disable-next-line no-empty
} catch (ex) {}
};
useEffect(() => {
setAppGenerator();
}, [appVersion]);
useLayoutEffect(() => {
setDocTitle();
}, [pageTitle]);
return (
<Helmet>
<link

View File

@ -19,8 +19,13 @@ const Index: FC = () => {
type: 'number',
title: t('permalink.label'),
description: t('permalink.text'),
enum: [1, 2],
enumNames: ['/questions/123/post-title', '/questions/123'],
enum: [1, 2, 3, 4],
enumNames: [
'/questions/10020000009999999/post-title',
'/questions/10020000009999999',
'/questions/2jsXF/post-title',
'/questions/2jsXF',
],
default: 1,
},
robots: {
@ -74,7 +79,7 @@ const Index: FC = () => {
const formMeta = { ...formData };
formMeta.robots.value = setting.robots;
formMeta.permalink.value = setting.permalink;
if (formMeta.permalink.value !== 1 && formMeta.permalink.value !== 2) {
if (!/[1234]/.test(formMeta.permalink.value)) {
formMeta.permalink.value = 1;
}
setFormData(formMeta);

View File

@ -8,7 +8,6 @@ import {
} from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import Pattern from '@/common/pattern';
import { Pagination } from '@/components';
import { loggedUserInfoStore, toastStore } from '@/stores';
import { scrollToElementTop } from '@/utils';
@ -40,7 +39,7 @@ const Index = () => {
* Note: Compatible with Permalink
*/
let { aid = '' } = useParams();
if (!aid && Pattern.isAnswerId.test(slugPermalink)) {
if (!aid && slugPermalink) {
aid = slugPermalink;
}
@ -76,9 +75,10 @@ const Index = () => {
page: 1,
page_size: 999,
});
if (res) {
res.list = res.list?.filter((v) => {
// delete answers pnly show to author and admin and has searchparams aid
// delete answers only show to author and admin and has search params aid
if (v.status === 10) {
if (
(v?.user_info.username === userInfo?.username || isAdmin) &&

View File

@ -19,7 +19,8 @@ const tagEdit = (tagId: string) => {
};
const questionLanding = (questionId: string, slugTitle: string = '') => {
const { seo } = seoSettingStore.getState();
if (seo.permalink === 1 && slugTitle) {
// @ts-ignore
if (/[13]/.test(seo.permalink) && slugTitle) {
return urlcat('/questions/:questionId/:slugPermalink', {
questionId,
slugPermalink: slugTitle,

View File

@ -15,7 +15,8 @@ const siteInfo = create<IProps>((set) => ({
update: (params) =>
set((state) => {
const o = { ...state.seo, ...params };
if (o.permalink !== 1 && o.permalink !== 2) {
// @ts-ignore
if (!/[1234]/.test(o.permalink)) {
o.permalink = 1;
}
return {