diff --git a/package.json b/package.json index c1783df..6d38de1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "filecat", - "version": "2.8.2", + "version": "2.9.0", "description": "filecat 文件管理器", "author": "xiaobaidadada", "scripts": { diff --git a/src/common/ListUtil.ts b/src/common/ListUtil.ts index 016ddc3..c1d7c51 100644 --- a/src/common/ListUtil.ts +++ b/src/common/ListUtil.ts @@ -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]; diff --git a/src/common/req/user.req.ts b/src/common/req/user.req.ts index 38bb243..c8efc74 100644 --- a/src/common/req/user.req.ts +++ b/src/common/req/user.req.ts @@ -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 作用) @@ -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; diff --git a/src/main/domain/user/user.controller.ts b/src/main/domain/user/user.controller.ts index 00e1de2..f6907f1 100644 --- a/src/main/domain/user/user.controller.ts +++ b/src/main/domain/user/user.controller.ts @@ -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'); } @@ -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') diff --git a/src/main/domain/user/user.service.ts b/src/main/domain/user/user.service.ts index 7957398..1b8ef52 100644 --- a/src/main/domain/user/user.service.ts +++ b/src/main/domain/user/user.service.ts @@ -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 @@ -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 = [] diff --git a/src/web/project/component/file/FileList.tsx b/src/web/project/component/file/FileList.tsx index 24a9e9e..9ebeb91 100644 --- a/src/web/project/component/file/FileList.tsx +++ b/src/web/project/component/file/FileList.tsx @@ -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"; @@ -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); @@ -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); @@ -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); @@ -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([]) @@ -441,7 +441,7 @@ export default function FileList() { baseSwitch(v); }} pre_value={file_root_path}/> -
{setIsFocused(true)}} onMouseLeave={()=>{setIsFocused(false)}}> +
{setIsFocused(true)}} onMouseLeave={()=>{setIsFocused(false)}}> {} {(nowFileList.folders && nowFileList.folders.length > 0) &&

{t("文件夹")}

} {(nowFileList.folders) && diff --git a/src/web/project/component/setting/CustomerRouter.tsx b/src/web/project/component/setting/CustomerRouter.tsx index 3c502fa..11ea985 100644 --- a/src/web/project/component/setting/CustomerRouter.tsx +++ b/src/web/project/component/setting/CustomerRouter.tsx @@ -54,7 +54,7 @@ export function CustomerRouter() { } const worlfow_api_info_click = ()=>{ let context =
- 需要以 "/api" 开头的路由,文件路径是有效的workflow路径。token也可以是文件绝对路径 + 需要以 "/api" 开头的路由,文件路径是有效的workflow路径。token也可以是文件绝对路径,请求的时候请设置同样的authorization请求头字段。
; set_prompt_card({open:true,title:"信息",context_div : (