mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
fix: initial system locale (#1684)
This commit is contained in:
@ -101,24 +101,6 @@ func (s *Server) registerAuthRoutes(g *echo.Group, secret string) {
|
|||||||
return echo.NewHTTPError(http.StatusInternalServerError, "Incorrect login credentials, please try again")
|
return echo.NewHTTPError(http.StatusInternalServerError, "Incorrect login credentials, please try again")
|
||||||
}
|
}
|
||||||
if user == nil {
|
if user == nil {
|
||||||
allowSignUpSetting, err := s.Store.FindSystemSetting(ctx, &api.SystemSettingFind{
|
|
||||||
Name: api.SystemSettingAllowSignUpName,
|
|
||||||
})
|
|
||||||
if err != nil && common.ErrorCode(err) != common.NotFound {
|
|
||||||
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to find system setting").SetInternal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
allowSignUpSettingValue := false
|
|
||||||
if allowSignUpSetting != nil {
|
|
||||||
err = json.Unmarshal([]byte(allowSignUpSetting.Value), &allowSignUpSettingValue)
|
|
||||||
if err != nil {
|
|
||||||
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to unmarshal system setting allow signup").SetInternal(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !allowSignUpSettingValue {
|
|
||||||
return echo.NewHTTPError(http.StatusUnauthorized, "signup is disabled").SetInternal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
userCreate := &api.UserCreate{
|
userCreate := &api.UserCreate{
|
||||||
Username: userInfo.Identifier,
|
Username: userInfo.Identifier,
|
||||||
// The new signup user should be normal user by default.
|
// The new signup user should be normal user by default.
|
||||||
|
@ -210,10 +210,7 @@ const Memo: React.FC<Props> = (props: Props) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div
|
<div className={`memo-wrapper ${"memos-" + memo.id} ${memo.pinned && !readonly ? "pinned" : ""}`} ref={memoContainerRef}>
|
||||||
className={`memo-wrapper ${"memos-" + memo.id} ${relatedMemoList.length > 0 && "pinned"} ${memo.pinned ? "pinned" : ""}`}
|
|
||||||
ref={memoContainerRef}
|
|
||||||
>
|
|
||||||
<div className="memo-top-wrapper">
|
<div className="memo-top-wrapper">
|
||||||
<div className="status-text-container">
|
<div className="status-text-container">
|
||||||
<Link className="time-text" to={`/m/${memo.id}`} onClick={handleMemoCreatedTimeClick}>
|
<Link className="time-text" to={`/m/${memo.id}`} onClick={handleMemoCreatedTimeClick}>
|
||||||
|
@ -41,7 +41,7 @@ const RelationListView = () => {
|
|||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={memoRelation.relatedMemoId}
|
key={memoRelation.relatedMemoId}
|
||||||
className="w-auto max-w-[50%] overflow-hidden flex flex-row justify-start items-center bg-gray-100 hover:bg-gray-200 rounded text-sm p-1 px-2 text-gray-500 cursor-pointer"
|
className="w-auto max-w-[50%] overflow-hidden flex flex-row justify-start items-center bg-gray-100 dark:bg-zinc-800 hover:opacity-80 rounded text-sm p-1 px-2 text-gray-500 cursor-pointer"
|
||||||
>
|
>
|
||||||
<Icon.Link className="w-4 h-auto shrink-0" />
|
<Icon.Link className="w-4 h-auto shrink-0" />
|
||||||
<span className="mx-1 max-w-full text-ellipsis font-mono whitespace-nowrap overflow-hidden">
|
<span className="mx-1 max-w-full text-ellipsis font-mono whitespace-nowrap overflow-hidden">
|
||||||
|
@ -18,7 +18,7 @@ const ResourceListView = () => {
|
|||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={resource.id}
|
key={resource.id}
|
||||||
className="max-w-full flex flex-row justify-start items-center flex-nowrap bg-gray-100 px-2 py-1 rounded cursor-pointer text-gray-500 hover:bg-gray-200 dark:opacity-60"
|
className="max-w-full flex flex-row justify-start items-center flex-nowrap bg-gray-100 dark:bg-zinc-800 hover:opacity-80 px-2 py-1 rounded cursor-pointer text-gray-500"
|
||||||
>
|
>
|
||||||
<ResourceIcon resourceType={resource.type} className="w-4 h-auto mr-1" />
|
<ResourceIcon resourceType={resource.type} className="w-4 h-auto mr-1" />
|
||||||
<span className="text-sm max-w-xs truncate font-mono">{resource.filename}</span>
|
<span className="text-sm max-w-xs truncate font-mono">{resource.filename}</span>
|
||||||
|
@ -232,7 +232,7 @@ const SystemSection = () => {
|
|||||||
</div>
|
</div>
|
||||||
<div className="form-label">
|
<div className="form-label">
|
||||||
<div className="flex flex-row items-center">
|
<div className="flex flex-row items-center">
|
||||||
<span className="normal-text mr-1">{t("setting.system-section.max-upload-size")}</span>
|
<span className="text-sm mr-1">{t("setting.system-section.max-upload-size")}</span>
|
||||||
<HelpButton icon="info" hint={t("setting.system-section.max-upload-size-hint")} />
|
<HelpButton icon="info" hint={t("setting.system-section.max-upload-size-hint")} />
|
||||||
</div>
|
</div>
|
||||||
<Input
|
<Input
|
||||||
@ -248,7 +248,7 @@ const SystemSection = () => {
|
|||||||
<Divider className="!mt-3 !my-4" />
|
<Divider className="!mt-3 !my-4" />
|
||||||
<div className="form-label">
|
<div className="form-label">
|
||||||
<div className="flex flex-row items-center">
|
<div className="flex flex-row items-center">
|
||||||
<span className="normal-text mr-1">{t("setting.system-section.openai-api-key")}</span>
|
<span className="text-sm mr-1">{t("setting.system-section.openai-api-key")}</span>
|
||||||
<HelpButton hint={t("setting.system-section.openai-api-key-description")} url="https://platform.openai.com/account/api-keys" />
|
<HelpButton hint={t("setting.system-section.openai-api-key-description")} url="https://platform.openai.com/account/api-keys" />
|
||||||
</div>
|
</div>
|
||||||
<Button onClick={handleSaveOpenAIConfig}>{t("common.save")}</Button>
|
<Button onClick={handleSaveOpenAIConfig}>{t("common.save")}</Button>
|
||||||
|
@ -44,16 +44,19 @@ const UsageHeatMap = () => {
|
|||||||
const [allStat, setAllStat] = useState<DailyUsageStat[]>(getInitialUsageStat(usedDaysAmount, beginDayTimestamp));
|
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);
|
||||||
|
const currentUserId = userStore.getCurrentUserId();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!userStore.state.user) {
|
userStore.getUserById(currentUserId).then((user) => {
|
||||||
|
if (!user) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setCreatedDays(Math.ceil((Date.now() - getTimeStampByDate(userStore.state.user.createdTs)) / 1000 / 3600 / 24));
|
setCreatedDays(Math.ceil((Date.now() - getTimeStampByDate(user.createdTs)) / 1000 / 3600 / 24));
|
||||||
}, [userStore.state.user]);
|
});
|
||||||
|
}, [currentUserId]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getMemoStats(userStore.getCurrentUserId())
|
getMemoStats(currentUserId)
|
||||||
.then(({ data: { data } }) => {
|
.then(({ data: { data } }) => {
|
||||||
setMemoAmount(data.length);
|
setMemoAmount(data.length);
|
||||||
const newStat: DailyUsageStat[] = getInitialUsageStat(usedDaysAmount, beginDayTimestamp);
|
const newStat: DailyUsageStat[] = getInitialUsageStat(usedDaysAmount, beginDayTimestamp);
|
||||||
@ -72,11 +75,7 @@ const UsageHeatMap = () => {
|
|||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
});
|
});
|
||||||
|
}, [memos.length, currentUserId]);
|
||||||
return () => {
|
|
||||||
handleUsageStatItemMouseLeave();
|
|
||||||
};
|
|
||||||
}, [memos.length]);
|
|
||||||
|
|
||||||
const handleUsageStatItemMouseEnter = useCallback((event: React.MouseEvent, item: DailyUsageStat) => {
|
const handleUsageStatItemMouseEnter = useCallback((event: React.MouseEvent, item: DailyUsageStat) => {
|
||||||
const tempDiv = document.createElement("div");
|
const tempDiv = document.createElement("div");
|
||||||
|
@ -49,8 +49,9 @@ export const initialGlobalState = async () => {
|
|||||||
externalUrl: "",
|
externalUrl: "",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
defaultGlobalState.locale = storageLocale || findNearestLanguageMatch(i18n.language);
|
defaultGlobalState.locale =
|
||||||
defaultGlobalState.appearance = customizedProfile.appearance;
|
storageLocale || defaultGlobalState.systemStatus.customizedProfile.locale || findNearestLanguageMatch(i18n.language);
|
||||||
|
defaultGlobalState.appearance = defaultGlobalState.systemStatus.customizedProfile.appearance;
|
||||||
}
|
}
|
||||||
store.dispatch(setGlobalState(defaultGlobalState));
|
store.dispatch(setGlobalState(defaultGlobalState));
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user