Merge branch 'main' into Mobile

This commit is contained in:
MoYiJiangNan 2023-12-04 22:24:45 +08:00 committed by GitHub
commit c0b015cbf1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 893 additions and 326 deletions

2
auto-imports.d.ts vendored
View File

@ -5,5 +5,7 @@
// Generated by unplugin-auto-import
export {}
declare global {
const ElMess: typeof import('element-plus/es')['ElMess']
const ElMessaeg: typeof import('element-plus/es')['ElMessaeg']
const ElMessage: typeof import('element-plus/es')['ElMessage']
}

4
components.d.ts vendored
View File

@ -7,7 +7,6 @@ export {}
declare module 'vue' {
export interface GlobalComponents {
ElAvatar: typeof import('element-plus/es')['ElAvatar']
ElButton: typeof import('element-plus/es')['ElButton']
ElCard: typeof import('element-plus/es')['ElCard']
ElCol: typeof import('element-plus/es')['ElCol']
@ -17,16 +16,15 @@ declare module 'vue' {
ElPagination: typeof import('element-plus/es')['ElPagination']
ElRow: typeof import('element-plus/es')['ElRow']
ElSelect: typeof import('element-plus/es')['ElSelect']
ElSwitch: typeof import('element-plus/es')['ElSwitch']
ElTable: typeof import('element-plus/es')['ElTable']
ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
ElTag: typeof import('element-plus/es')['ElTag']
ElUpload: typeof import('element-plus/es')['ElUpload']
ElWatermark: typeof import('element-plus/es')['ElWatermark']
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']
VanButton: typeof import('vant/es')['Button']
VanCellGroup: typeof import('vant/es')['CellGroup']
VanConfigProvider: typeof import('vant/es')['ConfigProvider']
VanField: typeof import('vant/es')['Field']
VanImage: typeof import('vant/es')['Image']
VanPopup: typeof import('vant/es')['Popup']

25
package-lock.json generated
View File

@ -11,7 +11,8 @@
"@types/crypto-js": "^4.2.1",
"axios": "^1.6.2",
"crypto-js": "^4.2.0",
"element-plus": "^2.4.2",
"echarts": "^5.4.3",
"element-plus": "^2.4.3",
"vant": "^4.7.3",
"vue": "^3.3.4",
"vue-router": "^4.2.5"
@ -1590,6 +1591,15 @@
"node": ">=6.0.0"
}
},
"node_modules/echarts": {
"version": "5.4.3",
"resolved": "https://registry.npmmirror.com/echarts/-/echarts-5.4.3.tgz",
"integrity": "sha512-mYKxLxhzy6zyTi/FaEbJMOZU1ULGEQHaeIeuMR5L+JnJTpz+YR03mnnpBhbR4+UYJAgiXgpyTVLffPAjOTLkZA==",
"dependencies": {
"tslib": "2.3.0",
"zrender": "5.4.4"
}
},
"node_modules/element-plus": {
"version": "2.4.3",
"resolved": "https://registry.npmmirror.com/element-plus/-/element-plus-2.4.3.tgz",
@ -2877,6 +2887,11 @@
"typescript": ">=4.2.0"
}
},
"node_modules/tslib": {
"version": "2.3.0",
"resolved": "https://registry.npmmirror.com/tslib/-/tslib-2.3.0.tgz",
"integrity": "sha512-N82ooyxVNm6h1riLCoyS9e3fuJ3AMG2zIZs2Gd1ATcSFjSA23Q0fzjjZeh0jbJvWVDZ0cJT8yaNNaaXHzueNjg=="
},
"node_modules/type-check": {
"version": "0.4.0",
"resolved": "https://registry.npmmirror.com/type-check/-/type-check-0.4.0.tgz",
@ -3297,6 +3312,14 @@
"engines": {
"node": ">=10"
}
},
"node_modules/zrender": {
"version": "5.4.4",
"resolved": "https://registry.npmmirror.com/zrender/-/zrender-5.4.4.tgz",
"integrity": "sha512-0VxCNJ7AGOMCWeHVyTrGzUgrK4asT4ml9PEkeGirAkKNYXYzoPJCLvmyfdoOXcjTHPs10OZVMfD1Rwg16AZyYw==",
"dependencies": {
"tslib": "2.3.0"
}
}
}
}

