Skip to content

Commit

Permalink
feat(web): add client settings & change settings directory (#1536)
Browse files Browse the repository at this point in the history
* fix(web): fix username overflow

* refactor(web): change settings directory

* feat(web): add client settings
  • Loading branch information
newfish-cmyk authored Sep 18, 2023
1 parent e6ba4b7 commit d22fd4e
Show file tree
Hide file tree
Showing 49 changed files with 324 additions and 161 deletions.
18 changes: 5 additions & 13 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,21 +127,13 @@
"zustand"
],
"i18n-ally.localesPaths": "web/public/locales",
"i18n-ally.enabledParsers": [
"json"
],
"i18n-ally.enabledFrameworks": [
"react",
"i18next",
"general"
],
"i18n-ally.enabledParsers": ["json"],
"i18n-ally.enabledFrameworks": ["react", "i18next", "general"],
"i18n-ally.sourceLanguage": "zh-CN",
"i18n-ally.displayLanguage": "en,zh",
"i18n-ally.namespace": false,
"i18n-ally.pathMatcher": "{locale}/translation.json",
"i18n-ally.keystyle": "nested",
"i18n-ally.keysInUse": [
"description.part2_whatever"
],
"jest.rootPath": "e2e",
}
"i18n-ally.keysInUse": ["description.part2_whatever"],
"jest.rootPath": "e2e"
}
20 changes: 15 additions & 5 deletions web/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@
"versionHistory": "Version History",
"Restore": "Restore",
"Invite": "Invite",
"HistoryTips": "No historical versions available"
"HistoryTips": "No historical versions available",
"NoDesc": "No Description"
},
"HomePanel": {
"APP": "Android or iOS app",
Expand Down Expand Up @@ -208,7 +209,13 @@
"Pause": "Pause",
"AppMonitor": "Application Monitor",
"PauseTips": "Are you sure you want to pause this application?",
"RestartTips": "Are you sure you want to restart this application?"
"RestartTips": "Are you sure you want to restart this application?",
"CommonSetting": "Common Settings",
"ClientSetting": "Client Settings",
"EditorFont": "Editor Font",
"FontSize": "Font Size",
"FuncListDisplay": "Function List Display",
"ListDisplay": "List Display"
},
"StoragePanel": {
"All": "Total Capacity",
Expand Down Expand Up @@ -572,7 +579,9 @@
},
"Reset": "Reset",
"SettingModal": {
"Exchange": "Exchange"
"Exchange": "Exchange",
"FunctionName": "Funciton Name",
"FunctionDesc": "Function Description"
},
"Expenses": "Expenses",
"OrderNumber": "Order Number",
Expand Down Expand Up @@ -637,5 +646,6 @@
"PreviousPage": "Previous Page",
"NextPage": "Next Page",
"LastPage": "Last Page",
"FirstPage": "First Page"
}
"FirstPage": "First Page",
"SavedSuccessfully": "Saved Successfully"
}
20 changes: 15 additions & 5 deletions web/public/locales/zh-CN/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@
"versionHistory": "历史版本",
"Restore": "恢复",
"Invite": "邀请",
"HistoryTips": "暂无历史版本"
"HistoryTips": "暂无历史版本",
"NoDesc": "暂无描述"
},
"HomePanel": {
"APP": "Android or iOS 应用",
Expand Down Expand Up @@ -208,7 +209,13 @@
"Pause": "暂停应用",
"AppMonitor": "资源监控",
"PauseTips": "确定要暂停此应用吗?",
"RestartTips": "确定要重启此应用吗?"
"RestartTips": "确定要重启此应用吗?",
"CommonSetting": "常用设置",
"ClientSetting": "客户端设置",
"EditorFont": "编辑器字体",
"FontSize": "字体大小",
"FuncListDisplay": "函数列表显示",
"ListDisplay": "列表显示"
},
"StoragePanel": {
"All": "总容量",
Expand Down Expand Up @@ -572,7 +579,9 @@
},
"Reset": "重置",
"SettingModal": {
"Exchange": "兑换"
"Exchange": "兑换",
"FunctionName": "函数名",
"FunctionDesc": "函数描述"
},
"Expenses": "支出",
"OrderNumber": "订单号",
Expand Down Expand Up @@ -637,5 +646,6 @@
"PreviousPage": "上一页",
"NextPage": "下一页",
"LastPage": "最后一页",
"FirstPage": "第一页"
}
"FirstPage": "第一页",
"SavedSuccessfully": "保存成功"
}
20 changes: 15 additions & 5 deletions web/public/locales/zh/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@
"versionHistory": "历史版本",
"Restore": "恢复",
"Invite": "邀请",
"HistoryTips": "暂无历史版本"
"HistoryTips": "暂无历史版本",
"NoDesc": "暂无描述"
},
"HomePanel": {
"APP": "Android or iOS 应用",
Expand Down Expand Up @@ -208,7 +209,13 @@
"Pause": "暂停应用",
"AppMonitor": "资源监控",
"PauseTips": "确定要暂停此应用吗?",
"RestartTips": "确定要重启此应用吗?"
"RestartTips": "确定要重启此应用吗?",
"CommonSetting": "常用设置",
"ClientSetting": "客户端设置",
"EditorFont": "编辑器字体",
"FontSize": "字体大小",
"FuncListDisplay": "函数列表显示",
"ListDisplay": "列表显示"
},
"StoragePanel": {
"All": "总容量",
Expand Down Expand Up @@ -572,7 +579,9 @@
},
"Reset": "重置",
"SettingModal": {
"Exchange": "兑换"
"Exchange": "兑换",
"FunctionName": "函数名",
"FunctionDesc": "函数描述"
},
"MyIncomeAndExpenses": "我的收支",
"Expenses": "支出",
Expand Down Expand Up @@ -637,5 +646,6 @@
"PreviousPage": "上一页",
"NextPage": "下一页",
"LastPage": "最后一页",
"FirstPage": "第一页"
}
"FirstPage": "第一页",
"SavedSuccessfully": "保存成功"
}
1 change: 1 addition & 0 deletions web/src/apis/typing.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ export type TFunctionNode = {
name: string;
level?: number;
isExpanded?: boolean;
desc?: string;
children: TreeNode[];
};

Expand Down
6 changes: 6 additions & 0 deletions web/src/components/CommonIcon/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -735,3 +735,9 @@ export const OutlineFolderAddIcon = createIcon({
viewBox: "0 0 24 24",
d: "M15 16C15.2833 16 15.521 15.904 15.713 15.712C15.9043 15.5207 16 15.2833 16 15V14H17C17.2833 14 17.5207 13.904 17.712 13.712C17.904 13.5207 18 13.2833 18 13C18 12.7167 17.904 12.479 17.712 12.287C17.5207 12.0957 17.2833 12 17 12H16V11C16 10.7167 15.9043 10.479 15.713 10.287C15.521 10.0957 15.2833 10 15 10C14.7167 10 14.4793 10.0957 14.288 10.287C14.096 10.479 14 10.7167 14 11V12H13C12.7167 12 12.4793 12.0957 12.288 12.287C12.096 12.479 12 12.7167 12 13C12 13.2833 12.096 13.5207 12.288 13.712C12.4793 13.904 12.7167 14 13 14H14V15C14 15.2833 14.096 15.5207 14.288 15.712C14.4793 15.904 14.7167 16 15 16ZM4 20C3.45 20 2.97933 19.8043 2.588 19.413C2.196 19.021 2 18.55 2 18V6C2 5.45 2.196 4.97933 2.588 4.588C2.97933 4.196 3.45 4 4 4H9.175C9.44167 4 9.696 4.05 9.938 4.15C10.1793 4.25 10.3917 4.39167 10.575 4.575L12 6H20C20.55 6 21.021 6.196 21.413 6.588C21.8043 6.97933 22 7.45 22 8V18C22 18.55 21.8043 19.021 21.413 19.413C21.021 19.8043 20.55 20 20 20H4ZM4 6V18H20V8H11.175L9.175 6H4ZM4 6V18V6Z",
});

export const CommonSettingIcon = createIcon({
displayName: "CommonSettingIcon",
viewBox: "0 0 16 16",
d: "M1.5 4.54688C1.5 4.38526 1.5642 4.23026 1.67848 4.11598C1.79276 4.0017 1.94776 3.9375 2.10938 3.9375H13.8906C14.0522 3.9375 14.2072 4.0017 14.3215 4.11598C14.4358 4.23026 14.5 4.38526 14.5 4.54688C14.5 4.70849 14.4358 4.86349 14.3215 4.97777C14.2072 5.09205 14.0522 5.15625 13.8906 5.15625H2.10938C1.94776 5.15625 1.79276 5.09205 1.67848 4.97777C1.5642 4.86349 1.5 4.70849 1.5 4.54688ZM1.5 8C1.5 7.83838 1.5642 7.68339 1.67848 7.56911C1.79276 7.45483 1.94776 7.39062 2.10938 7.39062H13.8906C14.0522 7.39062 14.2072 7.45483 14.3215 7.56911C14.4358 7.68339 14.5 7.83838 14.5 8C14.5 8.16162 14.4358 8.31661 14.3215 8.43089C14.2072 8.54517 14.0522 8.60938 13.8906 8.60938H2.10938C1.94776 8.60938 1.79276 8.54517 1.67848 8.43089C1.5642 8.31661 1.5 8.16162 1.5 8ZM2.10938 10.8438C1.94776 10.8438 1.79276 10.908 1.67848 11.0222C1.5642 11.1365 1.5 11.2915 1.5 11.4531C1.5 11.6147 1.5642 11.7697 1.67848 11.884C1.79276 11.9983 1.94776 12.0625 2.10938 12.0625H9.82812C9.98974 12.0625 10.1447 11.9983 10.259 11.884C10.3733 11.7697 10.4375 11.6147 10.4375 11.4531C10.4375 11.2915 10.3733 11.1365 10.259 11.0222C10.1447 10.908 9.98974 10.8438 9.82812 10.8438H2.10938Z",
});
9 changes: 6 additions & 3 deletions web/src/components/Editor/FunctionEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ function FunctionEditor(props: {
height?: string;
colorMode?: string;
readOnly?: boolean;
fontSize?: number;
}) {
const {
value,
Expand All @@ -123,6 +124,7 @@ function FunctionEditor(props: {
style = {},
colorMode = COLOR_MODE.light,
readOnly = false,
fontSize = 14,
} = props;

const editorRef = useRef<monaco.editor.IStandaloneCodeEditor | null>();
Expand Down Expand Up @@ -159,7 +161,7 @@ function FunctionEditor(props: {
formatOnPaste: true,
overviewRulerLanes: 0,
lineNumbersMinChars: 4,
fontSize: 14,
fontSize: fontSize,
theme: colorMode === COLOR_MODE.dark ? "lafEditorThemeDark" : "lafEditorTheme",
scrollBeyondLastLine: false,
});
Expand All @@ -172,7 +174,7 @@ function FunctionEditor(props: {
}

return () => {};
}, [colorMode, path, readOnly, value]);
}, [colorMode, path, readOnly, value, fontSize]);

