mirror of
https://github.com/usememos/memos.git
synced 2025-03-27 08:00:13 +01:00
chore: fix some typos (#587)
This commit is contained in:
parent
1ee8ebc9e1
commit
54271c1598
api
server
store
web/src
components
AboutSiteDialog.tsxCreateShortcutDialog.tsxMemoEditor.tsxMemoResources.tsxMemosHeader.tsxResourcesDialog.tsxSidebar.tsxToast.tsxUsageHeatMap.tsx
common
hooks
labs/marked/parser
less
pages
services
types
@ -8,8 +8,8 @@ const (
|
|||||||
Public Visibility = "PUBLIC"
|
Public Visibility = "PUBLIC"
|
||||||
// Protected is the PROTECTED visibility.
|
// Protected is the PROTECTED visibility.
|
||||||
Protected Visibility = "PROTECTED"
|
Protected Visibility = "PROTECTED"
|
||||||
// Privite is the PRIVATE visibility.
|
// Private is the PRIVATE visibility.
|
||||||
Privite Visibility = "PRIVATE"
|
Private Visibility = "PRIVATE"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (e Visibility) String() string {
|
func (e Visibility) String() string {
|
||||||
@ -18,7 +18,7 @@ func (e Visibility) String() string {
|
|||||||
return "PUBLIC"
|
return "PUBLIC"
|
||||||
case Protected:
|
case Protected:
|
||||||
return "PROTECTED"
|
return "PROTECTED"
|
||||||
case Privite:
|
case Private:
|
||||||
return "PRIVATE"
|
return "PRIVATE"
|
||||||
}
|
}
|
||||||
return "PRIVATE"
|
return "PRIVATE"
|
||||||
|
@ -31,7 +31,7 @@ func (key UserSettingKey) String() string {
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
UserSettingLocaleValue = []string{"en", "zh", "vi", "fr"}
|
UserSettingLocaleValue = []string{"en", "zh", "vi", "fr"}
|
||||||
UserSettingMemoVisibilityValue = []Visibility{Privite, Protected, Public}
|
UserSettingMemoVisibilityValue = []Visibility{Private, Protected, Public}
|
||||||
UserSettingEditorFontStyleValue = []string{"normal", "mono"}
|
UserSettingEditorFontStyleValue = []string{"normal", "mono"}
|
||||||
UserSettingMemoDisplayTsOptionKeyValue = []string{"created_ts", "updated_ts"}
|
UserSettingMemoDisplayTsOptionKeyValue = []string{"created_ts", "updated_ts"}
|
||||||
)
|
)
|
||||||
@ -68,7 +68,7 @@ func (upsert UserSettingUpsert) Validate() error {
|
|||||||
return fmt.Errorf("invalid user setting locale value")
|
return fmt.Errorf("invalid user setting locale value")
|
||||||
}
|
}
|
||||||
} else if upsert.Key == UserSettingMemoVisibilityKey {
|
} else if upsert.Key == UserSettingMemoVisibilityKey {
|
||||||
memoVisibilityValue := Privite
|
memoVisibilityValue := Private
|
||||||
err := json.Unmarshal([]byte(upsert.Value), &memoVisibilityValue)
|
err := json.Unmarshal([]byte(upsert.Value), &memoVisibilityValue)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to unmarshal user setting memo visibility value")
|
return fmt.Errorf("failed to unmarshal user setting memo visibility value")
|
||||||
|
@ -45,7 +45,7 @@ func (s *Server) registerMemoRoutes(g *echo.Group) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if userMemoVisibilitySetting != nil {
|
if userMemoVisibilitySetting != nil {
|
||||||
memoVisibility := api.Privite
|
memoVisibility := api.Private
|
||||||
err := json.Unmarshal([]byte(userMemoVisibilitySetting.Value), &memoVisibility)
|
err := json.Unmarshal([]byte(userMemoVisibilitySetting.Value), &memoVisibility)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to unmarshal user setting value").SetInternal(err)
|
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to unmarshal user setting value").SetInternal(err)
|
||||||
@ -53,7 +53,7 @@ func (s *Server) registerMemoRoutes(g *echo.Group) {
|
|||||||
memoCreate.Visibility = memoVisibility
|
memoCreate.Visibility = memoVisibility
|
||||||
} else {
|
} else {
|
||||||
// Private is the default memo visibility.
|
// Private is the default memo visibility.
|
||||||
memoCreate.Visibility = api.Privite
|
memoCreate.Visibility = api.Private
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,10 +176,10 @@ func (s *Server) registerMemoRoutes(g *echo.Group) {
|
|||||||
contentSearch := "#" + tag + " "
|
contentSearch := "#" + tag + " "
|
||||||
memoFind.ContentSearch = &contentSearch
|
memoFind.ContentSearch = &contentSearch
|
||||||
}
|
}
|
||||||
visibilitListStr := c.QueryParam("visibility")
|
visibilityListStr := c.QueryParam("visibility")
|
||||||
if visibilitListStr != "" {
|
if visibilityListStr != "" {
|
||||||
visibilityList := []api.Visibility{}
|
visibilityList := []api.Visibility{}
|
||||||
for _, visibility := range strings.Split(visibilitListStr, ",") {
|
for _, visibility := range strings.Split(visibilityListStr, ",") {
|
||||||
visibilityList = append(visibilityList, api.Visibility(visibility))
|
visibilityList = append(visibilityList, api.Visibility(visibility))
|
||||||
}
|
}
|
||||||
memoFind.VisibilityList = visibilityList
|
memoFind.VisibilityList = visibilityList
|
||||||
@ -271,7 +271,7 @@ func (s *Server) registerMemoRoutes(g *echo.Group) {
|
|||||||
if *memoFind.CreatorID != currentUserID {
|
if *memoFind.CreatorID != currentUserID {
|
||||||
memoFind.VisibilityList = []api.Visibility{api.Public, api.Protected}
|
memoFind.VisibilityList = []api.Visibility{api.Public, api.Protected}
|
||||||
} else {
|
} else {
|
||||||
memoFind.VisibilityList = []api.Visibility{api.Public, api.Protected, api.Privite}
|
memoFind.VisibilityList = []api.Visibility{api.Public, api.Protected, api.Private}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -313,10 +313,10 @@ func (s *Server) registerMemoRoutes(g *echo.Group) {
|
|||||||
contentSearch := "#" + tag + " "
|
contentSearch := "#" + tag + " "
|
||||||
memoFind.ContentSearch = &contentSearch
|
memoFind.ContentSearch = &contentSearch
|
||||||
}
|
}
|
||||||
visibilitListStr := c.QueryParam("visibility")
|
visibilityListStr := c.QueryParam("visibility")
|
||||||
if visibilitListStr != "" {
|
if visibilityListStr != "" {
|
||||||
visibilityList := []api.Visibility{}
|
visibilityList := []api.Visibility{}
|
||||||
for _, visibility := range strings.Split(visibilitListStr, ",") {
|
for _, visibility := range strings.Split(visibilityListStr, ",") {
|
||||||
visibilityList = append(visibilityList, api.Visibility(visibility))
|
visibilityList = append(visibilityList, api.Visibility(visibility))
|
||||||
}
|
}
|
||||||
memoFind.VisibilityList = visibilityList
|
memoFind.VisibilityList = visibilityList
|
||||||
@ -372,7 +372,7 @@ func (s *Server) registerMemoRoutes(g *echo.Group) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
userID, ok := c.Get(getUserIDContextKey()).(int)
|
userID, ok := c.Get(getUserIDContextKey()).(int)
|
||||||
if memo.Visibility == api.Privite {
|
if memo.Visibility == api.Private {
|
||||||
if !ok || memo.CreatorID != userID {
|
if !ok || memo.CreatorID != userID {
|
||||||
return echo.NewHTTPError(http.StatusForbidden, "this memo is private only")
|
return echo.NewHTTPError(http.StatusForbidden, "this memo is private only")
|
||||||
}
|
}
|
||||||
|
@ -93,13 +93,13 @@ func (s *Server) registerResourceRoutes(g *echo.Group) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, resource := range list {
|
for _, resource := range list {
|
||||||
memoResoureceList, err := s.Store.FindMemoResourceList(ctx, &api.MemoResourceFind{
|
memoResourceList, err := s.Store.FindMemoResourceList(ctx, &api.MemoResourceFind{
|
||||||
ResourceID: &resource.ID,
|
ResourceID: &resource.ID,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to find memo resource list").SetInternal(err)
|
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to find memo resource list").SetInternal(err)
|
||||||
}
|
}
|
||||||
resource.LinkedMemoAmount = len(memoResoureceList)
|
resource.LinkedMemoAmount = len(memoResourceList)
|
||||||
}
|
}
|
||||||
|
|
||||||
c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)
|
c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)
|
||||||
|
@ -49,7 +49,7 @@ func (s *Store) Vacuum(ctx context.Context) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Exec vacuum records in a transcation.
|
// Exec vacuum records in a transaction.
|
||||||
func vacuum(ctx context.Context, tx *sql.Tx) error {
|
func vacuum(ctx context.Context, tx *sql.Tx) error {
|
||||||
if err := vacuumMemo(ctx, tx); err != nil {
|
if err := vacuumMemo(ctx, tx); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -30,7 +30,7 @@ const AboutSiteDialog: React.FC<Props> = ({ destroy }: Props) => {
|
|||||||
<img className="logo-img" src="/logo-full.webp" alt="" />
|
<img className="logo-img" src="/logo-full.webp" alt="" />
|
||||||
<p>{t("slogan")}</p>
|
<p>{t("slogan")}</p>
|
||||||
<br />
|
<br />
|
||||||
<div className="addtion-info-container">
|
<div className="addition-info-container">
|
||||||
<GitHubBadge />
|
<GitHubBadge />
|
||||||
<>
|
<>
|
||||||
{t("common.version")}:
|
{t("common.version")}:
|
||||||
|
@ -192,7 +192,7 @@ const MemoFilterInputer: React.FC<MemoFilterInputerProps> = (props: MemoFilterIn
|
|||||||
if (["AND", "OR"].includes(value)) {
|
if (["AND", "OR"].includes(value)) {
|
||||||
handleFilterChange(index, {
|
handleFilterChange(index, {
|
||||||
...filter,
|
...filter,
|
||||||
relation: value as MemoFilterRalation,
|
relation: value as MemoFilterRelation,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -53,7 +53,7 @@ const MemoEditor = () => {
|
|||||||
const [allowSave, setAllowSave] = useState<boolean>(false);
|
const [allowSave, setAllowSave] = useState<boolean>(false);
|
||||||
const prevGlobalStateRef = useRef(editorState);
|
const prevGlobalStateRef = useRef(editorState);
|
||||||
const editorRef = useRef<EditorRefActions>(null);
|
const editorRef = useRef<EditorRefActions>(null);
|
||||||
const tagSeletorRef = useRef<HTMLDivElement>(null);
|
const tagSelectorRef = useRef<HTMLDivElement>(null);
|
||||||
const memoVisibilityOptionSelectorItems = VISIBILITY_SELECTOR_ITEMS.map((item) => {
|
const memoVisibilityOptionSelectorItems = VISIBILITY_SELECTOR_ITEMS.map((item) => {
|
||||||
return {
|
return {
|
||||||
value: item.value,
|
value: item.value,
|
||||||
@ -337,8 +337,8 @@ const MemoEditor = () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleTagSeletorClick = useCallback((event: React.MouseEvent) => {
|
const handleTagSelectorClick = useCallback((event: React.MouseEvent) => {
|
||||||
if (tagSeletorRef.current !== event.target && tagSeletorRef.current?.contains(event.target as Node)) {
|
if (tagSelectorRef.current !== event.target && tagSelectorRef.current?.contains(event.target as Node)) {
|
||||||
editorRef.current?.insertText(`#${(event.target as HTMLElement).textContent} ` ?? "");
|
editorRef.current?.insertText(`#${(event.target as HTMLElement).textContent} ` ?? "");
|
||||||
handleEditorFocus();
|
handleEditorFocus();
|
||||||
}
|
}
|
||||||
@ -415,7 +415,7 @@ const MemoEditor = () => {
|
|||||||
<div className="common-tools-container">
|
<div className="common-tools-container">
|
||||||
<div className="action-btn tag-action">
|
<div className="action-btn tag-action">
|
||||||
<Icon.Hash className="icon-img" />
|
<Icon.Hash className="icon-img" />
|
||||||
<div ref={tagSeletorRef} className="tag-list" onClick={handleTagSeletorClick}>
|
<div ref={tagSelectorRef} className="tag-list" onClick={handleTagSelectorClick}>
|
||||||
{tags.length > 0 ? (
|
{tags.length > 0 ? (
|
||||||
tags.map((tag) => {
|
tags.map((tag) => {
|
||||||
return (
|
return (
|
||||||
|
@ -24,7 +24,7 @@ const MemoResources: React.FC<Props> = (props: Props) => {
|
|||||||
const availableResourceList = resourceList.filter((resource) => resource.type.startsWith("image") || resource.type.startsWith("video"));
|
const availableResourceList = resourceList.filter((resource) => resource.type.startsWith("image") || resource.type.startsWith("video"));
|
||||||
const otherResourceList = resourceList.filter((resource) => !availableResourceList.includes(resource));
|
const otherResourceList = resourceList.filter((resource) => !availableResourceList.includes(resource));
|
||||||
|
|
||||||
const handlPreviewBtnClick = (resource: Resource) => {
|
const handlePreviewBtnClick = (resource: Resource) => {
|
||||||
const resourceUrl = `${window.location.origin}/o/r/${resource.id}/${resource.filename}`;
|
const resourceUrl = `${window.location.origin}/o/r/${resource.id}/${resource.filename}`;
|
||||||
window.open(resourceUrl);
|
window.open(resourceUrl);
|
||||||
};
|
};
|
||||||
@ -54,7 +54,7 @@ const MemoResources: React.FC<Props> = (props: Props) => {
|
|||||||
<div className="other-resource-wrapper">
|
<div className="other-resource-wrapper">
|
||||||
{otherResourceList.map((resource) => {
|
{otherResourceList.map((resource) => {
|
||||||
return (
|
return (
|
||||||
<div className="other-resource-container" key={resource.id} onClick={() => handlPreviewBtnClick(resource)}>
|
<div className="other-resource-container" key={resource.id} onClick={() => handlePreviewBtnClick(resource)}>
|
||||||
<Icon.FileText className="icon-img" />
|
<Icon.FileText className="icon-img" />
|
||||||
<span className="name-text">{resource.filename}</span>
|
<span className="name-text">{resource.filename}</span>
|
||||||
</div>
|
</div>
|
||||||
|
@ -3,7 +3,7 @@ import { memoService, shortcutService } from "../services";
|
|||||||
import { useAppSelector } from "../store";
|
import { useAppSelector } from "../store";
|
||||||
import Icon from "./Icon";
|
import Icon from "./Icon";
|
||||||
import SearchBar from "./SearchBar";
|
import SearchBar from "./SearchBar";
|
||||||
import { toggleSiderbar } from "./Sidebar";
|
import { toggleSidebar } from "./Sidebar";
|
||||||
import "../less/memos-header.less";
|
import "../less/memos-header.less";
|
||||||
|
|
||||||
let prevRequestTimestamp = Date.now();
|
let prevRequestTimestamp = Date.now();
|
||||||
@ -38,7 +38,7 @@ const MemosHeader = () => {
|
|||||||
return (
|
return (
|
||||||
<div className="section-header-container memos-header-container">
|
<div className="section-header-container memos-header-container">
|
||||||
<div className="title-container">
|
<div className="title-container">
|
||||||
<div className="action-btn" onClick={() => toggleSiderbar(true)}>
|
<div className="action-btn" onClick={() => toggleSidebar(true)}>
|
||||||
<Icon.Menu className="icon-img" />
|
<Icon.Menu className="icon-img" />
|
||||||
</div>
|
</div>
|
||||||
<span className="title-text" onClick={handleTitleTextClick}>
|
<span className="title-text" onClick={handleTitleTextClick}>
|
||||||
|
@ -83,15 +83,15 @@ const ResourcesDialog: React.FC<Props> = (props: Props) => {
|
|||||||
inputEl.click();
|
inputEl.click();
|
||||||
};
|
};
|
||||||
|
|
||||||
const getResouceUrl = useCallback((resource: Resource) => {
|
const getResourceUrl = useCallback((resource: Resource) => {
|
||||||
return `${window.location.origin}/o/r/${resource.id}/${resource.filename}`;
|
return `${window.location.origin}/o/r/${resource.id}/${resource.filename}`;
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const handlePreviewBtnClick = (resource: Resource) => {
|
const handlePreviewBtnClick = (resource: Resource) => {
|
||||||
const resourceUrl = getResouceUrl(resource);
|
const resourceUrl = getResourceUrl(resource);
|
||||||
if (resource.type.startsWith("image")) {
|
if (resource.type.startsWith("image")) {
|
||||||
showPreviewImageDialog(
|
showPreviewImageDialog(
|
||||||
resources.filter((r) => r.type.startsWith("image")).map((r) => getResouceUrl(r)),
|
resources.filter((r) => r.type.startsWith("image")).map((r) => getResourceUrl(r)),
|
||||||
resources.findIndex((r) => r.id === resource.id)
|
resources.findIndex((r) => r.id === resource.id)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
@ -17,7 +17,7 @@ const Sidebar = () => {
|
|||||||
const location = useAppSelector((state) => state.location);
|
const location = useAppSelector((state) => state.location);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
toggleSiderbar(false);
|
toggleSidebar(false);
|
||||||
}, [location.query]);
|
}, [location.query]);
|
||||||
|
|
||||||
const handleSettingBtnClick = () => {
|
const handleSettingBtnClick = () => {
|
||||||
@ -26,7 +26,7 @@ const Sidebar = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="mask" onClick={() => toggleSiderbar(false)}></div>
|
<div className="mask" onClick={() => toggleSidebar(false)}></div>
|
||||||
<aside className="sidebar-wrapper">
|
<aside className="sidebar-wrapper">
|
||||||
<UserBanner />
|
<UserBanner />
|
||||||
<UsageHeatMap />
|
<UsageHeatMap />
|
||||||
@ -52,7 +52,7 @@ const Sidebar = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const toggleSiderbar = (show?: boolean) => {
|
export const toggleSidebar = (show?: boolean) => {
|
||||||
const sidebarEl = document.body.querySelector(".sidebar-wrapper") as HTMLDivElement;
|
const sidebarEl = document.body.querySelector(".sidebar-wrapper") as HTMLDivElement;
|
||||||
const maskEl = document.body.querySelector(".mask") as HTMLDivElement;
|
const maskEl = document.body.querySelector(".mask") as HTMLDivElement;
|
||||||
|
|
||||||
|
@ -14,22 +14,22 @@ type ToastItemProps = {
|
|||||||
type: ToastType;
|
type: ToastType;
|
||||||
content: string;
|
content: string;
|
||||||
duration: number;
|
duration: number;
|
||||||
destory: FunctionType;
|
destroy: FunctionType;
|
||||||
};
|
};
|
||||||
|
|
||||||
const Toast: React.FC<ToastItemProps> = (props: ToastItemProps) => {
|
const Toast: React.FC<ToastItemProps> = (props: ToastItemProps) => {
|
||||||
const { destory, duration } = props;
|
const { destroy, duration } = props;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (duration > 0) {
|
if (duration > 0) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
destory();
|
destroy();
|
||||||
}, duration);
|
}, duration);
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="toast-container" onClick={destory}>
|
<div className="toast-container" onClick={destroy}>
|
||||||
<p className="content-text">{props.content}</p>
|
<p className="content-text">{props.content}</p>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@ -57,8 +57,8 @@ const initialToastHelper = () => {
|
|||||||
shownToastContainers.push([toast, tempDiv]);
|
shownToastContainers.push([toast, tempDiv]);
|
||||||
|
|
||||||
const cbs = {
|
const cbs = {
|
||||||
destory: () => {
|
destroy: () => {
|
||||||
tempDiv.classList.add("destory");
|
tempDiv.classList.add("destroy");
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (!tempDiv.parentElement) {
|
if (!tempDiv.parentElement) {
|
||||||
@ -77,7 +77,7 @@ const initialToastHelper = () => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
toast.render(<Toast {...config} destory={cbs.destory} />);
|
toast.render(<Toast {...config} destroy={cbs.destroy} />);
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
tempDiv.classList.add("showup");
|
tempDiv.classList.add("showup");
|
||||||
|
@ -11,11 +11,11 @@ const tableConfig = {
|
|||||||
height: 7,
|
height: 7,
|
||||||
};
|
};
|
||||||
|
|
||||||
const getInitialUsageStat = (usedDaysAmount: number, beginDayTimestemp: number): DailyUsageStat[] => {
|
const getInitialUsageStat = (usedDaysAmount: number, beginDayTimestamp: number): DailyUsageStat[] => {
|
||||||
const initialUsageStat: DailyUsageStat[] = [];
|
const initialUsageStat: DailyUsageStat[] = [];
|
||||||
for (let i = 1; i <= usedDaysAmount; i++) {
|
for (let i = 1; i <= usedDaysAmount; i++) {
|
||||||
initialUsageStat.push({
|
initialUsageStat.push({
|
||||||
timestamp: beginDayTimestemp + DAILY_TIMESTAMP * i,
|
timestamp: beginDayTimestamp + DAILY_TIMESTAMP * i,
|
||||||
count: 0,
|
count: 0,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -32,19 +32,19 @@ const UsageHeatMap = () => {
|
|||||||
const todayDay = new Date(todayTimeStamp).getDay() + 1;
|
const todayDay = new Date(todayTimeStamp).getDay() + 1;
|
||||||
const nullCell = new Array(7 - todayDay).fill(0);
|
const nullCell = new Array(7 - todayDay).fill(0);
|
||||||
const usedDaysAmount = (tableConfig.width - 1) * tableConfig.height + todayDay;
|
const usedDaysAmount = (tableConfig.width - 1) * tableConfig.height + todayDay;
|
||||||
const beginDayTimestemp = todayTimeStamp - usedDaysAmount * DAILY_TIMESTAMP;
|
const beginDayTimestamp = todayTimeStamp - usedDaysAmount * DAILY_TIMESTAMP;
|
||||||
|
|
||||||
const { memos } = useAppSelector((state) => state.memo);
|
const { memos } = useAppSelector((state) => state.memo);
|
||||||
const [allStat, setAllStat] = useState<DailyUsageStat[]>(getInitialUsageStat(usedDaysAmount, beginDayTimestemp));
|
const [allStat, setAllStat] = useState<DailyUsageStat[]>(getInitialUsageStat(usedDaysAmount, beginDayTimestamp));
|
||||||
const [currentStat, setCurrentStat] = useState<DailyUsageStat | null>(null);
|
const [currentStat, setCurrentStat] = useState<DailyUsageStat | null>(null);
|
||||||
const containerElRef = useRef<HTMLDivElement>(null);
|
const containerElRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getMemoStats(userService.getCurrentUserId())
|
getMemoStats(userService.getCurrentUserId())
|
||||||
.then(({ data: { data } }) => {
|
.then(({ data: { data } }) => {
|
||||||
const newStat: DailyUsageStat[] = getInitialUsageStat(usedDaysAmount, beginDayTimestemp);
|
const newStat: DailyUsageStat[] = getInitialUsageStat(usedDaysAmount, beginDayTimestamp);
|
||||||
for (const record of data) {
|
for (const record of data) {
|
||||||
const index = (utils.getDateStampByDate(record * 1000) - beginDayTimestemp) / (1000 * 3600 * 24) - 1;
|
const index = (utils.getDateStampByDate(record * 1000) - beginDayTimestamp) / (1000 * 3600 * 24) - 1;
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
newStat[index].count += 1;
|
newStat[index].count += 1;
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import "../../less/common/date-picker.less";
|
|||||||
interface DatePickerProps {
|
interface DatePickerProps {
|
||||||
className?: string;
|
className?: string;
|
||||||
datestamp: DateStamp;
|
datestamp: DateStamp;
|
||||||
handleDateStampChange: (datastamp: DateStamp) => void;
|
handleDateStampChange: (datestamp: DateStamp) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const DatePicker: React.FC<DatePickerProps> = (props: DatePickerProps) => {
|
const DatePicker: React.FC<DatePickerProps> = (props: DatePickerProps) => {
|
||||||
|
@ -26,7 +26,7 @@ const Selector: React.FC<Props> = (props: Props) => {
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [showSelector, toggleSelectorStatus] = useToggle(false);
|
const [showSelector, toggleSelectorStatus] = useToggle(false);
|
||||||
|
|
||||||
const seletorElRef = useRef<HTMLDivElement>(null);
|
const selectorElRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
let currentItem = nullItem;
|
let currentItem = nullItem;
|
||||||
for (const d of dataSource) {
|
for (const d of dataSource) {
|
||||||
@ -39,7 +39,7 @@ const Selector: React.FC<Props> = (props: Props) => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (showSelector) {
|
if (showSelector) {
|
||||||
const handleClickOutside = (event: MouseEvent) => {
|
const handleClickOutside = (event: MouseEvent) => {
|
||||||
if (!seletorElRef.current?.contains(event.target as Node)) {
|
if (!selectorElRef.current?.contains(event.target as Node)) {
|
||||||
toggleSelectorStatus(false);
|
toggleSelectorStatus(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -63,7 +63,7 @@ const Selector: React.FC<Props> = (props: Props) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={`selector-wrapper ${className ?? ""}`} ref={seletorElRef}>
|
<div className={`selector-wrapper ${className ?? ""}`} ref={selectorElRef}>
|
||||||
<div className={`current-value-container ${showSelector ? "active" : ""}`} onClick={handleCurrentValueClick}>
|
<div className={`current-value-container ${showSelector ? "active" : ""}`} onClick={handleCurrentValueClick}>
|
||||||
<span className="value-text">{currentItem.text}</span>
|
<span className="value-text">{currentItem.text}</span>
|
||||||
<span className="arrow-text">
|
<span className="arrow-text">
|
||||||
|
@ -5,7 +5,7 @@ const useToggle = (initialState = false): [boolean, (nextState?: boolean) => voi
|
|||||||
// Initialize the state
|
// Initialize the state
|
||||||
const [state, setState] = useState(initialState);
|
const [state, setState] = useState(initialState);
|
||||||
|
|
||||||
// Define and memorize toggler function in case we pass down the comopnent,
|
// Define and memorize toggler function in case we pass down the component,
|
||||||
// This function change the boolean value to it's opposite value
|
// This function change the boolean value to it's opposite value
|
||||||
const toggle = useCallback((nextState?: boolean) => {
|
const toggle = useCallback((nextState?: boolean) => {
|
||||||
if (nextState !== undefined) {
|
if (nextState !== undefined) {
|
||||||
|
@ -12,7 +12,7 @@ const renderer = (rawStr: string): string => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "blockqoute",
|
name: "blockquote",
|
||||||
regex: BLOCKQUOTE_REG,
|
regex: BLOCKQUOTE_REG,
|
||||||
renderer,
|
renderer,
|
||||||
};
|
};
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
@apply font-mono mx-1;
|
@apply font-mono mx-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
> .addtion-info-container {
|
> .addition-info-container {
|
||||||
@apply flex flex-row text-sm justify-start items-center;
|
@apply flex flex-row text-sm justify-start items-center;
|
||||||
|
|
||||||
> .github-badge-container {
|
> .github-badge-container {
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
background-color: #f6f5f4;
|
background-color: #f6f5f4;
|
||||||
}
|
}
|
||||||
|
|
||||||
> .addtion-btn-container {
|
> .addition-btn-container {
|
||||||
@apply fixed bottom-12 left-1/2 -translate-x-1/2;
|
@apply fixed bottom-12 left-1/2 -translate-x-1/2;
|
||||||
|
|
||||||
> .btn {
|
> .btn {
|
||||||
|
@ -48,7 +48,7 @@ function Home() {
|
|||||||
</div>
|
</div>
|
||||||
<MemoList />
|
<MemoList />
|
||||||
{userService.isVisitorMode() && (
|
{userService.isVisitorMode() && (
|
||||||
<div className="addtion-btn-container">
|
<div className="addition-btn-container">
|
||||||
{user ? (
|
{user ? (
|
||||||
<button className="btn" onClick={() => (window.location.href = "/")}>
|
<button className="btn" onClick={() => (window.location.href = "/")}>
|
||||||
<span className="icon">🏠</span> {t("common.back-to-home")}
|
<span className="icon">🏠</span> {t("common.back-to-home")}
|
||||||
|
@ -5,7 +5,7 @@ import store from "../store";
|
|||||||
import { setLocale } from "../store/modules/global";
|
import { setLocale } from "../store/modules/global";
|
||||||
import { setUser, patchUser, setHost, setOwner } from "../store/modules/user";
|
import { setUser, patchUser, setHost, setOwner } from "../store/modules/user";
|
||||||
|
|
||||||
const defauleSetting: Setting = {
|
const defaultSetting: Setting = {
|
||||||
locale: "en",
|
locale: "en",
|
||||||
memoVisibility: "PRIVATE",
|
memoVisibility: "PRIVATE",
|
||||||
memoDisplayTsOption: "created_ts",
|
memoDisplayTsOption: "created_ts",
|
||||||
@ -13,7 +13,7 @@ const defauleSetting: Setting = {
|
|||||||
|
|
||||||
export const convertResponseModelUser = (user: User): User => {
|
export const convertResponseModelUser = (user: User): User => {
|
||||||
const setting: Setting = {
|
const setting: Setting = {
|
||||||
...defauleSetting,
|
...defaultSetting,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (user.userSettingList) {
|
if (user.userSettingList) {
|
||||||
|
4
web/src/types/filter.d.ts
vendored
4
web/src/types/filter.d.ts
vendored
@ -1,4 +1,4 @@
|
|||||||
type MemoFilterRalation = "AND" | "OR";
|
type MemoFilterRelation = "AND" | "OR";
|
||||||
|
|
||||||
interface BaseFilter {
|
interface BaseFilter {
|
||||||
type: FilterType;
|
type: FilterType;
|
||||||
@ -6,7 +6,7 @@ interface BaseFilter {
|
|||||||
operator: string;
|
operator: string;
|
||||||
value: string;
|
value: string;
|
||||||
};
|
};
|
||||||
relation: MemoFilterRalation;
|
relation: MemoFilterRelation;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface TagFilter extends BaseFilter {
|
interface TagFilter extends BaseFilter {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user