mirror of
https://github.com/usememos/memos.git
synced 2024-12-19 00:51:30 +03:00
fix: initial system locale (#1684)
This commit is contained in:
parent
b40571095d
commit
ae1d9adf65
@ -101,24 +101,6 @@ func (s *Server) registerAuthRoutes(g *echo.Group, secret string) {
|
||||
return echo.NewHTTPError(http.StatusInternalServerError, "Incorrect login credentials, please try again")
|
||||
}
|
||||
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{
|
||||
Username: userInfo.Identifier,
|
||||
// The new signup user should be normal user by default.
|
||||
|
@ -210,10 +210,7 @@ const Memo: React.FC<Props> = (props: Props) => {
|
||||
|
||||
return (
|
||||
<>
|
||||
<div
|
||||
className={`memo-wrapper ${"memos-" + memo.id} ${relatedMemoList.length > 0 && "pinned"} ${memo.pinned ? "pinned" : ""}`}
|
||||
ref={memoContainerRef}
|
||||
>
|
||||
<div className={`memo-wrapper ${"memos-" + memo.id} ${memo.pinned && !readonly ? "pinned" : ""}`} ref={memoContainerRef}>
|
||||
<div className="memo-top-wrapper">
|
||||
<div className="status-text-container">
|
||||
<Link className="time-text" to={`/m/${memo.id}`} onClick={handleMemoCreatedTimeClick}>
|
||||
|
@ -41,7 +41,7 @@ const RelationListView = () => {
|
||||
return (
|
||||
<div
|
||||
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" />
|
||||
<span className="mx-1 max-w-full text-ellipsis font-mono whitespace-nowrap overflow-hidden">
|
||||
|
@ -18,7 +18,7 @@ const ResourceListView = () => {
|
||||
return (
|
||||
<div
|
||||
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" />
|
||||
<span className="text-sm max-w-xs truncate font-mono">{resource.filename}</span>
|
||||
|
@ -232,7 +232,7 @@ const SystemSection = () => {
|
||||
</div>
|
||||
<div className="form-label">
|
||||
<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")} />
|
||||
</div>
|
||||
<Input
|
||||
@ -248,7 +248,7 @@ const SystemSection = () => {
|
||||
<Divider className="!mt-3 !my-4" />
|
||||
<div className="form-label">
|
||||
<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" />
|
||||
</div>
|
||||
<Button onClick={handleSaveOpenAIConfig}>{t("common.save")}</Button>
|
||||
|
@ -44,16 +44,19 @@ const UsageHeatMap = () => {
|
||||
const [allStat, setAllStat] = useState<DailyUsageStat[]>(getInitialUsageStat(usedDaysAmount, beginDayTimestamp));
|
||||
const [currentStat, setCurrentStat] = useState<DailyUsageStat | null>(null);
|
||||
const containerElRef = useRef<HTMLDivElement>(null);
|
||||
const currentUserId = userStore.getCurrentUserId();
|
||||
|
||||
useEffect(() => {
|
||||
if (!userStore.state.user) {
|
||||
return;
|
||||
}
|
||||
setCreatedDays(Math.ceil((Date.now() - getTimeStampByDate(userStore.state.user.createdTs)) / 1000 / 3600 / 24));
|
||||
}, [userStore.state.user]);
|
||||
userStore.getUserById(currentUserId).then((user) => {
|
||||
if (!user) {
|
||||
return;
|
||||
}
|
||||
setCreatedDays(Math.ceil((Date.now() - getTimeStampByDate(user.createdTs)) / 1000 / 3600 / 24));
|
||||
});
|
||||
}, [currentUserId]);
|
||||
|
||||
useEffect(() => {
|
||||
getMemoStats(userStore.getCurrentUserId())
|
||||
getMemoStats(currentUserId)
|
||||
.then(({ data: { data } }) => {
|
||||
setMemoAmount(data.length);
|
||||
const newStat: DailyUsageStat[] = getInitialUsageStat(usedDaysAmount, beginDayTimestamp);
|
||||
@ -72,11 +75,7 @@ const UsageHeatMap = () => {
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
});
|
||||
|
||||
return () => {
|
||||
handleUsageStatItemMouseLeave();
|
||||
};
|
||||
}, [memos.length]);
|
||||
}, [memos.length, currentUserId]);
|
||||
|
||||
const handleUsageStatItemMouseEnter = useCallback((event: React.MouseEvent, item: DailyUsageStat) => {
|
||||
const tempDiv = document.createElement("div");
|
||||
|
@ -49,8 +49,9 @@ export const initialGlobalState = async () => {
|
||||
externalUrl: "",
|
||||
},
|
||||
};
|
||||
defaultGlobalState.locale = storageLocale || findNearestLanguageMatch(i18n.language);
|
||||
defaultGlobalState.appearance = customizedProfile.appearance;
|
||||
defaultGlobalState.locale =
|
||||
storageLocale || defaultGlobalState.systemStatus.customizedProfile.locale || findNearestLanguageMatch(i18n.language);
|
||||
defaultGlobalState.appearance = defaultGlobalState.systemStatus.customizedProfile.appearance;
|
||||
}
|
||||
store.dispatch(setGlobalState(defaultGlobalState));
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user