From 83493032a5591414b95eaae2d9ffa09a9a81fc5a Mon Sep 17 00:00:00 2001 From: "shiqi.li" <1009903985@qq.com> Date: Mon, 3 Jun 2019 22:43:38 +0800 Subject: [PATCH] :sparkles: add: clipboard --- render/views/System/index.js | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/render/views/System/index.js b/render/views/System/index.js index 177c694..9c13f08 100644 --- a/render/views/System/index.js +++ b/render/views/System/index.js @@ -1,10 +1,10 @@ import React from 'react'; -import { Button, Alert } from 'antd'; +import { Button, Alert, Input } from 'antd'; import electron from 'electron'; import os from 'os'; import styles from './index.css'; -const { remote } = electron; +const { remote, clipboard } = electron; const { app } = remote; @@ -19,6 +19,9 @@ class System extends React.Component { node: '', v8: '', systemPath: '', + text: '复制我呀', + copy: '', + copyVal: '' } } @@ -34,9 +37,25 @@ class System extends React.Component { this.setState({ systemPath: os.homedir() }) } + changeText = (e) => { + this.setState({ text: e.target.value }) + } + + copy = () => { + clipboard.writeText(this.state.text); + this.setState({ + copy: '复制成功!' + this.state.text + }) + } + + copyVal = () => { + this.setState({ + copyVal: clipboard.readText() + }) + } render() { - const { appPath, electron, chrome, node, v8, systemPath } = this.state; + const { appPath, electron, chrome, node, v8, systemPath, text, copy, copyVal } = this.state; return (
@@ -51,6 +70,14 @@ class System extends React.Component { {node && } {v8 && } + + + + + + + +
); }