添加filesystem
This commit is contained in:
@@ -17,12 +17,11 @@ import FileSystemParams from "@App/pages/components/FileSystemParams";
|
||||
import { IconQuestionCircleFill } from "@arco-design/web-react/icon";
|
||||
import { RefInputType } from "@arco-design/web-react/es/Input/interface";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { FileSystemType } from "@Packages/filesystem/factory";
|
||||
|
||||
function Tools() {
|
||||
const [loading, setLoading] = useState<{ [key: string]: boolean }>({});
|
||||
const syncCtrl = IoC.instance(SynchronizeController) as SynchronizeController;
|
||||
const fileRef = useRef<HTMLInputElement>(null);
|
||||
const systemConfig = IoC.instance(SystemConfig) as SystemConfig;
|
||||
const [fileSystemType, setFilesystemType] = useState<FileSystemType>(
|
||||
systemConfig.backup.filesystem
|
||||
);
|
||||
|
@@ -777,14 +777,13 @@ function ScriptEditor() {
|
||||
setEditors((prev) => {
|
||||
const i = parseInt(index, 10);
|
||||
if (prev[i].isChanged) {
|
||||
// eslint-disable-next-line no-restricted-globals, no-alert
|
||||
if (!confirm("脚本已修改, 关闭后会丢失修改, 是否继续?")) {
|
||||
return prev;
|
||||
}
|
||||
}
|
||||
if (prev.length === 1) {
|
||||
// 如果是id打开的回退到列表
|
||||
if (id) {
|
||||
// 如果是uuid打开的回退到列表
|
||||
if (uuid) {
|
||||
navigate("/");
|
||||
return prev;
|
||||
}
|
||||
@@ -801,7 +800,7 @@ function ScriptEditor() {
|
||||
setSelectSciptButtonAndTab(prev[i - 1].script.uuid);
|
||||
} else {
|
||||
prev[i + 1].active = true;
|
||||
setSelectSciptButtonAndTab(prev[i - 1].script.uuid);
|
||||
setSelectSciptButtonAndTab(prev[i + 1].script.uuid);
|
||||
}
|
||||
}
|
||||
prev.splice(i, 1);
|
||||
|
@@ -2,6 +2,33 @@ import { createAppSlice } from "../hooks";
|
||||
import { PayloadAction } from "@reduxjs/toolkit";
|
||||
import { editor } from "monaco-editor";
|
||||
|
||||
function setAutoMode() {
|
||||
const darkTheme = window.matchMedia("(prefers-color-scheme: dark)");
|
||||
const isMatch = (match: boolean) => {
|
||||
if (match) {
|
||||
document.body.setAttribute("arco-theme", "dark");
|
||||
editor.setTheme("vs-dark");
|
||||
} else {
|
||||
document.body.removeAttribute("arco-theme");
|
||||
editor.setTheme("vs");
|
||||
}
|
||||
};
|
||||
darkTheme.addEventListener("change", (e) => {
|
||||
isMatch(e.matches);
|
||||
});
|
||||
isMatch(darkTheme.matches);
|
||||
}
|
||||
|
||||
export type SystemConfig = {
|
||||
lightMode: "light" | "dark" | "auto";
|
||||
eslint: {
|
||||
enable: boolean;
|
||||
config: string;
|
||||
};
|
||||
scriptListColumnWidth: { [key: string]: number };
|
||||
menuExpandNum: number;
|
||||
};
|
||||
|
||||
export const settingSlice = createAppSlice({
|
||||
name: "setting",
|
||||
initialState: {
|
||||
@@ -12,27 +39,22 @@ export const settingSlice = createAppSlice({
|
||||
},
|
||||
scriptListColumnWidth: {} as { [key: string]: number },
|
||||
menuExpandNum: 5,
|
||||
},
|
||||
} as SystemConfig,
|
||||
reducers: (create) => {
|
||||
// 初始化黑夜模式
|
||||
const setAutoMode = () => {
|
||||
const darkTheme = window.matchMedia("(prefers-color-scheme: dark)");
|
||||
const isMatch = (match: boolean) => {
|
||||
if (match) {
|
||||
document.body.setAttribute("arco-theme", "dark");
|
||||
editor.setTheme("vs-dark");
|
||||
} else {
|
||||
document.body.removeAttribute("arco-theme");
|
||||
editor.setTheme("vs");
|
||||
}
|
||||
};
|
||||
darkTheme.addEventListener("change", (e) => {
|
||||
isMatch(e.matches);
|
||||
});
|
||||
isMatch(darkTheme.matches);
|
||||
};
|
||||
setAutoMode();
|
||||
// 加载配置
|
||||
chrome.storage.sync.get("systemSetting", (result) => {
|
||||
const systemSetting = result.systemSetting as SystemConfig;
|
||||
settingSlice.actions.initSetting(systemSetting);
|
||||
if (systemSetting) {
|
||||
localStorage.lightMode = systemSetting.lightMode;
|
||||
}
|
||||
});
|
||||
return {
|
||||
initSetting: create.reducer((state, action: PayloadAction<SystemConfig>) => {
|
||||
state.menuExpandNum = action.payload.menuExpandNum;
|
||||
}),
|
||||
setDarkMode: create.reducer((state, action: PayloadAction<"light" | "dark" | "auto">) => {
|
||||
localStorage.loghtMode = action.payload;
|
||||
state.lightMode = action.payload;
|
||||
|
@@ -4,8 +4,6 @@ import { languages } from "monaco-editor";
|
||||
// 注册eslint
|
||||
// const linterWorker = new Worker("/src/linter.worker.js");
|
||||
|
||||
console.log(dts, dts.length);
|
||||
|
||||
export default function registerEditor() {
|
||||
window.MonacoEnvironment = {
|
||||
getWorkerUrl(moduleId: any, label: any) {
|
||||
|
Reference in New Issue
Block a user