Showing
10 changed files
with
406 additions
and
102 deletions
... | @@ -13,6 +13,8 @@ var fileRouter = require('./routes/file/router'); | ... | @@ -13,6 +13,8 @@ var fileRouter = require('./routes/file/router'); |
13 | //var trashcanRouter = require('./routes/trashcan/router'); | 13 | //var trashcanRouter = require('./routes/trashcan/router'); |
14 | var folderRouter = require('./routes/folders'); | 14 | var folderRouter = require('./routes/folders'); |
15 | var quickRouter = require('./routes/quick'); | 15 | var quickRouter = require('./routes/quick'); |
16 | +var favoritesRouter = require('./routes/favorites'); | ||
17 | +var shareRouter = require('./routes/share'); | ||
16 | 18 | ||
17 | 19 | ||
18 | var passport = require('passport'); | 20 | var passport = require('passport'); |
... | @@ -60,6 +62,8 @@ app.use('/api/user', userRouter); | ... | @@ -60,6 +62,8 @@ app.use('/api/user', userRouter); |
60 | app.use('/api/login', loginRouter); | 62 | app.use('/api/login', loginRouter); |
61 | app.use('/api/RegistUser', registerRouter); | 63 | app.use('/api/RegistUser', registerRouter); |
62 | app.use('/api/folder', folderRouter); | 64 | app.use('/api/folder', folderRouter); |
65 | +app.use('/api/favorites', favoritesRouter); | ||
66 | +app.use('/api/share', shareRouter); | ||
63 | //app.use('/users', usersRouter); | 67 | //app.use('/users', usersRouter); |
64 | app.use('/api/file', fileRouter); | 68 | app.use('/api/file', fileRouter); |
65 | app.use('/api/quick', quickRouter); | 69 | app.use('/api/quick', quickRouter); | ... | ... |
backend/routes/favorites.js
0 → 100644
1 | +const express = require('express'); | ||
2 | +const router = express.Router(); | ||
3 | + | ||
4 | +router.get('/show', function(req, res, next) { | ||
5 | + console.log(req.query); | ||
6 | + user_id = req.query.id; | ||
7 | + let folders = []; | ||
8 | + let files = []; | ||
9 | + | ||
10 | + let checkfolder = 'SELECT * FROM folders WHERE user_id = ? AND favorite = 1;'; | ||
11 | + let checkfiles = 'SELECT * FROM files WHERE user_id = ? AND favorite = 1;'; | ||
12 | + connection.query(checkfolder, [user_id], function(err, folder, fields) { | ||
13 | + if (err) { | ||
14 | + console.log('select error'); | ||
15 | + res.status(404).send(); | ||
16 | + } else { | ||
17 | + folders.push(folder); | ||
18 | + connection.query(checkfiles, [user_id], function(err, file, fields) { | ||
19 | + if (err) { | ||
20 | + console.log('select error'); | ||
21 | + res.status(404).send(); | ||
22 | + } else { | ||
23 | + files.push(file); | ||
24 | + res.status(200).send({ | ||
25 | + folders: folders, | ||
26 | + files: files | ||
27 | + }); | ||
28 | + } | ||
29 | + }); | ||
30 | + } | ||
31 | + }); | ||
32 | +}); | ||
33 | + | ||
34 | +router.post('/addfolder', function(req, res, next) { | ||
35 | + let user_id = req.body.id; | ||
36 | + let folder_name = req.body.name; | ||
37 | + let cur = req.body.cur; | ||
38 | + console.log(req.body); | ||
39 | + let checkfolder = 'SELECT * FROM folders WHERE location = ? AND user_id = ? AND folder_name = ? AND favorite = 1;'; | ||
40 | + connection.query(checkfolder, [cur, user_id, folder_name], function(err, rows, fields) { | ||
41 | + if (err) { | ||
42 | + console.log('select error'); | ||
43 | + res.status(400).send({ error: err }); | ||
44 | + } else { | ||
45 | + if (rows.length == 0) { | ||
46 | + let sql = 'UPDATE folders SET favorite = 1 WHERE location = ? AND folder_name = ? AND user_id = ?;'; | ||
47 | + connection.query(sql, [cur, folder_name, user_id], function(err, result, fields) { | ||
48 | + if (err) { | ||
49 | + console.log('update error'); | ||
50 | + res.status(400).send({ error: err }); | ||
51 | + } else { | ||
52 | + let getfolder = 'SELECT * FROM folders WHERE location = ? AND user_id = ?;'; | ||
53 | + connection.query(getfolder, [cur, user_id], function(err, folders, fields) { | ||
54 | + res.status(200).send({ | ||
55 | + folders: folders | ||
56 | + }) | ||
57 | + }); | ||
58 | + } | ||
59 | + }); | ||
60 | + } else { | ||
61 | + console.log('already exist error'); | ||
62 | + res.status(400).send({ error: err }); | ||
63 | + } | ||
64 | + } | ||
65 | + }); | ||
66 | +}); | ||
67 | + | ||
68 | +router.post('/addfile', function(req, res, next) { | ||
69 | + let user_id = req.body.id; | ||
70 | + let file_name = req.body.name; | ||
71 | + let cur = req.body.cur; | ||
72 | + console.log(req.body); | ||
73 | + let checkfolder = 'SELECT * FROM files WHERE location = ? AND user_id = ? AND file_name = ? AND favorite = 1;'; | ||
74 | + connection.query(checkfolder, [cur, user_id, file_name], function(err, rows, fields) { | ||
75 | + if (err) { | ||
76 | + console.log('select error'); | ||
77 | + res.status(400).send({ error: err }); | ||
78 | + } else { | ||
79 | + if (rows.length == 0) { | ||
80 | + let sql = 'UPDATE files SET favorite = 1 WHERE location = ? AND file_name = ? AND user_id = ?;'; | ||
81 | + connection.query(sql, [cur, file_name, user_id], function(err, result, fields) { | ||
82 | + if (err) { | ||
83 | + console.log('update error'); | ||
84 | + res.status(400).send({ error: err }); | ||
85 | + } else { | ||
86 | + let getfolder = 'SELECT * FROM files WHERE location = ? AND user_id = ?;'; | ||
87 | + connection.query(getfolder, [cur, user_id], function(err, files, fields) { | ||
88 | + res.status(200).send({ | ||
89 | + files: files | ||
90 | + }) | ||
91 | + }); | ||
92 | + } | ||
93 | + }); | ||
94 | + } else { | ||
95 | + console.log('already exist error'); | ||
96 | + res.status(400).send({ error: err }); | ||
97 | + } | ||
98 | + } | ||
99 | + }); | ||
100 | +}); | ||
101 | + | ||
102 | +router.post('/delfolder', function(req, res, next) { | ||
103 | + let user_id = req.body.id; | ||
104 | + let folder_name = req.body.name; | ||
105 | + let cur = req.body.cur; | ||
106 | + let checkfolder = 'SELECT * FROM folders WHERE location = ? AND user_id = ? AND folder_name = ? AND favorite = 1;'; | ||
107 | + | ||
108 | + connection.query(checkfolder, [cur, user_id, folder_name], function(err, rows, fields) { | ||
109 | + if (err) { | ||
110 | + console.log('select error'); | ||
111 | + res.status(400).send({ error: err }); | ||
112 | + } else { | ||
113 | + if (rows.length != 0) { | ||
114 | + let sql = 'UPDATE folders SET favorite = 0 WHERE location = ? AND folder_name = ? AND user_id = ?;'; | ||
115 | + connection.query(sql, [cur, folder_name, user_id], function(err, result, fields) { | ||
116 | + if (err) { | ||
117 | + console.log('update error'); | ||
118 | + res.status(400).send({ error: err }); | ||
119 | + } else { | ||
120 | + let getfolder = 'SELECT * FROM folders WHERE location = ? AND user_id = ?;'; | ||
121 | + connection.query(getfolder, [cur, user_id], function(err, folders, fields) { | ||
122 | + res.status(200).send({ | ||
123 | + folders: folders | ||
124 | + }) | ||
125 | + }); | ||
126 | + } | ||
127 | + }); | ||
128 | + } else { | ||
129 | + console.log('dont exist error'); | ||
130 | + res.status(400).send({ error: err }); | ||
131 | + } | ||
132 | + } | ||
133 | + }); | ||
134 | +}); | ||
135 | + | ||
136 | +router.post('/delfile', function(req, res, next) { | ||
137 | + let user_id = req.body.id; | ||
138 | + let file_name = req.body.name; | ||
139 | + let cur = req.body.cur; | ||
140 | + let checkfile = 'SELECT * FROM files WHERE location = ? AND user_id = ? AND file_name = ? AND favorite = 1;'; | ||
141 | + | ||
142 | + connection.query(checkfile, [cur, user_id, file_name], function(err, rows, fields) { | ||
143 | + if (err) { | ||
144 | + console.log('select error'); | ||
145 | + res.status(400).send({ error: err }); | ||
146 | + } else { | ||
147 | + if (rows.length != 0) { | ||
148 | + let sql = 'UPDATE files SET favorite = 0 WHERE location = ? AND file_name = ? AND user_id = ?;'; | ||
149 | + connection.query(sql, [cur, file_name, user_id], function(err, result, fields) { | ||
150 | + if (err) { | ||
151 | + console.log('update error'); | ||
152 | + res.status(400).send({ error: err }); | ||
153 | + } else { | ||
154 | + let getfile = 'SELECT * FROM files WHERE location = ? AND user_id = ?;'; | ||
155 | + connection.query(getfile, [cur, user_id], function(err, files, fields) { | ||
156 | + res.status(200).send({ | ||
157 | + files: files | ||
158 | + }) | ||
159 | + }); | ||
160 | + } | ||
161 | + }); | ||
162 | + } else { | ||
163 | + console.log('dont exist error'); | ||
164 | + res.status(400).send({ error: err }); | ||
165 | + } | ||
166 | + } | ||
167 | + }); | ||
168 | +}); | ||
169 | + | ||
170 | + | ||
171 | + | ||
172 | +module.exports = router; | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
This diff is collapsed. Click to expand it.
1 | { | 1 | { |
2 | - "accessKeyId": "ASIAXZL2SWFE2KIQ3YTL", | 2 | + "accessKeyId": "ASIAXZL2SWFEZSIHHRDT", |
3 | - "secretAccessKey": "BqniXH7AqxjndKHjxBWKjRkBOgRmSN8J6mgldm7C", | 3 | + "secretAccessKey": "cdcXCezNz9OhFowZxE2KSftDmT3xSYAtiLJl1dFk", |
4 | - "sessionToken": "FwoGZXIvYXdzEIL//////////wEaDC6uNIWZKpDL9FekbiLDAb7ckeHQwp1tV2wu236TIia7VBtYMFQrLzkEm6sU7GiamzWfzrTCsQOOJXYMKzElNXD7dRckn30aVaw8xfNDgimqWdtk9O3x8jgCOp4gXk4KIUgtIFpN46qdGNxy28gL43voIf4O6n3boJaUum9bmejzmNlR8U4d6NfqMzrtJENs47Nl4fAiK8bIGlsznhr7MC5AUeZbV0d9uK7bkx1rn5zRRpR9WbbwofVIlK+YSEEHfQIJyLeJKDlprBXfqSTynCqkAyj8ovT2BTItQ8+cOmQXWuzPMA/Rbru2naLM3Hd2H8jEW6CMfPXvNAS+leVNDXuCY5r5Ebo9", | 4 | + "sessionToken": "FwoGZXIvYXdzEJf//////////wEaDG1NOyJj0/Xdzqu+uyLDAa8vgymCVldXPpET+AOsq5CXhMzhMEDmWogIaq6lWJVy8sdnK9tOXY/u9vz8p6cTm7xWb0YiX6TKDhlfFZX6ynv0Xw/p/qvbn4lPsoT8K9PpdDOWJUMA8qX/5RrKNO4OAolUkw+EMjQbK38u+g3HEVP8mo+DiGLrBGj+0Ar0xhGiU/Lg5qKRdp+tEYIn0ypDNu/2q13apRiMH7n+OVFzilil10g1qq8NLaW98QvVC4xRIgkjAMcRqA9yPdVrhc9yFyqjrCjA+vj2BTIt8CDkFsEAFqJR3W0YPDbsu2YdTq3SKgpOsxNXGsEFMaEhFxodp5/Qsk7tfMsO", |
5 | "region": "us-east-1" | 5 | "region": "us-east-1" |
6 | } | 6 | } | ... | ... |
backend/routes/share.js
0 → 100644
1 | +const express = require('express'); | ||
2 | +const router = express.Router(); | ||
3 | +const AWS = require("aws-sdk"); | ||
4 | +const moment = require("moment"); | ||
5 | + | ||
6 | +const BUCKET_NAME = "hong-s3-cloud"; | ||
7 | + | ||
8 | +const s3 = new AWS.S3({ | ||
9 | + accessKeyId: process.env.AWS_ACCESS_KEY_ID, | ||
10 | + secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY, | ||
11 | + region: "ap-northeast-2" | ||
12 | +}); | ||
13 | + | ||
14 | + | ||
15 | +router.post('/', function(req, res, next) { | ||
16 | + console.log(req.body); | ||
17 | + let user_id = req.body.id; | ||
18 | + let cur = req.body.cur; | ||
19 | + let curPath = user_id + cur; | ||
20 | + let name = req.body.file_name; | ||
21 | + let target_id = req.body.target_id; | ||
22 | + | ||
23 | + let checkfile = 'SELECT * FROM files WHERE location = ? AND file_name = ? AND user_id = ?'; | ||
24 | + connection.query(checkfile, [curPath, name, user_id], function(err1, rows, fields) { | ||
25 | + if (rows.length != 0) { | ||
26 | + let copy_params = { | ||
27 | + Bucket: BUCKET_NAME, | ||
28 | + CopySource: BUCKET_NAME + '/' + curPath + name, | ||
29 | + Key: target_id + '/share/' + name | ||
30 | + }; | ||
31 | + s3.copyObject(copy_params, function(err, data) { | ||
32 | + if (err) { | ||
33 | + console.log(err, data); | ||
34 | + res.status(304).send({ error: "copy error" }); | ||
35 | + } else { | ||
36 | + let values = [name, cur, target_id]; | ||
37 | + let sharesql = 'INSERT INTO files (file_name,location,user_id) values (?,?,?);'; | ||
38 | + connection.query(sharesql, values, function(err3, result, field) { | ||
39 | + if (err3) { | ||
40 | + console.log("sharesql error"); | ||
41 | + res.status(304).send({ error: "sharesql error" }); | ||
42 | + } else { | ||
43 | + res.status(200).send({}); | ||
44 | + } | ||
45 | + }); | ||
46 | + } | ||
47 | + }); | ||
48 | + } else { | ||
49 | + res.status(304).send({ error: "Does not exist" }); | ||
50 | + } | ||
51 | + }); | ||
52 | + | ||
53 | +}); | ||
54 | + | ||
55 | +module.exports = router; | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | var express = require('express'); | 1 | var express = require('express'); |
2 | var request = require('request'); | 2 | var request = require('request'); |
3 | var async = require('async'); | 3 | var async = require('async'); |
4 | - | 4 | +const AWS = require("aws-sdk"); |
5 | +AWS.config.loadFromPath(__dirname + "/../modules/awsconfig.json"); | ||
5 | var cryptoM = require('./../../routes/modules/cryptoM.js'); | 6 | var cryptoM = require('./../../routes/modules/cryptoM.js'); |
7 | +const moment = require("moment"); | ||
8 | + | ||
9 | +const BUCKET_NAME = "hong-s3-cloud"; | ||
10 | +const s3 = new AWS.S3(); | ||
6 | 11 | ||
7 | var router = express.Router(); | 12 | var router = express.Router(); |
8 | 13 | ||
... | @@ -14,32 +19,90 @@ router.get('/', function(req, res, next) { | ... | @@ -14,32 +19,90 @@ router.get('/', function(req, res, next) { |
14 | 19 | ||
15 | router.post('/', function(req, res, next) { | 20 | router.post('/', function(req, res, next) { |
16 | console.log(req.body); | 21 | console.log(req.body); |
17 | - var user_id=req.body.user_id; | 22 | + var user_id = req.body.user_id; |
18 | - var user_pw=req.body.user_pw; | 23 | + var user_pw = req.body.user_pw; |
19 | - var user_email=req.body.user_email; | 24 | + var user_email = req.body.user_email; |
20 | - var user_name=req.body.user_name; | 25 | + var user_name = req.body.user_name; |
21 | - var user_phone=req.body.user_phone; | 26 | + var user_phone = req.body.user_phone; |
22 | 27 | ||
23 | var sqlquery = "SELECT * FROM users WHERE user_id = ?"; | 28 | var sqlquery = "SELECT * FROM users WHERE user_id = ?"; |
24 | - connection.query(sqlquery, [user_id], function (err, rows) { | 29 | + connection.query(sqlquery, [user_id], function(err, rows) { |
25 | - if (rows.length == 0) { | 30 | + if (rows.length == 0) { |
26 | - user_pw=cryptoM.encrypt(user_pw); | 31 | + user_pw = cryptoM.encrypt(user_pw); |
27 | - console.log(user_pw); | 32 | + console.log(user_pw); |
28 | - var sql = 'INSERT INTO users(user_id,user_pw, user_email, user_phone, user_name) values (?,?,?,?,?)'; | 33 | + var sql = 'INSERT INTO users(user_id,user_pw, user_email, user_phone, user_name) values (?,?,?,?,?)'; |
29 | - var values = [user_id, user_pw, user_email, user_phone,user_name]; | 34 | + var values = [user_id, user_pw, user_email, user_phone, user_name]; |
30 | - connection.query(sql, values, function (err) { | 35 | + connection.query(sql, values, function(err) { |
31 | - if (err) { | 36 | + if (err) { |
32 | - console.log("inserting user failed"); | 37 | + console.log("inserting user failed"); |
33 | - throw err; | 38 | + res.status(400).send({ err: err }); |
34 | - } else { | 39 | + } else { |
35 | - res.status(200).send('saved'); | 40 | + let params = { |
36 | - | 41 | + Bucket: BUCKET_NAME, |
37 | - } | 42 | + Key: 'drive/' + user_id + '/', |
38 | - }); | 43 | + Body: "", |
39 | - } else { | 44 | + ACL: "public-read-write" |
40 | - res.status(404).send(err); | 45 | + }; |
41 | - } | 46 | + s3.putObject(params, function(err, data) { |
42 | - }); | 47 | + if (err) { |
48 | + console.log('s3 error'); | ||
49 | + res.status(400).send({ err: err }); | ||
50 | + } else { | ||
51 | + let params2 = { | ||
52 | + Bucket: BUCKET_NAME, | ||
53 | + Key: 'drive/' + user_id + '/share/', | ||
54 | + Body: "", | ||
55 | + ACL: "public-read-write" | ||
56 | + }; | ||
57 | + s3.putObject(params2, function(err, data) { | ||
58 | + if (err) { | ||
59 | + console.log('s3 error'); | ||
60 | + res.status(400).send({ err: err }); | ||
61 | + } else { | ||
62 | + let params3 = { | ||
63 | + Bucket: BUCKET_NAME, | ||
64 | + Key: 'drive/' + user_id + '/trashcan/', | ||
65 | + Body: "", | ||
66 | + ACL: "public-read-write" | ||
67 | + }; | ||
68 | + s3.putObject(params3, function(err, data) { | ||
69 | + if (err) { | ||
70 | + console.log('s3 error'); | ||
71 | + res.status(400).send({ err: err }); | ||
72 | + } else { | ||
73 | + let date = moment().format(); | ||
74 | + let root = '/'; | ||
75 | + let sql = "INSERT INTO folders (folder_name,location,user_id,created) values (?,?,?,?);"; | ||
76 | + connection.query(sql, ['share', root, user_id, date], function(err, result, field) { | ||
77 | + if (err) { | ||
78 | + console.log('insert1 error'); | ||
79 | + res.status(400).send({ err: err }); | ||
80 | + } else { | ||
81 | + let sql = "INSERT INTO folders (folder_name,location,user_id,created) values (?,?,?,?);"; | ||
82 | + connection.query(sql, ['trashcan', root, user_id, date], function(err, result, field) { | ||
83 | + if (err) { | ||
84 | + console.log('insert2 error'); | ||
85 | + res.status(400).send({ err: err }); | ||
86 | + } else { | ||
87 | + res.status(200).send('saved'); | ||
88 | + } | ||
89 | + }); | ||
90 | + } | ||
91 | + }); | ||
92 | + } | ||
93 | + }); | ||
94 | + } | ||
95 | + }); | ||
96 | + } | ||
97 | + }); | ||
98 | + | ||
99 | + | ||
100 | + } | ||
101 | + }); | ||
102 | + } else { | ||
103 | + res.status(404).send(err); | ||
104 | + } | ||
105 | + }); | ||
43 | }); | 106 | }); |
44 | 107 | ||
45 | -module.exports = router; | 108 | +module.exports = router; |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -79,25 +79,35 @@ function downloadFile(fileData) { | ... | @@ -79,25 +79,35 @@ function downloadFile(fileData) { |
79 | }, | 79 | }, |
80 | }); | 80 | }); |
81 | } | 81 | } |
82 | -function accessedList(curData) { | 82 | +function accessedList(curData){ |
83 | - return axios.get(`api/quick`, { | 83 | + return axios.get('api/quick', { |
84 | - params: { | 84 | + params:{ |
85 | - //현재 접속한 사람의 id와 다운로드를 위해 선택한 파일의 이름을 파라미터로 넘긴다. | ||
86 | id: curData.id | 85 | id: curData.id |
87 | }, | 86 | }, |
88 | }); | 87 | }); |
89 | } | 88 | } |
90 | function modifyFile(fileData){ | 89 | function modifyFile(fileData){ |
91 | - return axios.post(`/api/file/modify/${fileName}`, { | 90 | + return axios.post(`/api/file/modify/${fileData.name}`, fileData) |
92 | - params: { | 91 | +} |
93 | - user_id: fileData.id, | 92 | +function delFavorite(folderData) { |
94 | - cur: fileData.cur, | 93 | + return axios.post('api/favorites/delfolder', folderData); |
95 | - name: fileData.rename, | ||
96 | - content: fileData.content | ||
97 | - }, | ||
98 | - }); | ||
99 | } | 94 | } |
100 | 95 | ||
96 | +function addFavorite(folderData) { | ||
97 | + return axios.post('api/favorites/addfolder', folderData); | ||
98 | +} | ||
99 | + | ||
100 | +function moveFile(fileData) { | ||
101 | + return axios.post('/api/folder/move', fileData); | ||
102 | +} | ||
103 | + | ||
104 | +function delFavoriteFile(fileData) { | ||
105 | + return axios.post('api/favorites/delfile', fileData); | ||
106 | +} | ||
107 | + | ||
108 | +function addFavoriteFile(fileData) { | ||
109 | + return axios.post('api/favorites/addfile', fileData); | ||
110 | +} | ||
101 | 111 | ||
102 | export { | 112 | export { |
103 | registerUser, | 113 | registerUser, |
... | @@ -110,6 +120,11 @@ export { | ... | @@ -110,6 +120,11 @@ export { |
110 | uploadFile, | 120 | uploadFile, |
111 | deleteFile, | 121 | deleteFile, |
112 | downloadFile, | 122 | downloadFile, |
123 | + delFavorite, | ||
124 | + addFavorite, | ||
125 | + moveFile, | ||
126 | + delFavoriteFile, | ||
127 | + addFavoriteFile, | ||
113 | accessedList, | 128 | accessedList, |
114 | detailFile, | 129 | detailFile, |
115 | modifyFile | 130 | modifyFile | ... | ... |
This diff is collapsed. Click to expand it.
... | @@ -5,7 +5,9 @@ | ... | @@ -5,7 +5,9 @@ |
5 | <template v-slot:default> | 5 | <template v-slot:default> |
6 | <thead> | 6 | <thead> |
7 | <tr> | 7 | <tr> |
8 | + <th class="text-left">File ID</th> | ||
8 | <th class="text-left">Name</th> | 9 | <th class="text-left">Name</th> |
10 | + <th class="text-left">Dir</th> | ||
9 | <th class="text-left">Date</th> | 11 | <th class="text-left">Date</th> |
10 | </tr> | 12 | </tr> |
11 | </thead> | 13 | </thead> | ... | ... |
1 | -import Vue from 'vue' | 1 | +import Vue from 'vue'; |
2 | -import Vuex from 'vuex' | 2 | +import Vuex from 'vuex'; |
3 | 3 | ||
4 | -Vue.use(Vuex) | 4 | +Vue.use(Vuex); |
5 | 5 | ||
6 | export default new Vuex.Store({ | 6 | export default new Vuex.Store({ |
7 | - state: { | 7 | + state: { |
8 | - id: '', | 8 | + id: '', |
9 | - folders: [], | 9 | + folders: [], |
10 | - files: [], | 10 | + files: [], |
11 | - cur: '/', | 11 | + cur: '/', |
12 | - parent: '/', | 12 | + parent: '/', |
13 | - recentList:[] | 13 | + }, |
14 | - }, | 14 | + mutations: { |
15 | - mutations: { | 15 | + setId(state, userid) { |
16 | - setId(state, userid) { | 16 | + state.id = userid; |
17 | - state.id = userid; | 17 | + }, |
18 | - }, | 18 | + clearid(state) { |
19 | - clearid(state) { | 19 | + state.id = ''; |
20 | - state.id = ''; | 20 | + }, |
21 | - }, | 21 | + setFolder(state, folderlist) { |
22 | - setFolder(state, folderlist) { | 22 | + state.folders = folderlist; |
23 | - state.folders = folderlist; | 23 | + }, |
24 | - }, | 24 | + setFile(state, filelist) { |
25 | - setFile(state, filelist) { | 25 | + state.files = filelist; |
26 | - state.files = filelist; | 26 | + }, |
27 | - }, | 27 | + setCur(state, cur) { |
28 | - setCur(state, cur) { | 28 | + state.cur = cur; |
29 | - state.cur = cur; | 29 | + }, |
30 | - }, | 30 | + setParent(state, parent) { |
31 | - setParent(state, parent) { | 31 | + state.parent = parent; |
32 | - state.parent = parent; | 32 | + }, |
33 | - }, | 33 | + }, |
34 | - setRecentList(state, list){ | 34 | + getters: { |
35 | - state.recentList = list; | 35 | + isLogin(state) { |
36 | - } | 36 | + return state.id !== ''; |
37 | - }, | 37 | + }, |
38 | - getters: { | 38 | + userID(state) { |
39 | - isLogin(state) { | 39 | + return state.id; |
40 | - return state.id !== ''; | 40 | + }, |
41 | - }, | 41 | + folderL(state) { |
42 | - userID(state) { | 42 | + return state.folders; |
43 | - return state.id; | 43 | + }, |
44 | - }, | 44 | + fileL(state) { |
45 | - folderL(state) { | 45 | + return state.files; |
46 | - return state.folders; | 46 | + }, |
47 | - }, | 47 | + cur(state) { |
48 | - fileL(state) { | 48 | + return state.cur; |
49 | - return state.files; | 49 | + }, |
50 | - }, | 50 | + setFolder(state, folderlist) { |
51 | - recentL(state){ | 51 | + state.folders = folderlist; |
52 | - return state.recentList; | 52 | + }, |
53 | - }, | 53 | + setFile(state, filelist) { |
54 | - cur(state) { | 54 | + state.files = filelist; |
55 | - return state.cur; | 55 | + }, |
56 | - }, | 56 | + }, |
57 | - setFolder(state, folderlist){ | 57 | +}); |
58 | - state.folders = folderlist; | ||
59 | - }, | ||
60 | - setFile(state, filelist){ | ||
61 | - state.files = filelist; | ||
62 | - }, | ||
63 | - }, | ||
64 | -}) | ... | ... |
-
Please register or login to post a comment