This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var darkQuery = window.matchMedia('(prefers-color-scheme: dark)') | |
| if (!initialTheme) { | |
| initialTheme = darkQuery.matches ? 'dark' : 'light' | |
| } | |
| setTheme(initialTheme) | |
| darkQuery.addEventListener('change', function (e) { | |
| if (!preferredTheme) { | |
| setTheme(e.matches ? 'dark' : 'light') | |
| } | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const keyForState = Symbol('key-for-state'); | |
| type state = { | |
| base: any, | |
| copy: any, | |
| } | |
| const createProxy = (value: any) => { | |
| const state: state = { | |
| base: value, | |
| copy: null, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const searchValid = (context, event) => { | |
| return context.canSearch && event.query && event.query.length > 0; | |
| } | |
| const searchMachine = Machine( | |
| { | |
| id: 'search', | |
| initial: 'idle', | |
| context: { | |
| canSearch: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var winston = require('winston'); | |
| require('winston-daily-rotate-file'); | |
| var transport = new (winston.transports.DailyRotateFile)({ | |
| filename: 'application-%DATE%.log', | |
| datePattern: 'YYYY-MM-DD-HH', | |
| zippedArchive: true, | |
| maxSize: '20m', | |
| maxFiles: '14d' | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const debounce = (func, delay) => { | |
| let inDebounce | |
| return function() { | |
| const context = this | |
| const args = arguments | |
| clearTimeout(inDebounce) | |
| inDebounce = setTimeout(() => func.apply(context, args), delay) | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { Component } from "react"; | |
| import { EditorState, convertToRaw, convertFromRaw } from "draft-js"; | |
| import { Editor } from "react-draft-wysiwyg"; | |
| import { translate } from "react-translate"; | |
| import { connect } from "react-redux"; | |
| import { TEXT_CHANGED } from "../../actions"; | |
| class TextEditor extends Component { | |
| constructor(props) { | |
| super(props); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from "react"; | |
| import { connect } from "react-redux"; | |
| import S3 from "aws-s3"; | |
| import { | |
| DELETE_ATTACHMENT_REQUEST, | |
| GET_ATTACHMENTS_REQUEST, | |
| START_UPLOADING, | |
| UPLOAD_ATTACHMENT_REQUEST | |
| } from "../actions"; | |
| import {Icon} from "../../../../layout"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var BROWSER_TYPE = detectBrowserType(); | |
| //debounce | |
| function debounce(func, wait, immediate) { | |
| var timeout; | |
| return function () { | |
| var context = this, | |
| args = arguments; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const usePagination = (fetchApi) => { | |
| const [query, setQuery] = useState({ page: 1, size: 15 }); // 初始页码为: 1 | |
| const [isError, setIsError] = useState(false); // 初始状态为false | |
| const [list, setList] = useState([]); // 初始列表数据为空数组: [] | |
| useEffect(() => { | |
| setIsError(false); | |
| fetchApi(query) | |
| .then(setList) | |
| .catch(() => setIsError(true)); |
NewerOlder