useEffect(() => {
if (monacoEl && editorRef.current) {
Expand All @@ -188,10 +190,11 @@ function FunctionEditor(props: {
useEffect(() => {
if (monacoEl && editorRef.current) {
editorRef.current.updateOptions({
fontSize: fontSize,
theme: colorMode === COLOR_MODE.dark ? "lafEditorThemeDark" : "lafEditorTheme",
});
}
}, [colorMode]);
}, [colorMode, fontSize]);

// onChange
useEffect(() => {
Expand Down
1 change: 1 addition & 0 deletions web/src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,5 @@ export enum APP_SETTING_KEY {
ENV = "env",
MONITOR = "monitor",
DOMAIN = "domain",
COMMON = "common",
}
3 changes: 3 additions & 0 deletions web/src/pages/app/functions/mods/EditorPanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ import useFunctionStore from "../../store";
import CreateModal from "../FunctionPanel/CreateModal";

import useFunctionCache from "@/hooks/useFunctionCache";
import useCustomSettingStore from "@/pages/customSetting";

function EditorPanel() {
const store = useFunctionStore((store) => store);
const { currentFunction, updateFunctionCode, recentFunctionList } = store;
const { commonSettings } = useCustomSettingStore();
const { colorMode } = useColorMode();
const { t } = useTranslation();
const functionCache = useFunctionCache();
Expand Down Expand Up @@ -47,6 +49,7 @@ function EditorPanel() {
updateFunctionCode(currentFunction, value || "");
functionCache.setCache(currentFunction!._id, value || "");
}}
fontSize={commonSettings.fontSize}
/>
) : (
functionListQuery.data?.data?.length !== 0 && (
Expand Down
8 changes: 7 additions & 1 deletion web/src/pages/app/functions/mods/FunctionPanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import "./index.css";
import { TFunction, TFunctionNode } from "@/apis/typing";
import useFunctionCache from "@/hooks/useFunctionCache";
import RecycleBinModal from "@/pages/app/functions/mods/RecycleBinModal";
import useCustomSettingStore from "@/pages/customSetting";
import useGlobalStore from "@/pages/globalStore";

type TagItem = {
Expand Down Expand Up @@ -68,6 +69,7 @@ export default function FunctionList() {
const darkMode = colorMode === COLOR_MODE.dark;

const { currentApp, showSuccess } = useGlobalStore();
const { commonSettings } = useCustomSettingStore();

const { id: functionName } = useParams();
const navigate = useNavigate();
Expand Down Expand Up @@ -221,6 +223,10 @@ export default function FunctionList() {
fileType = FileType.folder;
}
const level = item.level || item?.name.split("/").length - 1;
const itemDisplay =
commonSettings.funcListDisplay === "name"
? item?.name.split("/")[level]
: item?.desc || t("FunctionPanel.NoDesc");

return (
<React.Fragment key={index}>
Expand Down Expand Up @@ -253,7 +259,7 @@ export default function FunctionList() {
>
<FileTypeIcon type={fileType} width="12px" />
<span className="ml-2">
{item.children?.length || isFuncList ? item?.name : item?.name.split("/")[level]}
{item.children?.length || isFuncList ? item.name : itemDisplay}
</span>
</div>
{!item.children?.length && (
Expand Down
23 changes: 0 additions & 23 deletions web/src/pages/app/setting/Profile/index.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useQuery, useQueryClient } from "@tanstack/react-query";

import { ErrorIcon } from "@/components/CommonIcon";

import { MonitorDataType } from "../../mods/StatusBar/MonitorBar";
import { MonitorDataType } from "../../../mods/StatusBar/MonitorBar";

import AreaCard from "./AreaCard";
import PieCard from "./PieCard";
Expand Down
Loading

0 comments on commit d22fd4e

Please sign in to comment.