diff --git a/.umirc.ts b/.umirc.ts
index 9e43bb64..0b49eabd 100644
--- a/.umirc.ts
+++ b/.umirc.ts
@@ -8,7 +8,7 @@ export default defineConfig({
type: 'none',
},
fastRefresh: {},
- favicon: 'https://qinglong.whyour.cn/g5.ico',
+ favicon: '/images/g5.ico',
proxy: {
'/api': {
target: 'http://127.0.0.1:5678/',
diff --git a/README.md b/README.md
index 931c55c1..abc6d6ef 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
-
+
diff --git a/public/images/g5.ico b/public/images/g5.ico
new file mode 100644
index 00000000..552357bf
Binary files /dev/null and b/public/images/g5.ico differ
diff --git a/public/images/qinglong.png b/public/images/qinglong.png
new file mode 100644
index 00000000..8ba23cea
Binary files /dev/null and b/public/images/qinglong.png differ
diff --git a/src/layouts/defaultProps.tsx b/src/layouts/defaultProps.tsx
index 888cf247..dd205676 100644
--- a/src/layouts/defaultProps.tsx
+++ b/src/layouts/defaultProps.tsx
@@ -69,5 +69,5 @@ export default {
fixSiderbar: true,
contentWidth: 'Fixed',
splitMenus: false,
- logo: 'https://qinglong.whyour.cn/qinglong.png',
+ logo: '/images/qinglong.png',
} as any;
diff --git a/src/layouts/index.tsx b/src/layouts/index.tsx
index cfa09e4c..09181be5 100644
--- a/src/layouts/index.tsx
+++ b/src/layouts/index.tsx
@@ -14,8 +14,12 @@ import { request } from '@/utils/http';
import './index.less';
import vhCheck from 'vh-check';
import { version, changeLog } from '../version';
+import { useCtx, useTheme } from '@/utils/hooks';
export default function (props: any) {
+ const ctx = useCtx();
+ const theme = useTheme();
+
const logout = () => {
request.post(`${config.apiPrefix}logout`).then(() => {
localStorage.removeItem(config.authKey);
@@ -107,7 +111,9 @@ export default function (props: any) {
pageTitleRender={() => '控制面板'}
{...defaultProps}
>
- {props.children}
+ {React.Children.map(props.children, (child) => {
+ return React.cloneElement(child, { ...ctx, ...theme });
+ })}
);
}
diff --git a/src/pages/config/index.tsx b/src/pages/config/index.tsx
index 149c92e9..7fef7e5c 100644
--- a/src/pages/config/index.tsx
+++ b/src/pages/config/index.tsx
@@ -11,16 +11,13 @@ import { PageContainer } from '@ant-design/pro-layout';
import { request } from '@/utils/http';
import Editor from '@monaco-editor/react';
import { Controlled as CodeMirror } from 'react-codemirror2';
-import { useCtx, useTheme } from '@/utils/hooks';
-const Config = () => {
+const Config = ({ headerStyle, isPhone, theme }: any) => {
const [value, setValue] = useState('');
const [loading, setLoading] = useState(true);
const [title, setTitle] = useState('config.sh');
const [select, setSelect] = useState('config.sh');
const [data, setData] = useState([]);
- const { headerStyle, isPhone } = useCtx();
- const { theme } = useTheme();
const editorRef = useRef(null);
const getConfig = (name: string) => {
diff --git a/src/pages/crontab/index.tsx b/src/pages/crontab/index.tsx
index d82da79e..23547f4d 100644
--- a/src/pages/crontab/index.tsx
+++ b/src/pages/crontab/index.tsx
@@ -31,7 +31,6 @@ import { PageContainer } from '@ant-design/pro-layout';
import { request } from '@/utils/http';
import CronModal from './modal';
import CronLogModal from './logModal';
-import { useCtx, useTheme } from '@/utils/hooks';
const { Text } = Typography;
const { Search } = Input;
@@ -59,7 +58,7 @@ enum OperationPath {
'stop',
}
-const Crontab = () => {
+const Crontab = ({ headerStyle, isPhone }: any) => {
const columns = [
{
title: '任务名',
@@ -203,7 +202,6 @@ const Crontab = () => {
const [selectedRowIds, setSelectedRowIds] = useState([]);
const [currentPage, setCurrentPage] = useState(1);
const [pageSize, setPageSize] = useState(20);
- const { headerStyle, isPhone } = useCtx();
const getCrons = () => {
setLoading(true);
diff --git a/src/pages/diff/index.tsx b/src/pages/diff/index.tsx
index 43503406..93cdbc48 100644
--- a/src/pages/diff/index.tsx
+++ b/src/pages/diff/index.tsx
@@ -6,14 +6,11 @@ import { request } from '@/utils/http';
import './index.less';
import { DiffEditor } from '@monaco-editor/react';
import ReactDiffViewer from 'react-diff-viewer';
-import { useCtx, useTheme } from '@/utils/hooks';
-const Crontab = () => {
+const Diff = ({ headerStyle, isPhone, theme }: any) => {
const [value, setValue] = useState('');
const [sample, setSample] = useState('');
const [loading, setLoading] = useState(true);
- const { headerStyle, isPhone } = useCtx();
- const { theme } = useTheme();
const editorRef = useRef(null);
const getConfig = () => {
@@ -115,4 +112,4 @@ const Crontab = () => {
);
};
-export default Crontab;
+export default Diff;
diff --git a/src/pages/env/index.tsx b/src/pages/env/index.tsx
index 0e47b40c..f366f057 100644
--- a/src/pages/env/index.tsx
+++ b/src/pages/env/index.tsx
@@ -104,7 +104,7 @@ const DragableBodyRow = ({
);
};
-const Env = () => {
+const Env = ({ headerStyle, isPhone, theme }: any) => {
const columns = [
{
title: '序号',
@@ -203,7 +203,6 @@ const Env = () => {
const [editedEnv, setEditedEnv] = useState();
const [selectedRowIds, setSelectedRowIds] = useState([]);
const [searchText, setSearchText] = useState('');
- const { headerStyle, isPhone } = useCtx();
const getEnvs = () => {
setLoading(true);
diff --git a/src/pages/log/index.module.less b/src/pages/log/index.module.less
index 019dcdee..4f91359e 100644
--- a/src/pages/log/index.module.less
+++ b/src/pages/log/index.module.less
@@ -14,6 +14,7 @@
flex: 1;
overflow: auto;
border-right: 1px dashed #f0f0f0;
+ padding-top: 6px;
}
}
diff --git a/src/pages/log/index.tsx b/src/pages/log/index.tsx
index 8f9943ec..2d7a096b 100644
--- a/src/pages/log/index.tsx
+++ b/src/pages/log/index.tsx
@@ -38,7 +38,7 @@ function getFilterData(keyword: string, data: any) {
return { tree: data, expandedKeys };
}
-const Log = () => {
+const Log = ({ headerStyle, isPhone, theme }: any) => {
const [title, setTitle] = useState('请选择日志文件');
const [value, setValue] = useState('请选择日志文件');
const [select, setSelect] = useState();
@@ -47,8 +47,6 @@ const Log = () => {
const [loading, setLoading] = useState(false);
const [height, setHeight] = useState();
const treeDom = useRef();
- const { headerStyle, isPhone } = useCtx();
- const { theme } = useTheme();
const getLogs = () => {
setLoading(true);
@@ -86,6 +84,7 @@ const Log = () => {
};
const onSelect = (value: any, node: any) => {
+ setValue('加载中...');
setSelect(value);
setTitle(node.parent || node.value);
getLog(node);
diff --git a/src/pages/login/index.tsx b/src/pages/login/index.tsx
index a517b50c..2cc7904f 100644
--- a/src/pages/login/index.tsx
+++ b/src/pages/login/index.tsx
@@ -46,7 +46,7 @@ const Login = () => {
{config.siteName}
diff --git a/src/pages/script/index.module.less b/src/pages/script/index.module.less
index 019dcdee..4f91359e 100644
--- a/src/pages/script/index.module.less
+++ b/src/pages/script/index.module.less
@@ -14,6 +14,7 @@
flex: 1;
overflow: auto;
border-right: 1px dashed #f0f0f0;
+ padding-top: 6px;
}
}
diff --git a/src/pages/script/index.tsx b/src/pages/script/index.tsx
index f87f6155..f71b3b58 100644
--- a/src/pages/script/index.tsx
+++ b/src/pages/script/index.tsx
@@ -40,7 +40,7 @@ const LangMap: any = {
'.ts': 'typescript',
};
-const Script = () => {
+const Script = ({ headerStyle, isPhone, theme }: any) => {
const [title, setTitle] = useState('请选择脚本文件');
const [value, setValue] = useState('请选择脚本文件');
const [select, setSelect] = useState();
@@ -51,8 +51,6 @@ const Script = () => {
const [height, setHeight] = useState();
const treeDom = useRef();
const [isLogModalVisible, setIsLogModalVisible] = useState(false);
- const { headerStyle, isPhone } = useCtx();
- const { theme } = useTheme();
const [searchValue, setSearchValue] = useState('');
const [isEditing, setIsEditing] = useState(false);
const editorRef = useRef(null);
@@ -64,6 +62,7 @@ const Script = () => {
.then((data) => {
setData(data.data);
setFilterData(data.data);
+ onSelect(data.data[0].value, data.data[0]);
})
.finally(() => setLoading(false));
};
@@ -75,6 +74,7 @@ const Script = () => {
};
const onSelect = (value: any, node: any) => {
+ setValue('加载中...');
const newMode = LangMap[value.slice(-3)] || '';
setMode(isPhone && newMode === 'typescript' ? 'javascript' : newMode);
setSelect(value);
@@ -100,6 +100,12 @@ const Script = () => {
setIsEditing(true);
};
+ const cancelEdit = () => {
+ setIsEditing(false);
+ setValue('加载中...');
+ getDetail({ value: select });
+ };
+
const saveFile = () => {
Modal.confirm({
title: `确认保存`,
@@ -126,6 +132,7 @@ const Script = () => {
.then((_data: any) => {
if (_data.code === 200) {
message.success(`保存成功`);
+ setIsEditing(false);
} else {
message.error(_data);
}
@@ -177,8 +184,6 @@ const Script = () => {
useEffect(() => {
const word = searchValue || '';
const { tree } = getFilterData(word.toLocaleLowerCase(), data);
- console.log(word);
- console.log(tree);
setFilterData(tree);
setSelect('');
setTitle('请选择脚本文件');
@@ -217,6 +222,9 @@ const Script = () => {
,
+ ,
]
: [