Skip to content

Commit

Permalink
2.9.0 文件列表历史样式
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaobaidadada committed Feb 14, 2025
1 parent a91cce5 commit 947eb16
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 18 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "filecat",
"version": "2.8.2",
"version": "2.9.0",
"description": "filecat 文件管理器",
"author": "xiaobaidadada",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/common/ListUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export function getNextByLoop(list, value) {
const index = getIndexByList(list, value);

if (index === null) {
return null;
return list[0]; // 默认第一个
}
if (index === list.length - 1) {
return list[0];
Expand Down
10 changes: 10 additions & 0 deletions src/common/req/user.req.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ export enum UserAuth {
workflow_api, // workflow 自定义触发api
}


export enum FileListShowTypeEmum {
block = "",
list = "list",
gallery = "gallery",

}

export class UserData extends UserLogin {
cwd: string; // 目录顶级范围 (role 作用)
access_dirs: string[] = []; // cwd 是第一个 这里是其它的可访问的 (role 作用)
Expand All @@ -85,6 +93,8 @@ export class UserData extends UserLogin {
protection_directory:any[]; // 保护目录
bind_role_id:string; // 绑定的角色id

file_list_show_type:FileListShowTypeEmum;


// 用于角色的
role_id:string;
Expand Down
17 changes: 13 additions & 4 deletions src/main/domain/user/user.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ export class UserController {
if(!user_data) {
throw "user data not found";
}
if(user.username)
user_data.username = user.username;
user_data.hash_password = hash_string(user.password);
userService.save_user_info(user.user_id,user_data);
// if(user.username)
// user_data.username = user.username;
// user_data.hash_password = hash_string(user.password);
userService.save_user_info(user.user_id,{username:user.username,hash_password:hash_string(user.password)} as UserData);
return Sucess('ok');
}

Expand Down Expand Up @@ -164,6 +164,15 @@ export class UserController {
return Sucess("");
}

// 用户样式类型
@Post('/save_user_file_list_show_type')
save_user_file_list_show_type(@Body() body: {type:string},@Req() req: Request) {
const user_data = userService.get_user_info_by_token(req.headers.authorization);
const user_id = userService.get_user_id(user_data.username);
userService.only_update_user_data(user_id,{file_list_show_type:body.type} as UserData);
return Sucess("");
}


// 删除用户
@Post('/delete_user')
Expand Down
11 changes: 11 additions & 0 deletions src/main/domain/user/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export class UserService {
}

public get_user_id(username: string): string {
username = `${username}`;
const root_username = this.get_root_name();
if (username === root_username) {
// root 账号 使用 -1
Expand Down Expand Up @@ -143,6 +144,16 @@ export class UserService {
this.load_user_cmd_path(id); // 权限更新
}

// 更新用户数据不做校验
public only_update_user_data(id: string, data: UserData){
let mapping = DataUtil.get(data_common_key.user_id_info_data_mapping);
if (!mapping) {
mapping = {}
}
mapping[id] = {...mapping[id], ...data}; // 覆盖之前的属性
DataUtil.set(data_common_key.user_id_info_data_mapping, mapping);
}

// 重新设置用户路径数据
private user_data_reset_check(user_data:UserData) {
const list = []
Expand Down
22 changes: 11 additions & 11 deletions src/web/project/component/file/FileList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {FileItem} from "./FileItem";
import {RouteBreadcrumbs} from "../../../meta/component/RouteBreadcrumbs";
import {useRecoilState} from "recoil";
import {$stroe} from "../../util/store";
import {fileHttp} from "../../util/config";
import {fileHttp, userHttp} from "../../util/config";
import {useLocation, useNavigate} from "react-router-dom";
import {ActionButton} from "../../../meta/component/Button";
import Header from "../../../meta/component/Header";
Expand All @@ -29,14 +29,9 @@ import {workflow_dir_name, WorkFlowRealTimeReq} from "../../../../common/req/fil
import {ws} from "../../util/ws";
import {CmdType} from "../../../../common/frame/WsData";
import {WorkFlowRealTime} from "./component/workflow/WorkFlowRealTime";
import {FileListShowTypeEmum} from "../../../../common/req/user.req";


export enum FileListShowTypeEmum {
block = "",
list = "list",
gallery = "gallery",

}


const fileTypes = Object.values(FileListShowTypeEmum);
Expand All @@ -58,7 +53,7 @@ export default function FileList() {
const navigate = useNavigate();

const [nowFileList, setNowFileList] = useRecoilState($stroe.nowFileList);
const [fileType, setFileType] = useRecoilState($stroe.fileShowType);
// const [fileType, setFileType] = useRecoilState($stroe.fileShowType);
const [uploadFiles, setUploadFiles] = useRecoilState($stroe.uploadFiles);
const [showPrompt, setShowPrompt] = useRecoilState($stroe.showPrompt);
const [selectedFile, setSelectedFile] = useRecoilState($stroe.selectedFileList);
Expand All @@ -78,6 +73,8 @@ export default function FileList() {
const [workflow_show_click,set_workflow_show_click] = useState(false);

const {reloadUserInfo} = useContext(GlobalContext);
const {initUserInfo} = useContext(GlobalContext);
const [user_base_info,setUser_base_info] = useRecoilState($stroe.user_base_info);
const { click_file } = user_click_file();

const [prompt_card, set_prompt_card] = useRecoilState($stroe.prompt_card);
Expand Down Expand Up @@ -198,8 +195,11 @@ export default function FileList() {
}
}
}, []);
function switchGridView() {
setFileType(getNextByLoop(fileTypes, fileType))
async function switchGridView() {
// setFileType(getNextByLoop(fileTypes, fileType));
const type = getNextByLoop(fileTypes, user_base_info?.user_data?.file_list_show_type??'');
await userHttp.post('save_user_file_list_show_type',{type});
initUserInfo();
}
function routerClick() {
setSelectList([])
Expand Down Expand Up @@ -441,7 +441,7 @@ export default function FileList() {
baseSwitch(v);
}} pre_value={file_root_path}/>
</Header>
<div id={"listing"} className={`mosaic file-icons ${fileType}`} ref={inputRef} onMouseEnter={()=>{setIsFocused(true)}} onMouseLeave={()=>{setIsFocused(false)}}>
<div id={"listing"} className={`mosaic file-icons ${user_base_info?.user_data?.file_list_show_type??''}`} ref={inputRef} onMouseEnter={()=>{setIsFocused(true)}} onMouseLeave={()=>{setIsFocused(false)}}>
{<RouteBreadcrumbs baseRoute={"file"} clickFun={routerClick}></RouteBreadcrumbs>}
{(nowFileList.folders && nowFileList.folders.length > 0) && <h2>{t("文件夹")}</h2>}
{(nowFileList.folders) &&
Expand Down
2 changes: 1 addition & 1 deletion src/web/project/component/setting/CustomerRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function CustomerRouter() {
}
const worlfow_api_info_click = ()=>{
let context = <div>
需要以 "/api" 开头的路由,文件路径是有效的workflow路径。token也可以是文件绝对路径
需要以 "/api" 开头的路由,文件路径是有效的workflow路径。token也可以是文件绝对路径,请求的时候请设置同样的authorization请求头字段。
</div>;
set_prompt_card({open:true,title:"信息",context_div : (
<div >
Expand Down

0 comments on commit 947eb16

Please sign in to comment.