Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
teaching_admin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
huanglu
teaching_admin
Commits
150ec8e8
Commit
150ec8e8
authored
Sep 09, 2020
by
bobo826
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 项目结构优化
parent
2b2bbe2a
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
20 additions
and
174 deletions
+20
-174
index.vue
src/components/hello-world/index.vue
+0
-32
index.js
src/components/index.js
+2
-3
index.js
src/router/index.js
+0
-7
index.js
src/store/index.js
+13
-11
account.js
src/store/modules/account.js
+4
-5
cart.js
src/store/modules/cart.js
+0
-43
index.js
src/utils/index.js
+0
-1
index.vue
src/views/about/index.vue
+0
-5
index.vue
src/views/cart/index.vue
+0
-59
index.vue
src/views/home/index.vue
+1
-8
No files found.
src/components/hello-world/index.vue
deleted
100644 → 0
View file @
2b2bbe2a
<
template
>
<div
class=
"hello"
>
this is helloworld components
</div>
</
template
>
<
script
>
export
default
{
name
:
'HelloWorld'
,
props
:
{
msg
:
String
,
},
};
</
script
>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<
style
scoped
lang=
"scss"
>
h3
{
margin
:
40px
0
0
;
}
ul
{
list-style-type
:
none
;
padding
:
0
;
}
li
{
display
:
inline-block
;
margin
:
0
10px
;
}
a
{
color
:
#42b983
;
}
</
style
>
src/components/index.js
View file @
150ec8e8
import
HelloWorld
from
'./hello-world'
;
import
GkHeader
from
'./header'
;
import
GkHeader
from
'./Header'
;
export
{
HelloWorld
,
GkHeader
};
export
{
GkHeader
};
src/router/index.js
View file @
150ec8e8
...
@@ -2,8 +2,6 @@ import Vue from 'vue';
...
@@ -2,8 +2,6 @@ import Vue from 'vue';
import
VueRouter
from
'vue-router'
;
import
VueRouter
from
'vue-router'
;
import
Home
from
'@/views/home'
;
import
Home
from
'@/views/home'
;
const
Cart
=
()
=>
import
(
'@/views/cart'
);
Vue
.
use
(
VueRouter
);
Vue
.
use
(
VueRouter
);
// 单入口路由配置
// 单入口路由配置
...
@@ -12,11 +10,6 @@ const routes = [
...
@@ -12,11 +10,6 @@ const routes = [
path
:
'/'
,
path
:
'/'
,
name
:
'Home'
,
name
:
'Home'
,
component
:
Home
component
:
Home
},
{
path
:
'/cart'
,
name
:
'Cart'
,
component
:
Cart
}
}
];
];
...
...
src/store/index.js
View file @
150ec8e8
import
Vue
from
'vue'
;
import
Vue
from
'vue'
import
Vuex
from
'vuex'
;
import
Vuex
from
'vuex'
Vue
.
use
(
Vuex
)
;
Vue
.
use
(
Vuex
)
const
reqiureContext
=
require
.
context
(
'./modules'
,
false
,
/
\.
js$/
)
;
const
reqiureContext
=
require
.
context
(
'./modules'
,
false
,
/
\.
js$/
)
const
modules
=
{}
;
const
modules
=
{}
reqiureContext
.
keys
().
forEach
((
key
)
=>
{
reqiureContext
.
keys
().
forEach
((
key
)
=>
{
const
name
=
key
.
slice
(
2
,
-
3
);
// 得到 state的名称
const
name
=
key
.
slice
(
2
,
-
3
)
// 得到 state的名称
const
moduleConfig
=
reqiureContext
(
key
).
default
||
reqiureContext
(
key
);
console
.
log
(
'reqiureContext(key).default'
,
reqiureContext
(
key
).
default
)
modules
[
name
]
=
moduleConfig
;
console
.
log
(
'reqiureContext(key)'
,
reqiureContext
(
key
))
});
const
moduleConfig
=
reqiureContext
(
key
).
default
||
reqiureContext
(
key
)
modules
[
name
]
=
moduleConfig
})
export
default
new
Vuex
.
Store
({
export
default
new
Vuex
.
Store
({
namespaced
:
true
,
namespaced
:
true
,
modules
:
{
modules
:
{
...
modules
,
...
modules
,
}
,
}
})
;
})
src/store/modules/account.js
View file @
150ec8e8
...
@@ -2,21 +2,20 @@ const state = {
...
@@ -2,21 +2,20 @@ const state = {
username
:
'zhaoting'
,
username
:
'zhaoting'
,
address
:
''
,
address
:
''
,
token
:
''
,
token
:
''
,
};
}
const
mutations
=
{
const
mutations
=
{
changeName
(
state
,
payload
)
{
changeName
(
state
,
payload
)
{
state
.
username
=
payload
;
state
.
username
=
payload
;
},
},
}
;
}
const
getters
=
{
const
getters
=
{
currentUsername
:
(
state
)
=>
state
.
username
,
currentUsername
:
(
state
)
=>
state
.
username
,
}
;
}
export
default
{
export
default
{
state
,
state
,
getters
,
getters
,
mutations
,
mutations
,
}
;
}
src/store/modules/cart.js
deleted
100644 → 0
View file @
2b2bbe2a
const
state
=
{
carts
:
[],
};
const
actions
=
{
addCart
({
commit
},
cart
)
{
setTimeout
(()
=>
{
commit
(
'addCart'
,
cart
);
},
1000
);
},
deleteCart
({
commit
},
id
)
{
setTimeout
(()
=>
{
commit
(
'deleteCart'
,
id
);
},
1000
);
},
deleteAll
({
commit
})
{
setTimeout
(()
=>
{
commit
(
'deleteAll'
);
},
1000
);
},
};
const
mutations
=
{
addCart
(
state
,
product
)
{
const
{
carts
}
=
state
;
carts
.
push
(
product
);
state
.
carts
=
[...
carts
];
},
deleteCart
(
state
,
id
)
{
const
carts
=
[...
state
.
carts
.
filter
((
cart
)
=>
cart
.
id
!==
id
)];
state
.
carts
=
carts
;
},
deleteAll
()
{
state
.
carts
=
[];
},
};
export
default
{
namespaced
:
true
,
state
,
mutations
,
actions
,
};
src/utils/index.js
View file @
150ec8e8
import
*
as
storage
from
'./storage'
import
*
as
storage
from
'./storage'
export
default
{
export
default
{
storage
storage
};
};
src/views/about/index.vue
deleted
100644 → 0
View file @
2b2bbe2a
<
template
>
<div
class=
"about"
>
<h1>
This is an about page
</h1>
</div>
</
template
>
src/views/cart/index.vue
deleted
100644 → 0
View file @
2b2bbe2a
<
template
>
<div
class=
'cartpage'
>
<h1
v-for=
"item in carts"
:key=
"item.id"
>
{{
JSON
.
stringify
(
item
)
}}
</h1>
<div>
<button
@
click=
"addCartInpage"
>
add
</button>
<button
@
click=
"deleteOne"
>
deleteOne
</button>
<button
@
click=
"deleteCartInpage"
>
deleteAll
</button>
</div>
</div>
</
template
>
<
script
>
import
{
mapState
,
mapActions
}
from
'vuex'
;
export
default
{
name
:
'cart'
,
// import引入的组件需要注入到对象中才能使用
components
:
{
},
data
()
{
// 这里存放数据
return
{
};
},
computed
:
{
...
mapState
({
carts
:
(
state
)
=>
state
.
cart
.
carts
,
}),
},
watch
:
{},
methods
:
{
...
mapActions
([
'cart/addCart'
,
'cart/deleteAll'
,
'cart/deleteCart'
]),
addCartInpage
()
{
if
(
!
this
.
addIndex
)
this
.
addIndex
=
1
;
this
[
'cart/addCart'
]({
id
:
this
.
addIndex
,
cart
:
'sfshfksfhs'
});
this
.
addIndex
+=
1
;
},
deleteCartInpage
()
{
if
(
!
this
.
deleteIndex
)
{
this
.
deleteIndex
=
1
;
}
this
[
'cart/deleteAll'
](
this
.
deleteIndex
);
this
.
deleteIndex
+=
1
;
},
deleteOne
()
{
}
},
created
()
{
},
mounted
()
{
},
};
</
script
>
<
style
lang=
'scss'
scoped
>
</
style
>
src/views/home/index.vue
View file @
150ec8e8
...
@@ -17,14 +17,7 @@ export default {
...
@@ -17,14 +17,7 @@ export default {
name
:
'Home'
,
name
:
'Home'
,
components
:
{
components
:
{
},
},
methods
:
{
methods
:
{},
// show() {
// this.$message({
// type: 'info',
// message: 'this is message',
// });
// },
},
};
};
</
script
>
</
script
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment