mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-23 23:06:06 +08:00
使用ssr-darkreader代替darkreader
This commit is contained in:
parent
1cfcc66548
commit
b2f5960097
|
@ -9,6 +9,9 @@ export default defineConfig({
|
||||||
type: 'none',
|
type: 'none',
|
||||||
},
|
},
|
||||||
fastRefresh: {},
|
fastRefresh: {},
|
||||||
|
// antd: {
|
||||||
|
// dark: true,
|
||||||
|
// },
|
||||||
mfsu: {},
|
mfsu: {},
|
||||||
esbuild: {},
|
esbuild: {},
|
||||||
webpack5: {},
|
webpack5: {},
|
||||||
|
|
|
@ -98,6 +98,7 @@
|
||||||
"@types/uuid": "^8.3.4",
|
"@types/uuid": "^8.3.4",
|
||||||
"@umijs/plugin-antd": "^0.15.0",
|
"@umijs/plugin-antd": "^0.15.0",
|
||||||
"@umijs/plugin-esbuild": "^1.4.1",
|
"@umijs/plugin-esbuild": "^1.4.1",
|
||||||
|
"@umijs/ssr-darkreader": "^4.9.45",
|
||||||
"@umijs/test": "^3.5.21",
|
"@umijs/test": "^3.5.21",
|
||||||
"ansi-to-react": "^6.1.6",
|
"ansi-to-react": "^6.1.6",
|
||||||
"antd": "^4.20.5",
|
"antd": "^4.20.5",
|
||||||
|
@ -105,7 +106,6 @@
|
||||||
"codemirror": "^5.65.2",
|
"codemirror": "^5.65.2",
|
||||||
"compression-webpack-plugin": "9.2.0",
|
"compression-webpack-plugin": "9.2.0",
|
||||||
"concurrently": "^7.0.0",
|
"concurrently": "^7.0.0",
|
||||||
"darkreader": "4.9.44",
|
|
||||||
"lint-staged": "^12.3.4",
|
"lint-staged": "^12.3.4",
|
||||||
"nodemon": "^2.0.15",
|
"nodemon": "^2.0.15",
|
||||||
"prettier": "^2.5.1",
|
"prettier": "^2.5.1",
|
||||||
|
|
|
@ -55,7 +55,7 @@
|
||||||
.ant-pro-page-container-children-content {
|
.ant-pro-page-container-children-content {
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
background-color: #fff;
|
background-color: @component-background;
|
||||||
padding: 16px;
|
padding: 16px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -172,7 +172,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.Resizer {
|
.Resizer {
|
||||||
background: #fff;
|
background: @component-background;
|
||||||
opacity: 0.2;
|
opacity: 0.2;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
-moz-box-sizing: border-box;
|
-moz-box-sizing: border-box;
|
||||||
|
@ -284,7 +284,7 @@
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
color: rgba(0, 0, 0, 0.85);
|
color: @text-color;
|
||||||
|
|
||||||
.side-menu-collapse-button:hover {
|
.side-menu-collapse-button:hover {
|
||||||
color: #1890ff;
|
color: #1890ff;
|
||||||
|
@ -301,11 +301,11 @@
|
||||||
text-align: left;
|
text-align: left;
|
||||||
outline: none;
|
outline: none;
|
||||||
padding: 4px 0;
|
padding: 4px 0;
|
||||||
border: 1px solid rgba(255, 255, 255, 0.12);
|
border: 1px solid fade(@component-background, 0.12);
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
|
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
background-color: #fff;
|
background-color: @component-background;
|
||||||
}
|
}
|
||||||
|
|
||||||
[data-dark='true'] .side-menu-user-drop-menu {
|
[data-dark='true'] .side-menu-user-drop-menu {
|
||||||
|
|
|
@ -1,11 +1,6 @@
|
||||||
import React, { useEffect, useState, useRef } from 'react';
|
import React, { useEffect, useState, useRef } from 'react';
|
||||||
import ProLayout, { PageLoading } from '@ant-design/pro-layout';
|
import ProLayout, { PageLoading } from '@ant-design/pro-layout';
|
||||||
import {
|
import * as DarkReader from '@umijs/ssr-darkreader';
|
||||||
enable as enableDarkMode,
|
|
||||||
disable as disableDarkMode,
|
|
||||||
auto as followSystemColorScheme,
|
|
||||||
setFetchMethod,
|
|
||||||
} from 'darkreader';
|
|
||||||
import defaultProps from './defaultProps';
|
import defaultProps from './defaultProps';
|
||||||
import { Link, history } from 'umi';
|
import { Link, history } from 'umi';
|
||||||
import {
|
import {
|
||||||
|
@ -35,6 +30,13 @@ export default function (props: any) {
|
||||||
const ws = useRef<any>(null);
|
const ws = useRef<any>(null);
|
||||||
const [socketMessage, setSocketMessage] = useState<any>();
|
const [socketMessage, setSocketMessage] = useState<any>();
|
||||||
const [collapsed, setCollapsed] = useState(false);
|
const [collapsed, setCollapsed] = useState(false);
|
||||||
|
const {
|
||||||
|
enable: enableDarkMode,
|
||||||
|
disable: disableDarkMode,
|
||||||
|
exportGeneratedCSS: collectCSS,
|
||||||
|
setFetchMethod,
|
||||||
|
auto: followSystemColorScheme,
|
||||||
|
} = DarkReader || {};
|
||||||
|
|
||||||
const logout = () => {
|
const logout = () => {
|
||||||
request.post(`${config.apiPrefix}user/logout`).then(() => {
|
request.post(`${config.apiPrefix}user/logout`).then(() => {
|
||||||
|
@ -121,7 +123,13 @@ export default function (props: any) {
|
||||||
init();
|
init();
|
||||||
|
|
||||||
const _theme = localStorage.getItem('qinglong_dark_theme') || 'auto';
|
const _theme = localStorage.getItem('qinglong_dark_theme') || 'auto';
|
||||||
setFetchMethod(window.fetch);
|
if (typeof window === 'undefined') return;
|
||||||
|
if (typeof window.matchMedia === 'undefined') return;
|
||||||
|
if (!DarkReader) {
|
||||||
|
return () => null;
|
||||||
|
}
|
||||||
|
setFetchMethod(fetch);
|
||||||
|
|
||||||
if (_theme === 'dark') {
|
if (_theme === 'dark') {
|
||||||
enableDarkMode({});
|
enableDarkMode({});
|
||||||
} else if (_theme === 'light') {
|
} else if (_theme === 'light') {
|
||||||
|
@ -129,6 +137,10 @@ export default function (props: any) {
|
||||||
} else {
|
} else {
|
||||||
followSystemColorScheme({});
|
followSystemColorScheme({});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
disableDarkMode();
|
||||||
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
|
@import '~antd/es/style/themes/default.less';
|
||||||
@import '~@/styles/variable.less';
|
@import '~@/styles/variable.less';
|
||||||
|
|
||||||
.left-tree {
|
.left-tree {
|
||||||
&-container {
|
&-container {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
position: relative;
|
position: relative;
|
||||||
background-color: #fff;
|
background-color: @component-background;
|
||||||
height: calc(100vh - 128px);
|
height: calc(100vh - 128px);
|
||||||
height: calc(100vh - var(--vh-offset, 0px) - 128px);
|
height: calc(100vh - var(--vh-offset, 0px) - 128px);
|
||||||
display: flex;
|
display: flex;
|
||||||
|
@ -25,6 +26,6 @@
|
||||||
:global {
|
:global {
|
||||||
.Pane.vertical.Pane1 {
|
.Pane.vertical.Pane1 {
|
||||||
padding-right: 5px;
|
padding-right: 5px;
|
||||||
border-right: 1px dashed #f0f0f0;
|
border-right: 1px dashed @text-color;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
|
@import '~antd/es/style/themes/default.less';
|
||||||
@import '~@/styles/variable.less';
|
@import '~@/styles/variable.less';
|
||||||
|
|
||||||
.left-tree {
|
.left-tree {
|
||||||
&-container {
|
&-container {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
position: relative;
|
position: relative;
|
||||||
background-color: #fff;
|
background-color: @component-background;
|
||||||
height: calc(100vh - 128px);
|
height: calc(100vh - 128px);
|
||||||
height: calc(100vh - var(--vh-offset, 0px) - 128px);
|
height: calc(100vh - var(--vh-offset, 0px) - 128px);
|
||||||
display: flex;
|
display: flex;
|
||||||
|
@ -25,6 +26,6 @@
|
||||||
:global {
|
:global {
|
||||||
.Pane.vertical.Pane1 {
|
.Pane.vertical.Pane1 {
|
||||||
padding-right: 5px;
|
padding-right: 5px;
|
||||||
border-right: 1px dashed #f0f0f0;
|
border-right: 1px dashed @text-color;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,12 +17,7 @@ import {
|
||||||
import config from '@/utils/config';
|
import config from '@/utils/config';
|
||||||
import { PageContainer } from '@ant-design/pro-layout';
|
import { PageContainer } from '@ant-design/pro-layout';
|
||||||
import { request } from '@/utils/http';
|
import { request } from '@/utils/http';
|
||||||
import {
|
import * as DarkReader from '@umijs/ssr-darkreader';
|
||||||
enable as enableDarkMode,
|
|
||||||
disable as disableDarkMode,
|
|
||||||
auto as followSystemColorScheme,
|
|
||||||
setFetchMethod,
|
|
||||||
} from 'darkreader';
|
|
||||||
import AppModal from './appModal';
|
import AppModal from './appModal';
|
||||||
import {
|
import {
|
||||||
EditOutlined,
|
EditOutlined,
|
||||||
|
@ -126,6 +121,13 @@ const Setting = ({
|
||||||
const [notificationInfo, setNotificationInfo] = useState<any>();
|
const [notificationInfo, setNotificationInfo] = useState<any>();
|
||||||
const [logRemoveFrequency, setLogRemoveFrequency] = useState<number>();
|
const [logRemoveFrequency, setLogRemoveFrequency] = useState<number>();
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
|
const {
|
||||||
|
enable: enableDarkMode,
|
||||||
|
disable: disableDarkMode,
|
||||||
|
exportGeneratedCSS: collectCSS,
|
||||||
|
setFetchMethod,
|
||||||
|
auto: followSystemColorScheme,
|
||||||
|
} = DarkReader || {};
|
||||||
|
|
||||||
const themeChange = (e: any) => {
|
const themeChange = (e: any) => {
|
||||||
setTheme(e.target.value);
|
setTheme(e.target.value);
|
||||||
|
@ -301,15 +303,27 @@ const Setting = ({
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setFetchMethod(window.fetch);
|
const _theme = localStorage.getItem('qinglong_dark_theme') || 'auto';
|
||||||
if (theme === 'dark') {
|
if (typeof window === 'undefined') return;
|
||||||
|
if (typeof window.matchMedia === 'undefined') return;
|
||||||
|
if (!DarkReader) {
|
||||||
|
return () => null;
|
||||||
|
}
|
||||||
|
setFetchMethod(fetch);
|
||||||
|
|
||||||
|
if (_theme === 'dark') {
|
||||||
enableDarkMode({});
|
enableDarkMode({});
|
||||||
} else if (theme === 'light') {
|
} else if (_theme === 'light') {
|
||||||
disableDarkMode();
|
disableDarkMode();
|
||||||
} else {
|
} else {
|
||||||
followSystemColorScheme({});
|
followSystemColorScheme({});
|
||||||
}
|
}
|
||||||
reloadTheme(theme);
|
reloadTheme(theme);
|
||||||
|
|
||||||
|
// unmount
|
||||||
|
return () => {
|
||||||
|
disableDarkMode();
|
||||||
|
};
|
||||||
}, [theme]);
|
}, [theme]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -15,7 +15,7 @@ export function init() {
|
||||||
// monaco 编辑器配置cdn和locale
|
// monaco 编辑器配置cdn和locale
|
||||||
loader.config({
|
loader.config({
|
||||||
paths: {
|
paths: {
|
||||||
vs: 'https://cdn.staticfile.org/monaco-editor/0.32.1/min/vs',
|
vs: 'https://cdn.staticfile.org/monaco-editor/0.33.0/min/vs',
|
||||||
},
|
},
|
||||||
'vs/nls': {
|
'vs/nls': {
|
||||||
availableLanguages: {
|
availableLanguages: {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user