View File

@ -12,7 +12,8 @@
"@types/crypto-js": "^4.2.1",
"axios": "^1.6.2",
"crypto-js": "^4.2.0",
"element-plus": "^2.4.2",
"echarts": "^5.4.3",
"element-plus": "^2.4.3",
"vant": "^4.7.3",
"vue": "^3.3.4",
"vue-router": "^4.2.5"

View File

@ -11,7 +11,7 @@ const onInitOrResize = () => {
}
}
onMounted(() => {
window.onresize = onInitOrResize;
window.addEventListener("resize", onInitOrResize);
onInitOrResize();
})
</script>

View File

@ -5,6 +5,8 @@ import {md5Hex} from "./CryptoUtils";
import {User} from "../entities/User";
import {Auth} from "../entities/Auth";
import {File} from "../entities/File";
import {SearchType} from "../entities/SearchType.ts";
import {AccessInformation} from "../entities/AccessInformation.ts";
export const baseUrl = 'http://localhost:8081';
@ -26,7 +28,7 @@ const instance = axios.create({
timeout: 1000,
headers: {'Content-Type': 'application/json'}
});
axios.interceptors.request.use(function (config) {
instance.interceptors.request.use(function (config) {
config.headers['Authorization'] = window.sessionStorage.getItem("authorization");
return config;
}, function (error) {
@ -35,8 +37,8 @@ axios.interceptors.request.use(function (config) {
});
// 添加响应拦截器
axios.interceptors.response.use(function (response) {
const authorization = response.headers['Set-Authorization'];
instance.interceptors.response.use(function (response) {
const authorization = response.headers['set-authorization'];
if (authorization) {
window.sessionStorage.setItem("authorization", authorization);
}
@ -44,12 +46,24 @@ axios.interceptors.response.use(function (response) {
}, function (error) {
return Promise.reject(error);
});
/**
*
* @param username
* @param password
*/
export const login = (username: string, password: string) => {
return instance.post<Result<User>>("/api/user/login", {
name: username,
password: md5Hex(password)
})
}
/**
*
* @param username
* @param password
* @param auth Auth.user或Auth.admin
* @param verifyCode Auth.user则无需填写
*/
export const register = (username: string, password: string, auth: Auth, verifyCode?: string) => {
return instance.post<Result<User>>("/api/user/register", {
name: username,
@ -58,13 +72,26 @@ export const register = (username: string, password: string, auth: Auth, verifyC
verifyCode: verifyCode,
})
}
/**
*
*/
export const generatorVerifyCode = () => {
return instance.get<Result<string>>("/api/user/verifyCode")
}
// 获取文件
/**
*
* @param page
* @param num
*/
export const getAllFiles = (page: number, num: number) => {
return instance.get<PageResult<File>>("/api/file/getAll", {params: {num, page}});
}
// 上传文件
/**
*
* @param options el-upload的http-request方法调用时传入
* @param controller
*/
export const upload = (options: UploadRequestOptions, controller: AbortController) => {
const param = new FormData();
param.append("file", options.file);
@ -81,4 +108,62 @@ export const upload = (options: UploadRequestOptions, controller: AbortControlle
},
signal: controller.signal
})
}
/**
*
* @param id id
*/
export const getLink = (id: number) => {
return instance.get<Result<string>>("/api/file/link", {params: {id}});
}
/**
*
* @param id id
*/
export const remove = (id: number) => {
return instance.post<Result<boolean>>("/api/file/remove", {id});
}
const handlerSearchType = (searchType: SearchType): string => {
switch (searchType){
case SearchType.ID:
return "ID"
case SearchType.TYPE:
return "TYPE"
case SearchType.UPLOAD_DAY:
return "UPLOAD_DAY"
case SearchType.UPLOADER:
return "UPLOADER"
default:
return "FILE_NAME"
}
}
/**
*
* @param page
* @param num
* @param searchType
* @param data
*/
export const search = (page: number, num: number, searchType: SearchType, data: string) => {
return instance.get<PageResult<File>>("/api/file/search", {params: {page, num, type: handlerSearchType(searchType), data}});
}
/**
* 访
* @param count
*/
export const getAccessInformation = (count: number) => {
return instance.get<AccessInformation[]>("/api/access/get", {params: {count}});
}
/**
* 访
*/
export const getTotalAccessInformation = () => {
return instance.get<AccessInformation>("/api/access/getAll");
}
/**
*
* @param filename
*/
export const checkUpload = (filename: string) => {
return instance.get<Result<boolean>>("/api/file/checkUpload", {params: {filename}});
}

View File

@ -0,0 +1,17 @@
/**
* 访
*/
export interface AccessInformation {
/**
*
*/
totalDownload: number;
/**
* 访
*/
totalAccess: number;
/**
*
*/
date: string;
}

View File

@ -1,3 +1,13 @@
/**
*
*/
export enum Auth {
user, admin
/**
*
*/
USER,
/**
*
*/
ADMIN,
}

View File

@ -1,10 +1,37 @@
/**
*
*/
export interface File {
/**
*
*/
downloadCount: number;
/**
* hashsha512
*/
hash: string;
/**
* id
*/
id: number;
/**
*
*/
name: string;
/**
*
*/
size: number;
/**
*
*/
type: string;
/**
*
*/
uploadTime: string;
/**
*
*/
uploaderName: string;
}

View File

@ -0,0 +1,25 @@
/**
*
*/
export enum SearchType {
/**
*
*/
FILE_NAME,
/**
* ID
*/
ID,
/**
*
*/
UPLOADER,
/**
*
*/
UPLOAD_DAY,
/**
*
*/
TYPE
}

View File

@ -1,7 +1,19 @@
import {Auth} from "./Auth";
/**
*
*/
export interface User {
id: string
/**
* id
*/
id: number;
/**
*
*/
name: string;
/**
*
*/
auth: Auth;
}

View File

@ -3,6 +3,7 @@ import './style.css'
import App from './App.vue'
import Mobile from './views/AppMobile.vue'
import PC from './views/AppPC.vue'
import 'element-plus/dist/index.css';
import {createRouter, createWebHashHistory} from "vue-router";
const router = createRouter({

View File

@ -120,6 +120,24 @@
<h2>emm咱就是说这个分享站好像有点bug这个东西好像展示不出来捏:&lt;</h2>
</div>
</van-popup>
<!-- 文件详情 -->
<van-popup v-model:show="showFileInformation" round>
<div class="file-information-popover" v-if="nowSelectedFileInformation">
<h2>文件名称:<span>{{ nowSelectedFileInformation.name }}</span></h2>
<div>
<p>文件ID: <span>{{ nowSelectedFileInformation.id }}</span></p>
<p>文件类型: <span>{{ nowSelectedFileInformation.type }}</span></p>
<p>文件大小: <span>{{ parserByteSize(nowSelectedFileInformation.size) }}</span></p>
<p title="点击复制"><a class="file-hash-a" @click="copyFullHash">文件校验值:
<span>{{ shortHash(nowSelectedFileInformation.hash) }}</span></a></p>
<p>文件上传者: <span>{{ nowSelectedFileInformation.uploaderName }}</span></p>
<p>文件上传时间: <span>{{ nowSelectedFileInformation.uploadTime }}</span></p>
</div>
</div>
<div class="file-information-popover" v-else>
<h2>emm咱就是说这个分享站好像有点bug这个东西好像展示不出来捏:&lt;</h2>
</div>
</van-popup>
</div>
<div class="fileLiteBox">
<el-table ref="fileListTable" :data="pageFileData" class="files-data-table" border stripe>
@ -511,7 +529,6 @@ const handleUpload = (options: UploadRequestOptions): XMLHttpRequest | Promise<u
return promise;
}
// TODO:
onBeforeMount(() => {
initTheme();

File diff suppressed because it is too large Load Diff

View File

@ -20,6 +20,12 @@
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
"include": [
"src/**/*.ts",
"src/**/*.d.ts",
"src/**/*.tsx",
"src/**/*.vue",
"auto-imports.d.ts"
],
"references": [{ "path": "./tsconfig.node.json" }]
}

View File

@ -24,7 +24,9 @@ export default defineConfig({
}),
Components({
resolvers: [
ElementPlusResolver(),
ElementPlusResolver({
importStyle: "css", // 确保样式也被自动导入
}),
VantResolver(),
],
}),