分享基础功能实现
This commit is contained in:
parent
0be5fdd979
commit
688d08d904
@ -14,4 +14,7 @@ public class BizException extends RuntimeException {
|
|||||||
public static BizException create(String message) {
|
public static BizException create(String message) {
|
||||||
return new BizException(-1, message);
|
return new BizException(-1, message);
|
||||||
}
|
}
|
||||||
|
public static BizException create(int code,String message) {
|
||||||
|
return new BizException(code, message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,29 @@
|
|||||||
|
package xyz.longicorn.driver.config;
|
||||||
|
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||||
|
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||||
|
import xyz.longicorn.driver.dto.ApiResult;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
@RestControllerAdvice
|
||||||
|
public class ResponseExceptionConfig {
|
||||||
|
|
||||||
|
@ExceptionHandler(value = BizException.class) // 要捕获的异常类型
|
||||||
|
@ResponseBody
|
||||||
|
@ResponseStatus(HttpStatus.OK)
|
||||||
|
public ApiResult bizExceptionHandler(HttpServletRequest req, BizException e) {
|
||||||
|
return ApiResult.error(e.getCode(), e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
@ExceptionHandler(value = Exception.class) // 要捕获的异常类型
|
||||||
|
@ResponseBody
|
||||||
|
@ResponseStatus(HttpStatus.OK)
|
||||||
|
public ApiResult exceptionHandler(HttpServletRequest req, Exception e) {
|
||||||
|
return ApiResult.error(-1, "App Internal Error:" + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
@ -7,8 +7,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import xyz.longicorn.driver.dto.ApiResult;
|
import xyz.longicorn.driver.dto.ApiResult;
|
||||||
|
import xyz.longicorn.driver.dto.ShareDto;
|
||||||
import xyz.longicorn.driver.pojo.ShareInfo;
|
import xyz.longicorn.driver.pojo.ShareInfo;
|
||||||
import xyz.longicorn.driver.service.ShareService;
|
import xyz.longicorn.driver.service.ShareService;
|
||||||
|
import xyz.longicorn.driver.service.UserService;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
@ -17,6 +19,8 @@ import javax.annotation.Resource;
|
|||||||
public class ShareController {
|
public class ShareController {
|
||||||
@Resource
|
@Resource
|
||||||
private ShareService shareService;
|
private ShareService shareService;
|
||||||
|
@Resource
|
||||||
|
private UserService userService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建分享
|
* 创建分享
|
||||||
@ -41,12 +45,21 @@ public class ShareController {
|
|||||||
|
|
||||||
@RequestMapping("/info")
|
@RequestMapping("/info")
|
||||||
public ApiResult info(String id) {
|
public ApiResult info(String id) {
|
||||||
return ApiResult.success(shareService.getById(id));
|
final ShareInfo shareInfo = shareService.getById(id);
|
||||||
|
if (shareInfo == null) {
|
||||||
|
return ApiResult.error(1, "分享码不正确或分享已过期");
|
||||||
|
}
|
||||||
|
ShareDto share = new ShareDto();
|
||||||
|
share.setShare(shareInfo);
|
||||||
|
share.setUser(
|
||||||
|
userService.getById(
|
||||||
|
shareInfo.getUid()
|
||||||
|
));
|
||||||
|
return ApiResult.success(share);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/list")
|
@RequestMapping("/list")
|
||||||
public ApiResult list(@RequestParam(required = true) String id, String parent,String password) {
|
public ApiResult list(@RequestParam(required = true) String id, String parent, String password) {
|
||||||
|
return ApiResult.success(shareService.listFiles(id, parent, password));
|
||||||
return ApiResult.success(shareService.listFiles(id, parent,password));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,11 @@
|
|||||||
package xyz.longicorn.driver.dto;
|
package xyz.longicorn.driver.dto;
|
||||||
|
|
||||||
public class ShareDto {
|
import lombok.Data;
|
||||||
|
import xyz.longicorn.driver.pojo.ShareInfo;
|
||||||
|
import xyz.longicorn.driver.pojo.UserInfo;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ShareDto {
|
||||||
|
private ShareInfo share;
|
||||||
|
private UserInfo user;
|
||||||
}
|
}
|
||||||
|
@ -57,12 +57,12 @@ public class ShareService extends ServiceImpl<ShareInfoMapper, ShareInfo> {
|
|||||||
public List<FileItem> listFiles(String id, String parent, String password) {
|
public List<FileItem> listFiles(String id, String parent, String password) {
|
||||||
ShareInfo info = this.getById(id);
|
ShareInfo info = this.getById(id);
|
||||||
if (null == info) {
|
if (null == info) {
|
||||||
throw BizException.create("分享信息有误");
|
throw BizException.create(1001,"分享信息有误");
|
||||||
}
|
}
|
||||||
// 需要先验证密码
|
// 需要先验证密码
|
||||||
if (info.getPassword() != null) {
|
if (info.getPassword() != null) {
|
||||||
if (!info.getPassword().equalsIgnoreCase(password)) {
|
if (!info.getPassword().equalsIgnoreCase(password)) {
|
||||||
throw BizException.create("提取密码不正确");
|
throw BizException.create(1002,"提取密码不正确");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 是否是文件
|
// 是否是文件
|
||||||
|
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 10 KiB |
45
web/src/components/AppLogo.vue
Normal file
45
web/src/components/AppLogo.vue
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
<template>
|
||||||
|
<svg viewBox="0 0 1055 1024" xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="128" height="128">
|
||||||
|
<path
|
||||||
|
d="M316.541982 228.818894c-1.473174-20.560422-1.939662-39.957046-2.019189-43.829582-1.387828-32.424367-12.728065-96.596159 20.010528-111.409362 33.750127-15.277751 57.021227 18.770113 71.173004 48.7282 3.409927 7.216514 46.939831 104.888216 48.103628 103.730238-6.438709 6.356274-15.045962 9.003913-21.517645 15.591977a106.972384 106.972384 0 0 1-34.295172 19.862143 71.903287 71.903287 0 0 1-15.509541 4.501957 161.557394 161.557394 0 0 0-18.770113 7.216514c-5.431055 1.870804-11.023102 3.310034-16.452217 5.197325a71.817942 71.817942 0 0 1-18.306534 4.965536c-6.821793 0.215303-10.392711-28.104739-12.416749-54.554946z"
|
||||||
|
fill="#FCC21B" p-id="5177"></path>
|
||||||
|
<path
|
||||||
|
d="M732.106902 225.85606c1.473174-20.560422 1.939662-39.957046 2.101624-43.829582 1.390738-32.425337 12.645629-96.513724-20.17249-111.343413-33.750127-15.277751-56.871873 18.770113-71.173003 48.728199-3.310034 7.216514-46.939831 104.971622-47.999857 103.730238 6.289355 6.356274 14.896608 9.003913 21.517645 15.526028a105.254813 105.254813 0 0 0 34.444526 19.862144 70.002418 70.002418 0 0 0 15.277751 4.501956 157.537444 157.537444 0 0 1 18.852549 7.216514c5.431055 1.870804 11.023102 3.310034 16.452217 5.197326a70.974188 70.974188 0 0 0 18.306534 4.965536c6.797547 0.300648 10.45575-28.018424 12.392504-54.554946z"
|
||||||
|
fill="#FCC21B" p-id="5178"></path>
|
||||||
|
<path
|
||||||
|
d="M991.175976 224.697112c-4.965536-50.201374-64.402612-62.300988-105.600072-53.84309-47.40438 9.698312-80.458168 54.157315-129.103933 59.437076a93.815653 93.815653 0 0 1-22.57961-1.654532 292.390536 292.390536 0 0 0-37.159083-19.862143c-102.617842-45.784762-242.152309-44.309649-331.21482-6.621038a234.339348 234.339348 0 0 0-45.153402 26.615078 84.41411 84.41411 0 0 1-21.021091 1.473174c-48.795118-5.279761-81.781988-49.655359-129.253286-59.437076-41.196491-8.457898-100.551131 3.726092-105.599103 53.843089-5.909182 58.940523 28.451939 85.936745 81.683065 97.394331 24.281664 5.279761 49.423569 6.902289 73.707172 12.645629a185.904037 185.904037 0 0 1 23.586296 9.153267c-7.911883 49.341133-3.310034 99.856732-5.11489 149.741941-2.168543 59.58643-22.427347 108.695774-40.419656 164.491134-54.58792 168.546968 86.582652 267.7704 233.413159 291.907559 86.201508 14.201239 179.619531 20.243287 263.63698-7.994318 61.241932-20.560422 123.443027-60.129536 151.531279-120.496681 29.2472-62.996357 14.118803-125.793898-7.75865-188.147257-26.069063-74.102864-16.552109-146.797533-10.62644-222.985534a201.28653 201.28653 0 0 0-6.356274-70.527096 96.207257 96.207257 0 0 1 14.201239-5.11489c24.215716-5.74334 49.341133-7.448304 73.707172-12.645629 52.975091-11.403276 87.386642-38.415985 81.493948-97.372994z"
|
||||||
|
fill="#FFFFFF" p-id="5179"></path>
|
||||||
|
<path
|
||||||
|
d="M187.918116 627.617372c-0.314225 0.927159-0.611964 1.939662-0.927159 2.863912a197.671969 197.671969 0 0 0-6.902288 23.436941c24.281664 4.105296 45.931207-23.668731 61.373829-38.631287a212.83916 212.83916 0 0 1 92.327932-57.733083c41.379789-11.486681 84.41411-11.32181 123.824171-31.034599 93.021362-46.54317 121.655628-205.242472 76.734016-292.585472a142.726182 142.726182 0 0 0-81.385326-72.827536 129.782814 129.782814 0 0 0-61.919845-3.310034 326.911678 326.911678 0 0 0-46.858365 18.206642c-10.708876 4.501957-21.517645 9.070831-31.961758 14.284644-21.185963 10.791312-41.743475-6.20692-57.567241-19.862144a120.033101 120.033101 0 0 0-54.488998-26.864324 191.007289 191.007289 0 0 0-80.607522-3.310034 122.586666 122.586666 0 0 0-44.839176 15.905232C64.011509 163.604534 60.684018 175.240569 52.293039 184.095128a75.211381 75.211381 0 0 0-17.611165 36.960267 98.466964 98.466964 0 0 0 17.859441 73.241654 143.632004 143.632004 0 0 0 66.704022 45.550063 281.979397 281.979397 0 0 0 57.335452 13.241106c4.65519 0.695369 16.287346 3.806588 18.38897 8.375462 1.55173 3.310034-0.611964 7.365868-0.314225 10.86211s2.019189 6.289355 2.250978 9.698312c0.775865 8.457898-0.611964 17.760519-0.381144 26.379409 0.775865 34.609397 8.457898 68.971487 8.27557 103.577975 0 11.486681 1.655502 23.818085 0.86024 35.072976a340.552354 340.552354 0 0 1-17.747911 80.557091z"
|
||||||
|
fill="#2F2F2F" p-id="5180"></path>
|
||||||
|
<path
|
||||||
|
d="M425.004996 451.092572c-6.052717 27.228012-27.776936 44.458033-48.562359 38.714693s-32.739562-32.739562-26.846868-59.967574 27.938898-44.540469 48.796089-38.631287 32.75411 32.723075 26.613138 59.884168z"
|
||||||
|
fill="#FFFFFF" p-id="5181"></path>
|
||||||
|
<path
|
||||||
|
d="M648.153462 453.80713c8.689688 26.300853 31.961758 40.651445 52.055691 32.425337s29.329636-36.612098 20.639948-62.996357-32.044193-40.732911-52.138127-32.358419-29.326726 36.711991-20.557512 62.929439z"
|
||||||
|
fill="#2F2F2F" p-id="5182"></path>
|
||||||
|
<path
|
||||||
|
d="M348.423244 746.392602a77.324643 77.324643 0 0 0-12.879359-5.740431c-11.023102-3.807557-26.483181-9.070831-26.151499-23.73565 0.149354-9.550898 12.18205-20.325723 20.172489-23.503859 41.379789-16.552109 115.680498-2.862942 126.306939 48.49641 3.178137 14.896608 0 40.651445-14.515463 48.959989-19.862143 11.486681-39.343143-0.611964-54.471541-13.804577a248.820868 248.820868 0 0 0-38.461566-30.671882z"
|
||||||
|
fill="#2F2F2F" p-id="5183"></path>
|
||||||
|
<path
|
||||||
|
d="M692.300179 746.392602a77.295548 77.295548 0 0 1 12.877419-5.743341c11.023102-3.807557 26.615078-9.070831 26.218417-23.735649a33.864567 33.864567 0 0 0-20.242317-23.50386c-41.595091-16.55114-115.599032-2.862942-126.390344 48.49738-3.178137 14.896608 0 40.651445 14.582382 48.95999 19.862143 11.486681 39.260708-0.611964 54.389105-13.804578a238.804451 238.804451 0 0 1 38.565338-30.669942z"
|
||||||
|
fill="#2F2F2F" p-id="5184"></path>
|
||||||
|
<path
|
||||||
|
d="M404.06731 727.308263a43.545422 43.545422 0 0 0-23.353536-2.399363 36.132032 36.132032 0 0 0-27.161093 26.846868c-27.079627 82.559792 51.127562 142.67672 122.746688 159.046502 70.377742 16.055556 173.793755 3.575768 218.169353-61.14204a106.824969 106.824969 0 0 0 17.527759-64.868131 93.135802 93.135802 0 0 0-24.13231-54.620894 50.714414 50.714414 0 0 0-52.75009-1.655502 39.211246 39.211246 0 0 0-19.001903 25.144814c-2.168543 10.791312 3.724152 17.611165 5.74334 27.690621a32.954865 32.954865 0 0 1-3.095701 22.726055c-19.396624 33.750127-71.619126 42.438844-106.527231 37.936888a139.22994 139.22994 0 0 1-57.253016-19.862144 56.376289 56.376289 0 0 1-21.185963-34.212736c-2.863912-14.353502 4.965536-25.986628-4.733747-39.344113a58.924036 58.924036 0 0 0-24.99255-21.286825z"
|
||||||
|
fill="#FCC21B" p-id="5185"></path>
|
||||||
|
<path
|
||||||
|
d="M560.862833 987.999865a820.962129 820.962129 0 0 1-133.920114-12.264486c-107.768615-17.760519-194.202883-68.359523-237.187743-138.803214a219.145972 219.145972 0 0 1-16.667519-186.737122c3.112188-9.550898 6.20692-18.934985 9.385057-28.137713a448.653621 448.653621 0 0 0 29.793215-129.339602c0.546015-16.452217 0.381144-32.974262 0.381144-49.506004a762.669454 762.669454 0 0 1 2.400332-82.758608 11.963838 11.963838 0 0 0-1.32382-0.381143c-11.586574-2.796993-23.967439-4.501957-36.860375-6.356274-12.18205-1.787399-24.281664-3.574798-36.31436-6.124484C48.021902 327.501161 33.986505 268.228956 38.55441 222.148395c4.817152-48.49641 46.792417-79.762799 106.610636-79.762799a153.534951 153.534951 0 0 1 30.107441 2.946347 205.240532 205.240532 0 0 1 69.517502 32.821998 142.177257 142.177257 0 0 0 57.248167 26.300853 57.171551 57.171551 0 0 0 8.27557-0.463579 245.261587 245.261587 0 0 1 45.000168-25.754838 435.577387 435.577387 0 0 1 165.096309-30.10744 468.415872 468.415872 0 0 1 186.753609 36.927293 307.008802 307.008802 0 0 1 35.768346 18.703195 64.235801 64.235801 0 0 0 9.070831 0.775865 137.578317 137.578317 0 0 0 58.72522-26.379409 206.350989 206.350989 0 0 1 69.517502-32.821998 153.330316 153.330316 0 0 1 30.025005-2.946347c59.966604 0 101.793485 31.348824 106.609667 79.762799 4.584392 46.163966-9.385057 105.368283-102.026245 125.462216-12.033666 2.632122-24.13231 4.353572-36.231924 6.124484-9.235703 1.32382-18.074744 2.632122-26.698484 4.267257a235.475021 235.475021 0 0 1 1.853347 54.620895l-1.851407 22.58155c-5.431055 65.942704-10.560492 128.243692 11.09002 189.782392 23.172177 65.79335 39.873641 136.4698 6.818883 207.774702-37.621693 80.607522-120.647004 118.707342-166.81097 134.069468a443.732698 443.732698 0 0 1-142.16368 21.169476zM145.165046 194.375339c-8.607252 0-51.674547 1.655502-54.770248 32.905403-3.310034 33.103249 5.892695 57.484806 61.241932 69.517502 10.791312 2.333414 21.798896 3.873506 32.739562 5.511551 13.50587 1.939662 27.459801 3.955942 41.379789 7.29895a174.154532 174.154532 0 0 1 25.059469 9.385056l2.796993 1.158949a26.118525 26.118525 0 0 1 15.526028 28.005816 566.373675 566.373675 0 0 0-4.501956 94.80876c0.149354 17.29694 0.314225 34.525991-0.314226 51.756983a489.376834 489.376834 0 0 1-32.507772 144.00054c-3.028783 9.070831-6.124484 18.206642-9.153267 27.459801a166.626702 166.626702 0 0 0 11.71847 143.686315c34.525991 56.638143 109.705368 99.460071 201.104202 114.52155 108.08284 17.760519 185.048646 15.277751 251.140705-6.982785 65.097981-21.798896 114.75334-60.745379 136.23801-106.841457 23.818085-51.31086 13.737659-104.508043-8.772123-168.596429-25.207853-71.917834-19.396624-142.759156-13.737659-211.184628l1.787399-22.427347a177.188164 177.188164 0 0 0-5.431055-61.440747 26.052576 26.052576 0 0 1 14.896607-31.0346 114.719396 114.719396 0 0 1 18.206642-6.438709c14.118803-3.310034 28.137713-5.34668 41.594121-7.29895 10.940666-1.655502 21.963768-3.178137 32.739563-5.511551 58.659272-12.728065 64.088387-40.883235 61.241932-69.517502-3.04527-31.266389-46.080561-32.821998-54.836197-32.821998a95.173417 95.173417 0 0 0-19.630354 1.939663 161.164613 161.164613 0 0 0-51.823901 25.603544 184.023535 184.023535 0 0 1-79.680363 34.212736 121.110583 121.110583 0 0 1-29.329636-1.853347 26.119494 26.119494 0 0 1-9.931072-3.724152 262.058094 262.058094 0 0 0-33.89851-18.074745 416.07893 416.07893 0 0 0-165.517216-32.364237 382.147445 382.147445 0 0 0-144.927698 25.986627 202.249573 202.249573 0 0 0-39.724287 23.586295 26.233935 26.233935 0 0 1-11.486681 4.733747 117.698717 117.698717 0 0 1-27.856462 1.655501 184.553062 184.553062 0 0 1-79.680363-34.212736 163.513544 163.513544 0 0 0-51.823902-25.603544 106.529171 106.529171 0 0 0-20.075506-1.803886z"
|
||||||
|
fill="#2F2F2F" p-id="5186"></path>
|
||||||
|
</svg>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: "AppLogo"
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
|
||||||
|
</style>
|
@ -65,12 +65,7 @@
|
|||||||
<div id="page-login">
|
<div id="page-login">
|
||||||
<div class="login-wrapper d-flex">
|
<div class="login-wrapper d-flex">
|
||||||
<div class="flex-1 left-picture">
|
<div class="flex-1 left-picture">
|
||||||
<svg class="logo-icon" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"
|
<app-logo class="logo-icon" />
|
||||||
xmlns:xlink="http://www.w3.org/1999/xlink" width="1000" height="1000">
|
|
||||||
<path
|
|
||||||
d="M549.766 97.925c19.974 4.609 50.703 35.339 62.995 55.312 35.339-13.828 36.875 41.484 46.094 55.312 23.047-16.901 46.094-35.339 46.094-55.312 0-21.51-30.729-35.339-30.729-41.484 0-12.292 38.411-12.292 41.484-12.292 50.703 0 106.016 39.948 106.016 96.797 0 27.656-9.219 41.484-33.802 70.677h32.266c21.51 0 27.656-3.073 55.312 7.682C923.125 294.591 960 348.367 960 389.852c0 3.073 0 9.219-1.536 13.828-4.609 3.073-12.292 3.073-16.901 4.609-15.365 1.536-32.266 6.146-47.63 7.682-47.63 0-50.703 0-53.776-1.536-1.536 1.536-1.536 0-1.536 4.609 0 3.073 7.682 44.557 10.755 67.604 9.219 56.849 12.292 115.234 19.974 173.62 1.536 7.682 7.682 15.365 9.219 23.047 3.073 13.828 6.146 27.656 6.146 39.948 0 153.646-245.833 208.958-321.119 208.958h-86.042c-115.234-9.219-248.906-52.24-301.145-138.281-4.609-7.682-18.437-39.948-18.437-50.703v-36.875c3.073-16.901 7.682-33.802 21.51-50.703v-84.505l12.292-132.135c-12.292 1.536-33.802 1.536-38.411 1.536-21.51 0-38.411-3.073-61.458-6.146-7.682-1.536-18.437-3.073-24.583-6.146-4.609-1.536-3.073-12.292-3.073-13.828 0-44.557 44.557-107.552 98.333-119.844 4.609-1.536 13.828-1.536 19.974-3.073l41.484-1.536c-13.828-10.755-36.875-46.094-36.875-59.922v-29.193c13.828-58.385 62.995-82.969 106.016-82.969 1.536 0 41.484 0 41.484 12.292 0 6.146-30.729 19.974-30.729 41.484 0 1.536 6.146 32.266 16.901 32.266 3.073 0-1.536-3.073 3.073-3.073 3.073 0 32.266 10.755 36.875 10.755h12.292l3.073-3.073c-19.974-16.901-30.729-36.875-36.875-53.776 12.292 7.682 18.438 9.219 29.193 9.219 27.656 0 46.094-15.365 78.359-29.193 24.583-10.755 52.24-13.828 78.359-18.437-12.292-9.219-24.583-16.901-36.875-23.047l38.411-1.536c7.68 1.537 15.362 4.61 23.044 6.146z"
|
|
||||||
></path>
|
|
||||||
</svg>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="login-form">
|
<div class="login-form">
|
||||||
<h1 class="title">天牛网盘</h1>
|
<h1 class="title">天牛网盘</h1>
|
||||||
@ -116,9 +111,11 @@ import {ElMessage, ElMessageBox} from "element-plus";
|
|||||||
import {useRouter} from 'vue-router'
|
import {useRouter} from 'vue-router'
|
||||||
import {useStore} from "vuex";
|
import {useStore} from "vuex";
|
||||||
import api from "../service/api";
|
import api from "../service/api";
|
||||||
|
import AppLogo from "../components/AppLogo.vue";
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'Login',
|
name: 'Login',
|
||||||
|
components: {AppLogo},
|
||||||
method: {
|
method: {
|
||||||
gotoMain() {
|
gotoMain() {
|
||||||
this.$router.push('/');
|
this.$router.push('/');
|
||||||
|
@ -3,12 +3,13 @@ import {ArrowDown, Grid, FolderAdd, Search} from '@element-plus/icons-vue'
|
|||||||
|
|
||||||
import FileUploader from "../components/file-uploader/Index.vue";
|
import FileUploader from "../components/file-uploader/Index.vue";
|
||||||
import {ElMessage} from "element-plus";
|
import {ElMessage} from "element-plus";
|
||||||
|
import AppLogo from "../components/AppLogo.vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
setup() {
|
setup() {
|
||||||
return {Search}
|
return {Search}
|
||||||
},
|
},
|
||||||
components: {ArrowDown, Grid, FolderAdd, FileUploader},
|
components: {AppLogo, ArrowDown, Grid, FolderAdd, FileUploader},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
currentActiveIndex: "/",
|
currentActiveIndex: "/",
|
||||||
@ -45,13 +46,7 @@ export default {
|
|||||||
<el-container>
|
<el-container>
|
||||||
<el-aside class="pan-left-aside">
|
<el-aside class="pan-left-aside">
|
||||||
<div class="logo-block">
|
<div class="logo-block">
|
||||||
<svg class="logo-icon" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"
|
<AppLogo class="logo-icon" />
|
||||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
||||||
width="1000" height="1000">
|
|
||||||
<path
|
|
||||||
d="M549.766 97.925c19.974 4.609 50.703 35.339 62.995 55.312 35.339-13.828 36.875 41.484 46.094 55.312 23.047-16.901 46.094-35.339 46.094-55.312 0-21.51-30.729-35.339-30.729-41.484 0-12.292 38.411-12.292 41.484-12.292 50.703 0 106.016 39.948 106.016 96.797 0 27.656-9.219 41.484-33.802 70.677h32.266c21.51 0 27.656-3.073 55.312 7.682C923.125 294.591 960 348.367 960 389.852c0 3.073 0 9.219-1.536 13.828-4.609 3.073-12.292 3.073-16.901 4.609-15.365 1.536-32.266 6.146-47.63 7.682-47.63 0-50.703 0-53.776-1.536-1.536 1.536-1.536 0-1.536 4.609 0 3.073 7.682 44.557 10.755 67.604 9.219 56.849 12.292 115.234 19.974 173.62 1.536 7.682 7.682 15.365 9.219 23.047 3.073 13.828 6.146 27.656 6.146 39.948 0 153.646-245.833 208.958-321.119 208.958h-86.042c-115.234-9.219-248.906-52.24-301.145-138.281-4.609-7.682-18.437-39.948-18.437-50.703v-36.875c3.073-16.901 7.682-33.802 21.51-50.703v-84.505l12.292-132.135c-12.292 1.536-33.802 1.536-38.411 1.536-21.51 0-38.411-3.073-61.458-6.146-7.682-1.536-18.437-3.073-24.583-6.146-4.609-1.536-3.073-12.292-3.073-13.828 0-44.557 44.557-107.552 98.333-119.844 4.609-1.536 13.828-1.536 19.974-3.073l41.484-1.536c-13.828-10.755-36.875-46.094-36.875-59.922v-29.193c13.828-58.385 62.995-82.969 106.016-82.969 1.536 0 41.484 0 41.484 12.292 0 6.146-30.729 19.974-30.729 41.484 0 1.536 6.146 32.266 16.901 32.266 3.073 0-1.536-3.073 3.073-3.073 3.073 0 32.266 10.755 36.875 10.755h12.292l3.073-3.073c-19.974-16.901-30.729-36.875-36.875-53.776 12.292 7.682 18.438 9.219 29.193 9.219 27.656 0 46.094-15.365 78.359-29.193 24.583-10.755 52.24-13.828 78.359-18.437-12.292-9.219-24.583-16.901-36.875-23.047l38.411-1.536c7.68 1.537 15.362 4.61 23.044 6.146z"
|
|
||||||
p-id="2967"></path>
|
|
||||||
</svg>
|
|
||||||
<span>牛牛的网盘</span>
|
<span>牛牛的网盘</span>
|
||||||
</div>
|
</div>
|
||||||
<el-menu :default-active="currentActiveIndex" class="pan-left-menu" :router="true">
|
<el-menu :default-active="currentActiveIndex" class="pan-left-menu" :router="true">
|
||||||
|
@ -5,24 +5,87 @@
|
|||||||
</div>
|
</div>
|
||||||
<div v-else class="share-content-wrapper">
|
<div v-else class="share-content-wrapper">
|
||||||
<!-- 分享信息有误 -->
|
<!-- 分享信息有误 -->
|
||||||
<el-result v-if="shareError" icon="warning"
|
<el-result v-if="shareError" icon="warning" sub-title="啊哦!没有找到分享数据,请打开正确的分享链接!">
|
||||||
sub-title="啊哦!没有找到分享数据,请打开正确的分享链接!"
|
|
||||||
>
|
|
||||||
</el-result>
|
</el-result>
|
||||||
<div v-else class="share-main">
|
<div v-else class="share-main">
|
||||||
<!-- 显示分享信息 -->
|
<!-- 显示分享信息 -->
|
||||||
|
<div v-if="passwordBox.show" class="password-box">
|
||||||
|
<div class="password-box-wrapper">
|
||||||
|
<div class="logo">
|
||||||
|
<app-logo class="app-logo"/>
|
||||||
|
<span>天牛网盘</span>
|
||||||
|
</div>
|
||||||
|
<div class="password-inner">
|
||||||
|
<div class="title">
|
||||||
|
<el-avatar :size="30" :src="shareUser.avatar" style="vertical-align: middle"/>
|
||||||
|
<span style="margin-left: 3px">{{ shareUser.nickname }} 给您加密分享了文件</span>
|
||||||
|
</div>
|
||||||
|
<div class="box-wrapper">
|
||||||
|
<div style="font-size: 14px;">请输入提取密码:</div>
|
||||||
|
<div class="box-inner">
|
||||||
|
<el-input v-model="passwordBox.value"/>
|
||||||
|
<el-button :disabled="passwordBox.value.length == 0" @click="submitView"
|
||||||
|
style="margin-left: 10px;width: 100px"
|
||||||
|
type="primary">提取
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-else class="share-file-wrapper">
|
||||||
|
<div class="share-file-content-box">
|
||||||
|
<div class="share-info">
|
||||||
|
<div class="file-title">{{ shareInfo.title }}</div>
|
||||||
|
<div class="other-info">
|
||||||
|
<span>{{ formatDate(shareInfo.createTime, 'YYYY-MM-DD HH:mm') }}</span>
|
||||||
|
<span>{{ shareInfo.live == -1 ? '长期有效' : (shareInfo.live / 3600 / 24 + '天') }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<el-table :data="fileListData" style="width: 100%">
|
||||||
|
<el-table-column type="selection"/>
|
||||||
|
<el-table-column label="名称">
|
||||||
|
<!-- 自定义单元格内容 -->
|
||||||
|
<template #default="file">
|
||||||
|
<div class="list-file-info" @click="showChild(file.row)">
|
||||||
|
<FileIcon class="list-file-icon" style="width: 40px;" :file="file.row"
|
||||||
|
:ext="file.row.type"/>
|
||||||
|
<span class="list-file-name">{{ file.row.name }}</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="size" label="大小" width="200">
|
||||||
|
<template #default="file">
|
||||||
|
<span class="list-file-size">{{ formatSize(file.row.size) }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="创建时间" width="200">
|
||||||
|
<template #default="file">
|
||||||
|
<span class="list-file-time">{{
|
||||||
|
formatDate(file.row.createTime, 'YYYY-MM-DD HH:mm')
|
||||||
|
}}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {useRoute} from "vue-router";
|
import {useRoute, useRouter} from "vue-router";
|
||||||
import api from "../service/api";
|
import api from "../service/api";
|
||||||
import {ref} from "vue";
|
import {reactive, ref, watchEffect} from "vue";
|
||||||
|
import AppLogo from "../components/AppLogo.vue";
|
||||||
|
import {ElMessage} from "element-plus";
|
||||||
|
import strings from "../service/strings";
|
||||||
|
import FileIcon from "../components/FileIcon.vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "Share",
|
name: "Share",
|
||||||
|
components: {AppLogo, FileIcon},
|
||||||
setup(props) {
|
setup(props) {
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const id = route.params.id // 获取动态路由的参数 实例: this.$route.params.id
|
const id = route.params.id // 获取动态路由的参数 实例: this.$route.params.id
|
||||||
@ -40,35 +103,179 @@ export default {
|
|||||||
* @type {Ref<UnwrapRef<ShareInfo>>}
|
* @type {Ref<UnwrapRef<ShareInfo>>}
|
||||||
*/
|
*/
|
||||||
const shareInfo = ref({})
|
const shareInfo = ref({})
|
||||||
|
/**
|
||||||
|
* 所有的文件数组
|
||||||
|
*/
|
||||||
const showShareFiles = () => {
|
const fileListData = ref([])
|
||||||
api.share.list(id).then(ret => {
|
/**
|
||||||
console.log(ret)
|
*
|
||||||
|
* @type {Ref<UnwrapRef<UserInfo>>}
|
||||||
|
*/
|
||||||
|
const shareUser = ref({})
|
||||||
|
const passwordBox = reactive({
|
||||||
|
show: false,
|
||||||
|
value: ''
|
||||||
})
|
})
|
||||||
|
// 分享密码保存的key
|
||||||
|
const authId = "net_driver_share_auth_" + id;
|
||||||
|
// 显示文件
|
||||||
|
const showShareFiles = async (path = '/') => {
|
||||||
|
try {
|
||||||
|
|
||||||
|
const currentPath = route.query.path || '/';
|
||||||
|
const result = await api.share.list(id, currentPath, passwordBox.value);
|
||||||
|
fileListData.value = result
|
||||||
|
} catch (e) {
|
||||||
|
ElMessage(e.message)
|
||||||
|
if (e.code && e.code == 1002) { // 密码错误
|
||||||
|
throw e;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 使用参数加载分享
|
// 使用参数加载分享
|
||||||
api.share.info(id).then(ret => {
|
api.share.info(id).then(ret => {
|
||||||
if (null == ret) shareError.value = true
|
if (null == ret) shareError.value = true
|
||||||
else {
|
else {
|
||||||
|
const {share, user} = ret
|
||||||
// 正确则显示分享信息
|
// 正确则显示分享信息
|
||||||
shareInfo.value = ret
|
shareInfo.value = share
|
||||||
// 开始加载文件
|
shareUser.value = user
|
||||||
|
|
||||||
|
// 需要输入密码 且本地没有保存的密码数据
|
||||||
|
if (ret.share.password && !sessionStorage.getItem(authId)) {
|
||||||
|
// 显示密码输入框
|
||||||
|
passwordBox.show = true
|
||||||
|
document.title = '天牛网盘 请输入提取密码'
|
||||||
|
} else {
|
||||||
|
passwordBox.value = sessionStorage.getItem(authId)
|
||||||
showShareFiles()
|
showShareFiles()
|
||||||
}
|
}
|
||||||
}).finally(() => {
|
// 开始加载文件
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}).catch(e => {
|
||||||
|
shareError.value = true
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
// 加载状态设置为false
|
// 加载状态设置为false
|
||||||
loadingData.value = false
|
loadingData.value = false
|
||||||
});
|
});
|
||||||
|
// 提交密码
|
||||||
|
const submitView = () => {
|
||||||
|
if (!passwordBox.value) return;
|
||||||
|
// 没有必要单独验证密码是否正确
|
||||||
|
// 直接使用密码 加载文件
|
||||||
|
showShareFiles().then(() => {
|
||||||
|
// 如果能够加载成功文件 说明密码正确
|
||||||
|
// 存储密码
|
||||||
|
sessionStorage.setItem(authId, passwordBox.value)
|
||||||
|
// 隐藏密码输入框
|
||||||
|
passwordBox.show = false
|
||||||
|
}).catch(e => console.log(e.message));
|
||||||
|
}
|
||||||
|
const router = useRouter()
|
||||||
|
watchEffect(()=>{
|
||||||
|
showShareFiles()
|
||||||
|
})
|
||||||
|
// 显示下一级目录
|
||||||
|
const showChild = (file) => {
|
||||||
|
if (file.type != 'folder') return
|
||||||
|
const currentPath = route.query.path || '';
|
||||||
|
router.push('?path=' + currentPath + '/' + file.name)
|
||||||
|
};
|
||||||
return {
|
return {
|
||||||
shareError, loadingData, shareInfo
|
shareError, loadingData, shareInfo, passwordBox, shareUser,
|
||||||
|
submitView, fileListData, showChild,
|
||||||
|
...strings,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped lang="less">
|
||||||
|
.password-box {
|
||||||
|
height: 100vh;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
background-color: #eef1f6;
|
||||||
|
|
||||||
|
.logo {
|
||||||
|
text-align: center;
|
||||||
|
font-size: 32px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.app-logo {
|
||||||
|
fill: var(--el-color-primary);
|
||||||
|
width: 80px;
|
||||||
|
height: 80px;
|
||||||
|
vertical-align: middle;
|
||||||
|
margin-right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.password-box-wrapper {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.password-inner {
|
||||||
|
width: 500px;
|
||||||
|
margin: auto;
|
||||||
|
background-color: #fff;
|
||||||
|
box-shadow: 0 0 4px rgba(0, 0, 0, 0.1);
|
||||||
|
border-radius: 5px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.title {
|
||||||
|
background-color: var(--el-color-primary);
|
||||||
|
color: #fff;
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.box-wrapper {
|
||||||
|
padding: 40px 50px 50px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.box-inner {
|
||||||
|
margin-top: 10px;
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.share-file-content-box {
|
||||||
|
}
|
||||||
|
|
||||||
|
.share-main {
|
||||||
|
padding-top: 50px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.share-content-wrapper {
|
||||||
|
height: 100vh;
|
||||||
|
background: #efefef;
|
||||||
|
}
|
||||||
|
|
||||||
|
.share-file-wrapper {
|
||||||
|
max-width: 1200px;
|
||||||
|
margin: auto;
|
||||||
|
background: #fff;
|
||||||
|
padding: 50px;
|
||||||
|
border-radius: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.list-file-info {
|
||||||
|
display: flex;
|
||||||
|
line-height: 40px;
|
||||||
|
height: 40px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.list-file-icon {
|
||||||
|
width: 40px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.list-file-name {
|
||||||
|
margin-left: 5px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
@ -188,11 +188,16 @@ export default {
|
|||||||
create(info) {
|
create(info) {
|
||||||
return request('/api/share/create', 'POST', info)
|
return request('/api/share/create', 'POST', info)
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {string} id
|
||||||
|
* @returns {Promise<ShareData>}
|
||||||
|
*/
|
||||||
info(id){
|
info(id){
|
||||||
return request('/api/share/info', 'GET', {id})
|
return request('/api/share/info', 'GET', {id})
|
||||||
},
|
},
|
||||||
list(id,parent='/'){
|
list(id,parent='/',password){
|
||||||
return request('/api/share/list', 'GET', {id,parent})
|
return request('/api/share/list', 'GET', {id,parent,password})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
code() {
|
code() {
|
||||||
|
@ -13,8 +13,8 @@ export function formatDate(time, format = 'MM-DD') {
|
|||||||
return dayjs(time).format(format);
|
return dayjs(time).format(format);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function formatSize(a, b = 2) {
|
export function formatSize(a, b = 1) {
|
||||||
if (0 == a) return "0 B";
|
if (0 == a) return "-";
|
||||||
let c = 1024, d = b || 2, e = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"],
|
let c = 1024, d = b || 2, e = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"],
|
||||||
f = Math.floor(Math.log(a) / Math.log(c));
|
f = Math.floor(Math.log(a) / Math.log(c));
|
||||||
return parseFloat((a / Math.pow(c, f)).toFixed(d)) + " " + e[f];
|
return parseFloat((a / Math.pow(c, f)).toFixed(d)) + " " + e[f];
|
||||||
|
9
web/src/service/type.d.ts
vendored
9
web/src/service/type.d.ts
vendored
@ -3,6 +3,7 @@ interface ApiResult<T> {
|
|||||||
message: string
|
message: string
|
||||||
data: T
|
data: T
|
||||||
}
|
}
|
||||||
|
|
||||||
declare type FileItem = {
|
declare type FileItem = {
|
||||||
createTime: string,
|
createTime: string,
|
||||||
id: number,
|
id: number,
|
||||||
@ -55,6 +56,14 @@ declare type UserInfo = {
|
|||||||
status: number
|
status: number
|
||||||
updateTime: string
|
updateTime: string
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 分享数据
|
||||||
|
*/
|
||||||
|
declare type ShareData = {
|
||||||
|
share: ShareInfo
|
||||||
|
user: UserInfo
|
||||||
|
}
|
||||||
|
|
||||||
declare type LoginUser = {
|
declare type LoginUser = {
|
||||||
account: string
|
account: string
|
||||||
permissions: string[]
|
permissions: string[]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user