@@ -7,7 +7,7 @@ import ZoomIcon from './components/zoom'; | |||||
import logoImg from './assets/logo.png'; | import logoImg from './assets/logo.png'; | ||||
import { useModel } from 'umi'; | import { useModel } from 'umi'; | ||||
import UserCenter from './components/userCenter'; | import UserCenter from './components/userCenter'; | ||||
import system, { isClient } from '@/services/system'; | |||||
import system from '@/services/system'; | |||||
import SvgIcon from '../SvgIcon'; | import SvgIcon from '../SvgIcon'; | ||||
import classNames from 'classnames'; | import classNames from 'classnames'; | ||||
import { CloudDownloadOutlined } from '@ant-design/icons'; | import { CloudDownloadOutlined } from '@ant-design/icons'; | ||||
@@ -15,6 +15,7 @@ import ATooltip from '../Tooltip'; | |||||
import SyncModal from '../SyncModal'; | import SyncModal from '../SyncModal'; | ||||
import { useState } from 'react'; | import { useState } from 'react'; | ||||
import storage from '@/utils/storage'; | import storage from '@/utils/storage'; | ||||
import { isClient } from '@/utils/tool'; | |||||
export default function AppHeader(props) { | export default function AppHeader(props) { | ||||
const { className, style } = props; | const { className, style } = props; | ||||
@@ -12,8 +12,8 @@ import { useState } from 'react'; | |||||
import styles from './UserCenter.less'; | import styles from './UserCenter.less'; | ||||
import defaultAvatorImg from '@/assets/avator_default.svg'; | import defaultAvatorImg from '@/assets/avator_default.svg'; | ||||
import FolderSetModal from './FolderSetModal'; | import FolderSetModal from './FolderSetModal'; | ||||
import { isClient } from '@/services/system'; | |||||
import storage from '@/utils/storage'; | import storage from '@/utils/storage'; | ||||
import { isClient } from '@/utils/tool'; | |||||
interface UserCenterProps { | interface UserCenterProps { | ||||
className?: string; | className?: string; | ||||
@@ -6,13 +6,17 @@ import { MobileFilled, LockFilled } from '@ant-design/icons'; | |||||
import { useCallback } from 'react'; | import { useCallback } from 'react'; | ||||
import { useEffect } from 'react'; | import { useEffect } from 'react'; | ||||
import { login } from '@/services/user'; | import { login } from '@/services/user'; | ||||
import { firstCharToUpperCase, handleRequest, passwordReg } from '@/utils/tool'; | |||||
import { | |||||
firstCharToUpperCase, | |||||
handleRequest, | |||||
isClient, | |||||
passwordReg, | |||||
} from '@/utils/tool'; | |||||
import { useForm } from 'antd/lib/form/Form'; | import { useForm } from 'antd/lib/form/Form'; | ||||
import classNames from 'classnames'; | import classNames from 'classnames'; | ||||
import SmsInputer from './SmsInputer'; | import SmsInputer from './SmsInputer'; | ||||
import { memoize } from 'lodash'; | import { memoize } from 'lodash'; | ||||
import { Rule } from 'antd/lib/form'; | import { Rule } from 'antd/lib/form'; | ||||
import { isClient } from '@/services/system'; | |||||
import storage from '@/utils/storage'; | import storage from '@/utils/storage'; | ||||
import { useRef } from 'react'; | import { useRef } from 'react'; | ||||
import { useLayoutEffect } from 'react'; | import { useLayoutEffect } from 'react'; | ||||
@@ -1,8 +1,9 @@ | |||||
import { fetchLocalApi } from '@/utils/request'; | import { fetchLocalApi } from '@/utils/request'; | ||||
import { isClient } from '@/utils/tool'; | |||||
import { DATA } from './API'; | import { DATA } from './API'; | ||||
import { sendSocketMessage } from './socket'; | import { sendSocketMessage } from './socket'; | ||||
export const isClient = !!window.ipcRenderer; // process.env.IS_CLIENT; | |||||
console.log('system initial: ????'); | |||||
const noop = () => {}; | const noop = () => {}; | ||||
const safeCall = <T>(f: T, repalceF = noop) => (isClient ? f : repalceF); | const safeCall = <T>(f: T, repalceF = noop) => (isClient ? f : repalceF); | ||||
@@ -3,7 +3,7 @@ import { fetchApi } from '@/utils/request'; | |||||
import storage from '@/utils/storage'; | import storage from '@/utils/storage'; | ||||
import { errorReponse, firstCharToLowerCase, isReqSuccess } from '@/utils/tool'; | import { errorReponse, firstCharToLowerCase, isReqSuccess } from '@/utils/tool'; | ||||
import { propertyOf } from 'lodash'; | import { propertyOf } from 'lodash'; | ||||
import system, { isClient } from './system'; | |||||
import system from './system'; | |||||
import { DATA } from './API'; | import { DATA } from './API'; | ||||
export async function queryCurrent() { | export async function queryCurrent() { | ||||
@@ -2,11 +2,11 @@ import { useCallback, useEffect, useState } from 'react'; | |||||
import { | import { | ||||
firstCharToLowerCase, | firstCharToLowerCase, | ||||
firstCharToUpperCase, | firstCharToUpperCase, | ||||
isClient, | |||||
Subject, | Subject, | ||||
} from '@/utils/tool'; | } from '@/utils/tool'; | ||||
import { API, DATA } from '@/services/API'; | import { API, DATA } from '@/services/API'; | ||||
import dayjs from 'dayjs'; | import dayjs from 'dayjs'; | ||||
import { isClient } from '@/services/system'; | |||||
import { throttle } from 'lodash'; | import { throttle } from 'lodash'; | ||||
import { fetchApi } from './request'; | import { fetchApi } from './request'; | ||||
import storage from './storage'; | import storage from './storage'; | ||||
@@ -1,9 +1,13 @@ | |||||
import { API } from '@/services/API'; | import { API } from '@/services/API'; | ||||
import { isClient } from '@/services/system'; | |||||
import { message } from 'antd'; | import { message } from 'antd'; | ||||
import { request } from 'umi'; | import { request } from 'umi'; | ||||
import { parseRequest } from './request.config'; | import { parseRequest } from './request.config'; | ||||
import { errorReponse, firstCharToLowerCase, handleRequest } from './tool'; | |||||
import { | |||||
errorReponse, | |||||
firstCharToLowerCase, | |||||
handleRequest, | |||||
isClient, | |||||
} from './tool'; | |||||
const remoteUrl = window.systemConfig?.remoteUrl || ''; | const remoteUrl = window.systemConfig?.remoteUrl || ''; | ||||
const gatewayPort = window.systemConfig?.gatewayPort || 7888; | const gatewayPort = window.systemConfig?.gatewayPort || 7888; | ||||
@@ -1,5 +1,6 @@ | |||||
import system, { isClient } from '@/services/system'; | |||||
import system from '@/services/system'; | |||||
import { identity } from 'lodash'; | import { identity } from 'lodash'; | ||||
import { isClient } from './tool'; | |||||
const keepSaveKeyMap = new Map(); | const keepSaveKeyMap = new Map(); | ||||
@@ -35,12 +36,13 @@ const storage = { | |||||
}; | }; | ||||
if (isClient && window.addIpcRendererListener) { | if (isClient && window.addIpcRendererListener) { | ||||
console.log('try to reload local data'); | |||||
storage.clear(); | storage.clear(); | ||||
window.addIpcRendererListener( | window.addIpcRendererListener( | ||||
'initialStorageData', | 'initialStorageData', | ||||
(_, hash: { keyList?: string[]; [key: string]: any }) => { | (_, hash: { keyList?: string[]; [key: string]: any }) => { | ||||
const kList = hash.keyList || []; | const kList = hash.keyList || []; | ||||
console.log('reload data:', hash); | |||||
kList.forEach((key: string) => { | kList.forEach((key: string) => { | ||||
keepSaveKeyMap.set(key, true); | keepSaveKeyMap.set(key, true); | ||||
storage.set(key, hash[key]); | storage.set(key, hash[key]); | ||||
@@ -1,3 +1,7 @@ | |||||
console.log('initial tool.js'); | |||||
export const isClient = !!window.ipcRenderer; // process.env.IS_CLIENT; | |||||
export function firstCharToLowerCase(obj: any) { | export function firstCharToLowerCase(obj: any) { | ||||
return Object.entries(obj).reduce( | return Object.entries(obj).reduce( | ||||
(o: { [key: string]: any }, [key, value]) => { | (o: { [key: string]: any }, [key, value]) => { | ||||