Merge pull request #248 from answerdev/feat/1.0.7/ui

Feat/1.0.7/UI
This commit is contained in:
haitao.jarvis 2023-03-09 14:46:59 +08:00 committed by GitHub
commit a322e16d40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 5 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

@ -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;
}
@ -56,7 +55,7 @@ const Index = () => {
const { setUsers } = usePageUsers();
const userInfo = loggedUserInfoStore((state) => state.user);
const isAuthor = userInfo?.username === question?.user_info?.username;
const isAdmin = userInfo?.is_admin;
const isAdmin = userInfo?.role_id === 2;
const isLogged = Boolean(userInfo?.access_token);
const { state: locationState } = useLocation();
@ -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) &&