Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
马贞晓
/
templateReact
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 3bb186c3
authored
Nov 12, 2019
by
马贞晓
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
修改
1 parent
4756f733
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
157 additions
and
14 deletions
config/env.js
config/webpackDevServer.config.js
src/component/layout/App.js
src/component/layout/LayoutHeader.js
src/component/layout/LayoutSlide.js
src/index.js
src/router/App.js
src/router/index.js
src/service/index.js
src/utils/index.js
src/view/index/index.js
config/env.js
View file @
3bb186c
...
...
@@ -61,6 +61,7 @@ process.env.NODE_PATH = (process.env.NODE_PATH || '')
const
REACT_APP
=
/^REACT_APP_/i
;
function
getClientEnvironment
(
publicUrl
)
{
const
raw
=
Object
.
keys
(
process
.
env
)
.
filter
(
key
=>
REACT_APP
.
test
(
key
))
.
reduce
(
...
...
@@ -79,6 +80,7 @@ function getClientEnvironment(publicUrl) {
PUBLIC_URL
:
publicUrl
,
}
);
// Stringify all values so we can feed into Webpack DefinePlugin
const
stringified
=
{
'process.env'
:
Object
.
keys
(
raw
).
reduce
((
env
,
key
)
=>
{
...
...
config/webpackDevServer.config.js
View file @
3bb186c
...
...
@@ -102,7 +102,7 @@ module.exports = function(proxy, allowedHost) {
// it used the same host and port.
// https://github.com/facebook/create-react-app/issues/2272#issuecomment-302832432
app
.
use
(
noopServiceWorkerMiddleware
());
console
.
log
(
app
);
//
console.log(app);
},
};
};
src/component/layout/App.js
View file @
3bb186c
...
...
@@ -3,29 +3,29 @@ import Routers from "../../router";
import
store
from
"../../store"
;
import
{
Provider
}
from
'react-redux'
import
"./less/App.less"
;
import
{
Layout
,
Menu
,
Breadcrumb
,
Icon
}
from
'antd'
;
import
{
Layout
}
from
'antd'
;
import
LayoutHeader
from
"./LayoutHeader"
;
import
LayoutSlide
from
"./LayoutSlide"
;
import
LayoutFooter
from
"./LayoutFooter"
;
const
{
SubMenu
}
=
Menu
;
const
{
Header
,
Content
,
Footer
,
Sider
}
=
Layout
;
class
App
extends
Component
{
render
(){
console
.
log
(
LayoutFooter
);
//
console.log(LayoutFooter);
return
<
Provider
store
=
{
store
}
>
<
Layout
className
=
"h100"
>
<
Header
className
=
"header"
>
<
LayoutHeader
title
=
"头部"
/>
<
/Header
>
<
Content
style
=
{{
padding
:
'0 50px'
,
display
:
"flex"
}}
>
<
Layout
style
=
{{
padding
:
'24px 0'
,
background
:
'#fff'
}}
>
<
Sider
width
=
{
200
}
style
=
{{
background
:
'#fff'
}}
>
<
LayoutSlide
title
=
"侧边"
/>
<
LayoutSlide
data
=
"fdafdsa"
title
=
"侧边"
/>
<
/Sider
>
<
Content
style
=
{{
padding
:
'0 24px'
,
minHeight
:
280
,
display
:
"flex"
}}
>
<
Routers
title
=
"路由"
/>
...
...
src/component/layout/LayoutHeader.js
View file @
3bb186c
import
React
,{
Component
}
from
'react'
import
{
Layout
,
Menu
,
Breadcrumb
,
Icon
}
from
'antd'
;
import
{
Layout
,
Menu
,
}
from
'antd'
;
const
{
SubMenu
}
=
Menu
;
const
{
Header
,
Content
,
Footer
,
Sider
}
=
Layout
;
class
LayoutHeader
extends
Component
{
render
(){
...
...
src/component/layout/LayoutSlide.js
View file @
3bb186c
...
...
@@ -4,6 +4,9 @@ const { SubMenu } = Menu;
const
{
Header
,
Content
,
Footer
,
Sider
}
=
Layout
;
export
default
class
LayoutSlide
extends
Component
{
componentWillMount
(){
console
.
log
(
this
.
props
);
}
render
(){
return
<
Menu
mode
=
"inline"
...
...
src/index.js
View file @
3bb186c
...
...
@@ -3,7 +3,8 @@ import ReactDOM from 'react-dom';
import
'./less/index.less'
;
import
App
from
'./component/layout/App'
;
import
*
as
serviceWorker
from
'./serviceWorker'
;
import
axios
from
"./service/index"
import
axios
from
"./service/index"
;
ReactDOM
.
render
(
<
App
/>
,
document
.
getElementById
(
'root'
));
// If you want your app to work offline and load faster, you can change
...
...
src/router/App.js
View file @
3bb186c
import
{
lazy
}
from
'react'
;
export
default
[
{
path
:
"/"
,
component
:
lazy
(()
=>
import
(
/* webpackChunkName: "Index" */
"../view/index/index.js"
))}
{
path
:
"/system/index"
,
component
:
lazy
(()
=>
import
(
/* webpackChunkName: "Index" */
"../view/index/index.js"
))},
{
path
:
"system/index2"
,
component
:
lazy
(()
=>
import
(
/* webpackChunkName: "Index" */
"../view/index/index.js"
))}
]
\ No newline at end of file
src/router/index.js
View file @
3bb186c
...
...
@@ -8,7 +8,7 @@ import Load from "../component/loading/index.js";
//import Demo from "../view/index/index";
//const Demo = lazy(()=>import(/* webpackChunkName: "Index" */ "../view/index/index.js"))
import
App
from
"./App.js"
;
let
List
=
[
{
path
:
"/"
,
component
:
lazy
(()
=>
import
(
/* webpackChunkName: "Index" */
"../view/index/index.js"
))}];
//
let List = [ { path:"/",component:lazy(()=>import(/* webpackChunkName: "Index" */ "../view/index/index.js"))}];
class
Routers
extends
Component
{
state
=
{
...
...
src/service/index.js
View file @
3bb186c
...
...
@@ -48,6 +48,7 @@ let config = {
export
default
{
GET
(
target
,
params
=
{}){
return
_axios
.
get
((
target
),{
params
})
},
POST
(
target
,
params
=
{}){
return
_axios
.
post
((
target
),
params
)
...
...
src/utils/index.js
0 → 100644
View file @
3bb186c
const
$polysoft
=
"$polysoft"
/**
* @name 获取location
*/
export
let
locationFormat
=
()
=>
{
let
_search
=
location
.
search
.
length
>
location
.
hash
.
length
?
location
.
search
:
location
.
hash
;
_search
=
_search
.
substr
(
_search
.
indexOf
(
"?"
)
+
1
,
_search
.
length
-
1
);
let
str
=
`'
${
decodeURIComponent
(
_search
).
replace
(
/^
(?!\?
|#
)
/ig
,
""
).
replace
(
/&/ig
,
"','"
).
replace
(
/
\=
/ig
,
"':'"
)}
'`
.
split
(
","
).
map
(
d
=>
(
d
.
includes
(
":"
)?
d
:
d
+
":''"
));
str
=
`{
${
str
}
}`
;
console
.
log
(
str
,
111
);
return
new
Function
(
"return "
+
str
)();
}
/**
* @name 本地存储
*/
export
let
storeSet
=
(
key
,
val
,
time
)
=>
{
if
(
!
val
)
{
return
key
}
let
name
=
key
.
includes
(
$polysoft
)
?
key
:
$polysoft
+
key
let
opt
=
{
key
:
name
,
val
,
type
:
isType
(
val
),
createTime
:
Date
.
now
(),
time
}
sessionStorage
.
setItem
(
name
,
JSON
.
stringify
(
opt
))
}
export
let
storeGet
=
(
key
)
=>
{
let
name
=
key
.
includes
(
$polysoft
)
?
key
:
$polysoft
+
key
let
date
=
Date
.
now
()
let
data
=
sessionStorage
.
getItem
(
name
)
if
(
data
)
{
let
da
=
JSON
.
parse
(
data
)
if
(
da
.
time
&&
da
.
time
>=
date
)
{
storeDel
(
name
)
}
return
da
.
val
}
else
{
return
null
}
}
export
let
storeDel
=
(
key
)
=>
{
if
(
key
&&
isType
(
key
)
==
'String'
)
{
let
name
=
$polysoft
+
key
key
.
includes
(
$polysoft
)
?
sessionStorage
.
removeItem
(
key
)
:
sessionStorage
.
removeItem
(
name
)
}
}
export
let
storeAll
=
()
=>
{
let
item
=
sessionStorage
,
list
=
[]
for
(
let
i
=
0
;
i
<
item
.
length
;
i
++
)
{
let
keys
=
sessionStorage
.
key
(
i
)
if
(
keys
.
includes
(
$polysoft
))
{
list
.
push
(
getItem
(
keys
))
}
}
return
list
}
//常用呢类型判断
export
let
isType
=
(
obj
)
=>
{
if
(
obj
)
{
return
/
\[
object
(
.*
?)\]
/gi
.
exec
(
Object
.
prototype
.
toString
.
call
(
obj
))[
1
]
.
trim
()
}
return
'undefined'
}
/**
* @name 拼图
* @param {data} Array 只包含src的数组
* @param {width} Int 单个图片宽度
* @param {height} Int 单个图片高度
* @param {col} Int 列数
* @param {row} Int 行数
*/
export
const
jigsaw
=
({
data
=
[],
width
=
15
,
height
=
15
,
col
=
3
,
row
=
3
})
=>
{
const
canvas
=
document
.
createElement
(
"canvas"
);
const
d2
=
canvas
.
getContext
(
"2d"
);
let
j
=
2
;
//间隙宽度
let
x
,
y
;
//每次
x
=
y
=
0
;
let
_width
=
width
*
col
+
(
j
*
(
col
-
1
))
+
j
;
let
_height
=
height
*
row
+
(
j
*
(
row
-
1
))
+
j
;
Object
.
assign
(
canvas
,{
width
:
_width
,
height
:
_height
})
d2
.
fillStyle
=
"rgba(0,0,0,0.1)"
;
d2
.
fillRect
(
0
,
0
,
_width
,
_height
);
let
primise
=
data
.
map
((
d
,
index
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
let
img
=
new
Image
();
//img.src = 'http://10.10.80.99:808/nas/images/app/20190412180056f96b2939-ac07-4502-ab0e-6fbd327ed80d.jpg';
img
.
src
=
'image/HeadPortrait2.png?d='
+
Date
.
now
();
img
.
crossOrigin
=
""
;
img
.
addEventListener
(
"load"
,(
ev
)
=>
{
resolve
(
img
)
},
false
)
})
})
return
Promise
.
all
(
primise
)
.
then
(
data
=>
{
data
.
forEach
((
el
,
ind
)
=>
{
x
=
(
ind
%
col
);
d2
.
drawImage
(
el
,
x
*
width
+
(
x
+
j
),
y
*
height
+
(
y
+
j
),
width
,
height
);
if
((
ind
+
1
)
%
col
==
0
){
y
+=
1
}
})
return
canvas
.
toDataURL
(
"image/png"
);
})
}
src/view/index/index.js
View file @
3bb186c
...
...
@@ -3,13 +3,16 @@ import PropTypes from 'prop-types';
import
{
connect
}
from
"react-redux"
;
import
EVENT
from
"../../store/EVENT"
import
$http
from
"../../service"
;
//import * as utils from "../../utils/index";
@
connect
((
state
)
=>
{
// debugger
let
{
layout
,
login
}
=
state
return
{
layout
,
login
};
})
class
Demo
extends
Component
{
state
=
{
list
:[
1
,
2
,
3
]
}
componentDidMount
(){
// debugger
console
.
log
(
$http
)
...
...
@@ -22,7 +25,7 @@ import $http from "../../service";
* @name 同步修改
*/
EventClick
(
item
){
console
.
log
(
this
.
props
);
this
.
props
.
dispatch
({
type
:
EVENT
.
LAYOUT
,
payload
:{
...
...
@@ -42,10 +45,23 @@ import $http from "../../service";
}
})
}
/**
*
*/
EventClickSetList
(
item
,
ind
){
let
{
list
}
=
this
.
state
;
list
[
ind
]
=
item
+
1
;
this
.
setState
({
list
})
}
render
(){
let
{
layout
,
login
}
=
this
.
props
;
console
.
log
(
layout
,
login
)
//
console.log(layout,login)
return
<
article
>
{
this
.
state
.
list
.
map
((
item
,
ind
)
=>
{
return
<
span
style
=
{{
margin
:
10
}}
onClick
=
{
this
.
EventClickSetList
.
bind
(
this
,
item
,
ind
)}
key
=
{
ind
}
>
{
item
}
<
/span
>
})
}
<
p
>
同步修改
<
/p
>
{
layout
.
menuList
.
map
((
d
,
ind
)
=>
{
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment