Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions src/components/UploadForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@
<el-button type="primary" round style="outline: none; border-right: none;">
<font-awesome-icon icon="trash-alt" />
</el-button>
<template v-slot:dropdown>
<el-dropdown-menu slot="dropdown">
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item @click="clearFileList">清空全部</el-dropdown-item>
<el-dropdown-item @click="clearSuccessList">清空已上传</el-dropdown-item>
</el-dropdown-menu>
Expand Down Expand Up @@ -220,6 +220,11 @@ props: {
type: String,
default: 'default',
required: false
},
uploadFolder: {
type: String,
default: '',
required: false
}
},
data() {
Expand Down Expand Up @@ -357,7 +362,12 @@ methods: {
formData.append('url', file.file.url)
}
axios({
url: '/upload' + '?authCode=' + cookies.get('authCode') + '&serverCompress=' + needServerCompress + '&uploadChannel=' + uploadChannel + '&uploadNameType=' + uploadNameType + '&autoRetry=' + autoRetry,
url: '/upload' + '?authCode=' + cookies.get('authCode') +
'&serverCompress=' + needServerCompress +
'&uploadChannel=' + uploadChannel +
'&uploadNameType=' + uploadNameType +
'&autoRetry=' + autoRetry +
'&uploadFolder=' + this.uploadFolder,
method: 'post',
data: formData,
onUploadProgress: (progressEvent) => {
Expand Down
17 changes: 17 additions & 0 deletions src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export default createStore({
},
useDarkMode: null,
cusDarkMode: false,
uploadFolder: '',
},
getters: {
userConfig: state => state.userConfig,
Expand All @@ -42,6 +43,9 @@ export default createStore({
adminUrlSettings: state => state.adminUrlSettings,
useDarkMode: state => state.useDarkMode,
cusDarkMode: state => state.cusDarkMode,
storeUploadFolder: (state) => {
return state.uploadFolder || localStorage.getItem('uploadFolder') || ''
}
},
mutations: {
setUserConfig(state, userConfig) {
Expand Down Expand Up @@ -83,6 +87,10 @@ export default createStore({
setCusDarkMode(state, cusDarkMode) {
state.cusDarkMode = cusDarkMode;
},
setStoreUploadFolder(state, folder) {
state.uploadFolder = folder
localStorage.setItem('uploadFolder', folder)
}
},
actions: {
async fetchUserConfig({ commit }) {
Expand Down Expand Up @@ -118,6 +126,15 @@ export default createStore({
} catch (error) {
console.log(error);
}
},
initializeStore({ commit }) {
// ... existing initialization code ...

// 初始化上传文件夹设置
const uploadFolder = localStorage.getItem('uploadFolder')
if (uploadFolder) {
commit('setStoreUploadFolder', uploadFolder)
}
}
},
modules: {
Expand Down
66 changes: 66 additions & 0 deletions src/utils/fileManager.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// 文件管理器工具类
class FileManager {
constructor() {
this.FILE_LIST_PATH = 'data/fileList.json';
}

// 从本地存储读取文件列表
getLocalFileList() {
try {
const fileList = localStorage.getItem(this.FILE_LIST_PATH);
return fileList ? JSON.parse(fileList) : [];
} catch (error) {
console.error('Error reading local file list:', error);
return [];
}
}

// 保存文件列表到本地存储
saveFileList(fileList) {
try {
localStorage.setItem(this.FILE_LIST_PATH, JSON.stringify(fileList));
return true;
} catch (error) {
console.error('Error saving file list:', error);
return false;
}
}

// 添加新文件到列表
addFile(newFile) {
try {
const fileList = this.getLocalFileList();
fileList.push(newFile);
return this.saveFileList(fileList);
} catch (error) {
console.error('Error adding file:', error);
return false;
}
}

// 从列表中删除文件
removeFile(fileName) {
try {
let fileList = this.getLocalFileList();
fileList = fileList.filter(file => file.name !== fileName);
return this.saveFileList(fileList);
} catch (error) {
console.error('Error removing file:', error);
return false;
}
}

// 更新文件列表
async refreshFileList(fetchWithAuth) {
try {
const response = await fetchWithAuth('/api/manage/list?count=60', { method: 'GET' });
const newFileList = await response.json();
return this.saveFileList(newFileList);
} catch (error) {
console.error('Error refreshing file list:', error);
return false;
}
}
}

export const fileManager = new FileManager();
Loading