修复脚本管理编辑交互,修复ico无法加载

This commit is contained in:
hanhh
2021-08-19 23:46:26 +08:00
parent f86892cef0
commit d9a9d2ee4f
20 changed files with 50 additions and 35 deletions
+1 -4
View File
@@ -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<any[]>([]);
const { headerStyle, isPhone } = useCtx();
const { theme } = useTheme();
const editorRef = useRef<any>(null);
const getConfig = (name: string) => {
+1 -3
View File
@@ -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<string[]>([]);
const [currentPage, setCurrentPage] = useState(1);
const [pageSize, setPageSize] = useState(20);
const { headerStyle, isPhone } = useCtx();
const getCrons = () => {
setLoading(true);
+2 -5
View File
@@ -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<any>(null);
const getConfig = () => {
@@ -115,4 +112,4 @@ const Crontab = () => {
);
};
export default Crontab;
export default Diff;
+1 -2
View File
@@ -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<string[]>([]);
const [searchText, setSearchText] = useState('');
const { headerStyle, isPhone } = useCtx();
const getEnvs = () => {
setLoading(true);
+1
View File
@@ -14,6 +14,7 @@
flex: 1;
overflow: auto;
border-right: 1px dashed #f0f0f0;
padding-top: 6px;
}
}
+2 -3
View File
@@ -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<number>();
const treeDom = useRef<any>();
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);
+1 -1
View File
@@ -46,7 +46,7 @@ const Login = () => {
<img
alt="logo"
className={styles.logo}
src="https://qinglong.whyour.cn/qinglong.png"
src="/images/qinglong.png"
/>
<span className={styles.title}>{config.siteName}</span>
</div>
+1
View File
@@ -14,6 +14,7 @@
flex: 1;
overflow: auto;
border-right: 1px dashed #f0f0f0;
padding-top: 6px;
}
}
+14 -5
View File
@@ -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<string>();
@@ -51,8 +51,6 @@ const Script = () => {
const [height, setHeight] = useState<number>();
const treeDom = useRef<any>();
const [isLogModalVisible, setIsLogModalVisible] = useState(false);
const { headerStyle, isPhone } = useCtx();
const { theme } = useTheme();
const [searchValue, setSearchValue] = useState('');
const [isEditing, setIsEditing] = useState(false);
const editorRef = useRef<any>(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 = () => {
<Button type="primary" onClick={saveFile}>
</Button>,
<Button type="primary" onClick={cancelEdit}>
退
</Button>,
]
: [
<Button type="primary" onClick={editFile}>
@@ -255,6 +263,7 @@ const Script = () => {
height={height}
showLine={{ showLeafIcon: true }}
onSelect={onTreeSelect}
defaultSelectedKeys={[data[0] && data[0].key]}
></Tree>
</div>
</div>
-1
View File
@@ -18,7 +18,6 @@ const SaveModal = ({
const [loading, setLoading] = useState(false);
const handleOk = async (values: any) => {
console.log(file.filename);
setLoading(true);
const payload = { ...file, ...values };
request
-1
View File
@@ -16,7 +16,6 @@ const SettingModal = ({
const [loading, setLoading] = useState(false);
const handleOk = async (values: any) => {
console.log(file.filename);
setLoading(true);
const payload = { ...file, ...values };
request
+1 -2
View File
@@ -18,12 +18,11 @@ const optionsWithDisabled = [
{ label: '跟随系统', value: 'auto' },
];
const Password = () => {
const Password = ({ headerStyle, isPhone }: any) => {
const [value, setValue] = useState('');
const [loading, setLoading] = useState(true);
const defaultDarken = localStorage.getItem('qinglong_dark_theme') || 'auto';
const [theme, setTheme] = useState(defaultDarken);
const { headerStyle, isPhone } = useCtx();
const handleOk = (values: any) => {
request