chore: fix memos amount

This commit is contained in:
boojack 2022-07-05 22:09:11 +08:00
parent 592e037f21
commit 0e8d3e6907
5 changed files with 26 additions and 30 deletions

View File

@ -19,7 +19,7 @@ interface Props {}
const MyAccountSection: React.FC<Props> = () => { const MyAccountSection: React.FC<Props> = () => {
const user = useAppSelector((state) => state.user.user as User); const user = useAppSelector((state) => state.user.user as User);
const [username, setUsername] = useState<string>(user.name); const [username, setUsername] = useState<string>(user.name);
const openAPIRoute = `${window.location.origin}/h/${user.openId}/memo`; const openAPIRoute = `${window.location.origin}/api/memo?openId=${user.openId}`;
const handleUsernameChanged = (e: React.ChangeEvent<HTMLInputElement>) => { const handleUsernameChanged = (e: React.ChangeEvent<HTMLInputElement>) => {
const nextUsername = e.target.value as string; const nextUsername = e.target.value as string;
@ -100,7 +100,7 @@ const MyAccountSection: React.FC<Props> = () => {
</span> </span>
<div className="usage-guide-container"> <div className="usage-guide-container">
<p className="title-text">Usage guide:</p> <p className="title-text">Usage guide:</p>
<pre>{`POST ${openAPIRoute}\nContent-type: application/json\n{\n "content": "Hello, #memos ${window.location.origin}"\n}`}</pre> <pre>{`POST ${openAPIRoute}\nContent-type: application/json\n{\n "content": "Hello #memos from ${window.location.origin}"\n}`}</pre>
</div> </div>
</div> </div>
</> </>

View File

@ -29,7 +29,7 @@
@apply flex flex-row justify-start items-center; @apply flex flex-row justify-start items-center;
> .action-btn { > .action-btn {
@apply flex flex-row justify-start items-center p-1 w-auto h-auto mr-1 select-none rounded cursor-pointer opacity-60 hover:opacity-80 hover:bg-gray-300 hover:shadow; @apply flex flex-row justify-start items-center p-1 w-auto h-auto mr-1 select-none rounded cursor-pointer opacity-60 hover:opacity-90 hover:bg-gray-300 hover:shadow;
> .icon-img { > .icon-img {
@apply w-5 h-auto; @apply w-5 h-auto;
@ -49,7 +49,7 @@
} }
> .tag-list { > .tag-list {
@apply hidden flex-col justify-start items-start absolute top-6 left-0 p-1 z-10 rounded w-32 max-h-52 overflow-auto bg-black; @apply hidden flex-col justify-start items-start absolute top-6 left-0 mt-1 p-1 z-10 rounded w-32 max-h-52 overflow-auto bg-black;
> span { > span {
@apply w-full text-white cursor-pointer rounded text-sm leading-6 px-2 hover:bg-gray-700; @apply w-full text-white cursor-pointer rounded text-sm leading-6 px-2 hover:bg-gray-700;

View File

@ -4,7 +4,7 @@
@apply px-4; @apply px-4;
> .dialog-container { > .dialog-container {
@apply w-176 max-w-full mb-8 p-0; @apply w-180 max-w-full mb-8 p-0;
> .dialog-content-container { > .dialog-content-container {
.flex(column, flex-start, flex-start); .flex(column, flex-start, flex-start);
@ -38,7 +38,7 @@
} }
> .icon-text { > .icon-text {
@apply text-base mr-1; @apply text-base mr-2;
} }
} }
} }

View File

@ -15,13 +15,7 @@ const memoSlice = createSlice({
setMemos: (state, action: PayloadAction<Memo[]>) => { setMemos: (state, action: PayloadAction<Memo[]>) => {
return { return {
...state, ...state,
memos: action.payload, memos: action.payload.filter((m) => m.rowStatus === "NORMAL").sort((a, b) => b.createdTs - a.createdTs),
};
},
setTags: (state, action: PayloadAction<string[]>) => {
return {
...state,
tags: action.payload,
}; };
}, },
createMemo: (state, action: PayloadAction<Memo>) => { createMemo: (state, action: PayloadAction<Memo>) => {
@ -33,16 +27,24 @@ const memoSlice = createSlice({
patchMemo: (state, action: PayloadAction<Partial<Memo>>) => { patchMemo: (state, action: PayloadAction<Partial<Memo>>) => {
return { return {
...state, ...state,
memos: state.memos.map((m) => { memos: state.memos
if (m.id === action.payload.id) { .map((memo) => {
return { if (memo.id === action.payload.id) {
...m, return {
...action.payload, ...memo,
}; ...action.payload,
} else { };
return m; } else {
} return memo;
}), }
})
.filter((memo) => memo.rowStatus === "NORMAL"),
};
},
setTags: (state, action: PayloadAction<string[]>) => {
return {
...state,
tags: action.payload,
}; };
}, },
}, },

View File

@ -16,18 +16,12 @@ module.exports = {
spacing: { spacing: {
112: "28rem", 112: "28rem",
128: "32rem", 128: "32rem",
168: "42rem", 180: "45rem",
176: "44rem",
200: "50rem",
}, },
zIndex: { zIndex: {
100: "100", 100: "100",
1000: "1000", 1000: "1000",
}, },
gridTemplateRows: {
7: "repeat(7, minmax(0, 1fr))",
},
}, },
}, },
plugins: [],
}; };