Skip to content

Commit

Permalink
eslint fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinmoch committed Mar 29, 2020
1 parent 10ebbff commit 38fa5c7
Show file tree
Hide file tree
Showing 47 changed files with 13,085 additions and 662 deletions.
7 changes: 2 additions & 5 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ module.exports = {
env: {
node: true
},
extends:
process.env.PLATFORM_ENV === "react"
? ["react-app"]
: ["plugin:vue/essential", "@vue/standard"],
extends: process.env.PLATFORM_ENV === "react" ? ["react-app"] : ["plugin:vue/essential", "@vue/standard"],
rules: {
"one-var": "off",
"no-mixed-operators": "off",
Expand All @@ -24,4 +21,4 @@ module.exports = {
parserOptions: {
parser: "babel-eslint"
}
};
}
4 changes: 2 additions & 2 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
presets: [process.env.PLATFORM_ENV === "react" ? "react-app" : "@vue/app"]
};
presets: [process.env.PLATFORM_ENV === 'react' ? 'react-app' : '@vue/app']
}
16 changes: 8 additions & 8 deletions config-overrides.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
const path = require("path");
const fs = require("fs");
const path = require('path')
const fs = require('fs')

const appDirectory = fs.realpathSync(process.cwd());
const resolveApp = relativePath => path.resolve(appDirectory, relativePath);
const appDirectory = fs.realpathSync(process.cwd())
const resolveApp = relativePath => path.resolve(appDirectory, relativePath)

module.exports = {
paths: function(paths, env) {
paths.appBuild = resolveApp("dist/react");
paths.appHtml = resolveApp("public/react.html");
return paths;
paths.appBuild = resolveApp('dist/react')
paths.appHtml = resolveApp('public/react.html')
return paths
}
};
}
50 changes: 23 additions & 27 deletions http-server.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,32 @@
var express = require("express");
var compression = require("compression");
var http = require("http");
var path = require("path");
var portrange = 8090;
var app = express();
var express = require('express')
var compression = require('compression')
var http = require('http')
var path = require('path')
var portrange = 8090
var app = express()

app.use(compression());
app.use("/", express.static(path.resolve(__dirname, "./dist/")));
app.use(compression())
app.use('/', express.static(path.resolve(__dirname, './dist/')))

function getPort(cb) {
var port = portrange;
portrange += 1;
var port = portrange
portrange += 1

var server = http.createServer();
var server = http.createServer()
server.listen(port, function() {
server.once("close", function() {
cb(port);
});
server.close();
});
server.on("error", function() {
getPort(cb);
});
server.once('close', function() {
cb(port)
})
server.close()
})
server.on('error', function() {
getPort(cb)
})
}

getPort(function(port) {
app.listen(port, function() {
require("child_process").exec(
"start chrome http://localhost:" + port + "/vue"
);
require("child_process").exec(
"start chrome http://localhost:" + port + "/react"
);
});
});
require('child_process').exec('start chrome http://localhost:' + port + '/vue')
require('child_process').exec('start chrome http://localhost:' + port + '/react')
})
})
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,16 @@
"@babel/parser": "7.7.5"
},
"browserslist": {
"production": [">0.2%", "not dead", "not op_mini all"],
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"keywords": []
}
}
3 changes: 2 additions & 1 deletion public/card.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified public/react.ico
Binary file not shown.
Binary file modified public/vue.ico
Binary file not shown.
79 changes: 27 additions & 52 deletions src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,72 +1,47 @@
import React, { useState } from "react";
import { changeTheme, supportCssVars, enableCssVars, themeVars } from "./theme";
import Todo from "./views/Todo";
import tagVars from "./theme/Tag";
import todoVars from "./theme/Todo";
import "./style/app.scss";
import React, { useState } from 'react'
import { changeTheme, supportCssVars, enableCssVars, themeVars } from './theme'
import Todo from './views/Todo'
import tagVars from './theme/Tag'
import todoVars from './theme/Todo'
import './style/app.scss'

export default () => {
const [todoColor, setTodoColor] = useState(() =>
themeVars(Object.keys(todoVars)[0])
);
const [tagColor, setTagColor] = useState(() =>
themeVars(Object.keys(tagVars)[0])
);
const [fontSize, setFontSize] = useState(() => themeVars("aui-font-size"));
const [theme, setTheme] = useState(themeVars());
const [title] = useState("New Tag");
const [todoColor, setTodoColor] = useState(() => themeVars(Object.keys(todoVars)[0]))
const [tagColor, setTagColor] = useState(() => themeVars(Object.keys(tagVars)[0]))
const [fontSize, setFontSize] = useState(() => themeVars('aui-font-size'))
const [theme, setTheme] = useState(themeVars())
const [title] = useState('New Tag')

const change = e => {
const apply = () => {
const { name, value } = e.target;
const { name, value } = e.target

name === "aui-tag-color" && setTagColor(value);
name === "aui-todo-color" && setTodoColor(value);
name === "aui-font-size" && setFontSize(value);
name === 'aui-tag-color' && setTagColor(value)
name === 'aui-todo-color' && setTodoColor(value)
name === 'aui-font-size' && setFontSize(value)

setTheme(Object.assign(theme, { [name]: value }));
changeTheme(theme);
};
setTheme(Object.assign(theme, { [name]: value }))
changeTheme(theme)
}

if (
!supportCssVars() &&
window.confirm("当前浏览器不支持主题切换,要启用兼容程序吗?")
) {
enableCssVars().then(apply);
if (!supportCssVars() && window.confirm('当前浏览器不支持主题切换,要启用兼容程序吗?')) {
enableCssVars().then(apply)
} else {
apply();
apply()
}
};
}

return (
<div id="app">
<div id="nav">
<span>更改 Tag 颜色 </span>
<input
name="aui-tag-color"
type="color"
size="4"
value={tagColor}
onChange={change}
/>
<input name="aui-tag-color" type="color" size="4" value={tagColor} onChange={change} />
<span>更改 {title} 颜色 </span>
<input
name="aui-todo-color"
type="color"
size="4"
value={todoColor}
onChange={change}
/>
<input name="aui-todo-color" type="color" size="4" value={todoColor} onChange={change} />
<span>更改字体大小 </span>
<input
name="aui-font-size"
type="text"
size="2"
value={fontSize}
onChange={change}
/>
<input name="aui-font-size" type="text" size="2" value={fontSize} onChange={change} />
</div>
<Todo />
</div>
);
};
)
}
Loading

0 comments on commit 38fa5c7

Please sign in to comment.