Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
84385067
Unverified
Commit
84385067
authored
Aug 06, 2023
by
boojack
Committed by
GitHub
Aug 06, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: update image displays (#2093)
parent
72630039
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
142 additions
and
368 deletions
+142
-368
package.json
web/package.json
+0
-3
pnpm-lock.yaml
web/pnpm-lock.yaml
+108
-345
Memo.tsx
web/src/components/Memo.tsx
+6
-9
MemoResourceListView.tsx
web/src/components/MemoResourceListView.tsx
+28
-11
No files found.
web/package.json
View file @
84385067
...
@@ -10,10 +10,7 @@
...
@@ -10,10 +10,7 @@
"dependencies"
:
{
"dependencies"
:
{
"@emotion/react"
:
"^11.11.1"
,
"@emotion/react"
:
"^11.11.1"
,
"@emotion/styled"
:
"^11.11.0"
,
"@emotion/styled"
:
"^11.11.0"
,
"@microsoft/fetch-event-source"
:
"^2.0.1"
,
"@mui/joy"
:
"5.0.0-beta.0"
,
"@mui/joy"
:
"5.0.0-beta.0"
,
"@mui/material"
:
"^5.14.2"
,
"@mui/styled-engine-sc"
:
"^5.12.0"
,
"@reduxjs/toolkit"
:
"^1.8.1"
,
"@reduxjs/toolkit"
:
"^1.8.1"
,
"axios"
:
"^0.27.2"
,
"axios"
:
"^0.27.2"
,
"classnames"
:
"^2.3.2"
,
"classnames"
:
"^2.3.2"
,
...
...
web/pnpm-lock.yaml
View file @
84385067
This diff is collapsed.
Click to expand it.
web/src/components/Memo.tsx
View file @
84385067
...
@@ -66,6 +66,7 @@ const Memo: React.FC<Props> = (props: Props) => {
...
@@ -66,6 +66,7 @@ const Memo: React.FC<Props> = (props: Props) => {
);
);
},
[
memo
.
relationList
]);
},
[
memo
.
relationList
]);
// Update display time string.
useEffect
(()
=>
{
useEffect
(()
=>
{
let
intervalFlag
:
any
=
-
1
;
let
intervalFlag
:
any
=
-
1
;
if
(
Date
.
now
()
-
memo
.
displayTs
<
1000
*
60
*
60
*
24
)
{
if
(
Date
.
now
()
-
memo
.
displayTs
<
1000
*
60
*
60
*
24
)
{
...
@@ -102,6 +103,11 @@ const Memo: React.FC<Props> = (props: Props) => {
...
@@ -102,6 +103,11 @@ const Memo: React.FC<Props> = (props: Props) => {
}
}
},
[
lazyRendering
]);
},
[
lazyRendering
]);
if
(
!
shouldRender
)
{
// Render a placeholder to occupy the space.
return
<
div
className=
{
`memo-wrapper min-h-[128px] ${"memos-" + memo.id}`
}
ref=
{
memoContainerRef
}
></
div
>;
}
const
handleTogglePinMemoBtnClick
=
async
()
=>
{
const
handleTogglePinMemoBtnClick
=
async
()
=>
{
try
{
try
{
if
(
memo
.
pinned
)
{
if
(
memo
.
pinned
)
{
...
@@ -246,15 +252,6 @@ const Memo: React.FC<Props> = (props: Props) => {
...
@@ -246,15 +252,6 @@ const Memo: React.FC<Props> = (props: Props) => {
}
}
};
};
if
(
!
shouldRender
)
{
return
(
<
div
className=
{
`memo-wrapper min-h-[128px] ${"memos-" + memo.id} ${memo.pinned && !readonly ? "pinned" : ""}`
}
ref=
{
memoContainerRef
}
></
div
>
);
}
return
(
return
(
<>
<>
<
div
className=
{
`memo-wrapper ${"memos-" + memo.id} ${memo.pinned && !readonly ? "pinned" : ""}`
}
ref=
{
memoContainerRef
}
>
<
div
className=
{
`memo-wrapper ${"memos-" + memo.id} ${memo.pinned && !readonly ? "pinned" : ""}`
}
ref=
{
memoContainerRef
}
>
...
...
web/src/components/MemoResourceListView.tsx
View file @
84385067
import
{
ImageList
,
ImageListItem
,
useMediaQuery
}
from
"@mui/material
"
;
import
classNames
from
"classnames
"
;
import
{
absolutifyLink
}
from
"@/helpers/utils"
;
import
{
absolutifyLink
}
from
"@/helpers/utils"
;
import
{
getResourceType
,
getResourceUrl
}
from
"@/utils/resource"
;
import
{
getResourceType
,
getResourceUrl
}
from
"@/utils/resource"
;
import
MemoResource
from
"./MemoResource"
;
import
MemoResource
from
"./MemoResource"
;
...
@@ -23,7 +23,6 @@ const MemoResourceListView: React.FC<Props> = (props: Props) => {
...
@@ -23,7 +23,6 @@ const MemoResourceListView: React.FC<Props> = (props: Props) => {
...
getDefaultProps
(),
...
getDefaultProps
(),
...
props
,
...
props
,
};
};
const
matches
=
useMediaQuery
(
"(min-width:640px)"
);
const
imageResourceList
=
resourceList
.
filter
((
resource
)
=>
getResourceType
(
resource
).
startsWith
(
"image"
));
const
imageResourceList
=
resourceList
.
filter
((
resource
)
=>
getResourceType
(
resource
).
startsWith
(
"image"
));
const
videoResourceList
=
resourceList
.
filter
((
resource
)
=>
resource
.
type
.
startsWith
(
"video"
));
const
videoResourceList
=
resourceList
.
filter
((
resource
)
=>
resource
.
type
.
startsWith
(
"video"
));
const
otherResourceList
=
resourceList
.
filter
(
const
otherResourceList
=
resourceList
.
filter
(
...
@@ -41,20 +40,38 @@ const MemoResourceListView: React.FC<Props> = (props: Props) => {
...
@@ -41,20 +40,38 @@ const MemoResourceListView: React.FC<Props> = (props: Props) => {
return
(
return
(
<>
<>
{
imageResourceList
.
length
>
0
&&
(
{
imageResourceList
.
length
>
0
&&
<
div
className=
"w-full mt-2"
>
(
imageResourceList
.
length
===
1
?
(
<
ImageList
variant=
"masonry"
cols=
{
matches
?
3
:
2
}
gap=
{
8
}
>
<
div
className=
"mt-2 max-w-[90%] max-h-64 flex justify-center items-center shadow rounded overflow-hidden hide-scrollbar hover:shadow-md"
>
<
img
className=
"cursor-pointer min-h-full w-auto min-w-full object-cover"
src=
{
getResourceUrl
(
imageResourceList
[
0
])
}
onClick=
{
()
=>
handleImageClick
(
getResourceUrl
(
imageResourceList
[
0
]))
}
decoding=
"async"
loading=
"lazy"
/>
</
div
>
)
:
(
<
div
className=
{
classNames
(
"w-full mt-2 grid gap-2 grid-cols-2 sm:grid-cols-3"
)
}
>
{
imageResourceList
.
map
((
resource
)
=>
{
{
imageResourceList
.
map
((
resource
)
=>
{
const
url
=
getResourceUrl
(
resource
);
const
url
=
getResourceUrl
(
resource
);
return
(
return
(
<
ImageListItem
onClick=
{
()
=>
handleImageClick
(
url
)
}
key=
{
resource
.
id
}
>
<
SquareDiv
<
img
className=
"shadow rounded"
src=
{
url
}
loading=
"lazy"
/>
key=
{
resource
.
id
}
</
ImageListItem
>
className=
"flex justify-center items-center shadow rounded overflow-hidden hide-scrollbar hover:shadow-md"
>
<
img
className=
"cursor-pointer min-h-full w-auto min-w-full object-cover"
src=
{
resource
.
externalLink
?
url
:
url
+
"?thumbnail=1"
}
onClick=
{
()
=>
handleImageClick
(
url
)
}
decoding=
"async"
loading=
"lazy"
/>
</
SquareDiv
>
);
);
})
}
})
}
</
ImageList
>
</
div
>
</
div
>
)
}
)
)
}
<
div
className=
{
`resource-wrapper ${className || ""}`
}
>
<
div
className=
{
`resource-wrapper ${className || ""}`
}
>
{
videoResourceList
.
length
>
0
&&
(
{
videoResourceList
.
length
>
0
&&
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment