Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
geek-cloud-disk
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
geek-cloud-disk
Commits
8ca925eb
Commit
8ca925eb
authored
Jul 16, 2020
by
huanglu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: init
parent
27abc9e2
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
96 deletions
+23
-96
index.js
src/router/index.js
+1
-8
storage.js
src/utils/storage.js
+22
-24
index.vue
src/views/about/index.vue
+0
-5
index.vue
src/views/cart/index.vue
+0
-59
No files found.
src/router/index.js
View file @
8ca925eb
...
@@ -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
);
// 单入口路由配置
// 单入口路由配置
...
@@ -13,15 +11,10 @@ const routes = [
...
@@ -13,15 +11,10 @@ const routes = [
name
:
'Home'
,
name
:
'Home'
,
component
:
Home
component
:
Home
},
},
{
path
:
'/cart'
,
name
:
'Cart'
,
component
:
Cart
}
];
];
const
router
=
new
VueRouter
({
const
router
=
new
VueRouter
({
mode
:
'h
ash
'
,
mode
:
'h
istory
'
,
base
:
process
.
env
.
BASE_URL
,
base
:
process
.
env
.
BASE_URL
,
routes
routes
});
});
...
...
src/utils/storage.js
View file @
8ca925eb
...
@@ -12,62 +12,61 @@
...
@@ -12,62 +12,61 @@
*/
*/
export
function
setStorage
(
key
,
val
)
{
export
function
setStorage
(
key
,
val
)
{
localStorage
.
setItem
(
key
,
JSON
.
stringify
(
val
))
localStorage
.
setItem
(
key
,
JSON
.
stringify
(
val
))
}
}
/**
/**
* 获取本地缓存
* 获取本地缓存
* @param {string} key
* @param {string} key
*/
*/
export
function
getStorage
(
key
)
{
export
function
getStorage
(
key
)
{
const
val
=
localStorage
.
getItem
(
key
)
const
val
=
localStorage
.
getItem
(
key
)
return
val
===
'undefined'
?
''
:
JSON
.
parse
(
val
)
return
val
===
'undefined'
?
''
:
JSON
.
parse
(
val
)
}
}
/**
/**
* 移除某一项缓存
* 移除某一项缓存
* @param {string} key
* @param {string} key
*/
*/
export
function
removeStorage
(
key
)
{
export
function
removeStorage
(
key
)
{
localStorage
.
removeItem
(
key
)
localStorage
.
removeItem
(
key
)
}
}
/**
/**
* 清除所有缓存
* 清除所有缓存
*/
*/
export
function
clearStorage
()
{
export
function
clearStorage
()
{
localStorage
.
clear
()
localStorage
.
clear
()
}
}
/**
/**
* 设置本地临时缓存
* 设置本地临时缓存
* @param {string} key
* @param {string} key
* @param {any} val
* @param {any} val
*/
*/
export
function
setSession
(
key
,
val
)
{
export
function
setSession
(
key
,
val
)
{
sessionStorage
.
setItem
(
key
,
JSON
.
stringify
(
val
))
sessionStorage
.
setItem
(
key
,
JSON
.
stringify
(
val
))
}
}
/**
/**
* 获取本地临时缓存
* 获取本地临时缓存
* @param {string} key
* @param {string} key
*/
*/
export
function
getSession
(
key
)
{
export
function
getSession
(
key
)
{
const
val
=
sessionStorage
.
getItem
(
key
)
const
val
=
sessionStorage
.
getItem
(
key
)
return
val
===
'undefined'
?
''
:
JSON
.
parse
(
val
)
return
val
===
'undefined'
?
''
:
JSON
.
parse
(
val
)
}
}
/**
/**
* 移除某一项临时缓存
* 移除某一项临时缓存
* @param {string} key
* @param {string} key
*/
*/
export
function
removeSession
(
key
)
{
export
function
removeSession
(
key
)
{
sessionStorage
.
removeItem
(
key
)
sessionStorage
.
removeItem
(
key
)
}
}
/**
/**
* 清除所有临时缓存
* 清除所有临时缓存
*/
*/
export
function
clearSession
()
{
export
function
clearSession
()
{
sessionStorage
.
clear
()
sessionStorage
.
clear
()
}
}
\ No newline at end of file
src/views/about/index.vue
deleted
100644 → 0
View file @
27abc9e2
<
template
>
<div
class=
"about"
>
<h1>
This is an about page
</h1>
</div>
</
template
>
src/views/cart/index.vue
deleted
100644 → 0
View file @
27abc9e2
<
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
>
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