From 90bda7f0c9f6a487c2473eb26e4e5d5ab96a95f1 Mon Sep 17 00:00:00 2001 From: chl <11571174+chl010909@user.noreply.gitee.com> Date: Mon, 17 Apr 2023 03:46:43 +0000 Subject: [PATCH] =?UTF-8?q?!2154=20=E6=96=B0=E5=A2=9E:=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E9=87=8D=E5=91=BD=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Common/HostUrl.ts | 1 + src/UI/Components/SourceManage/ImgList.tsx | 41 ++++++++-- .../Components/SourceManage/TexturePanel.tsx | 74 +++++++++++++++---- 3 files changed, 97 insertions(+), 19 deletions(-) diff --git a/src/Common/HostUrl.ts b/src/Common/HostUrl.ts index 25f6dbdcb..271a9e79d 100644 --- a/src/Common/HostUrl.ts +++ b/src/Common/HostUrl.ts @@ -27,6 +27,7 @@ export const ImgsUrl = { upload: CURRENT_HOST + "/CAD-imageUpload", delete: CURRENT_HOST + "/CAD-imageDelete", logo: CURRENT_HOST + "/CAD-logoUpload", + update: CURRENT_HOST + "/CAD-imageUpdate" }; export const DirUrl = { query: CURRENT_HOST + "/CAD-dirQuery", diff --git a/src/UI/Components/SourceManage/ImgList.tsx b/src/UI/Components/SourceManage/ImgList.tsx index 0fe3163e2..6ec6cbd2a 100644 --- a/src/UI/Components/SourceManage/ImgList.tsx +++ b/src/UI/Components/SourceManage/ImgList.tsx @@ -1,5 +1,5 @@ -import { Button, Card, Checkbox, Classes, Intent, Popover, Position } from '@blueprintjs/core'; -import { observable } from 'mobx'; +import { Button, Card, Checkbox, Classes, ContextMenu, Intent, Menu, MenuItem, Popover, Position } from '@blueprintjs/core'; +import { IObservableValue } from 'mobx'; import { inject, observer } from 'mobx-react'; import * as React from 'react'; import { app } from '../../../ApplicationServices/Application'; @@ -14,6 +14,8 @@ export interface IImgListProps store?: MaterialStore; select?: (e, data) => void; selectIds?: Set; + isRename: IObservableValue; + info: { fid: string, name: string; }; showInfos?: boolean; isShowSize?: boolean; } @@ -21,7 +23,6 @@ export interface IImgListProps @inject('store') @observer export class ImgList extends React.Component { - @observable private isShowSize = false; renderEditorPanel(pic) { return ( @@ -60,7 +61,8 @@ export class ImgList extends React.Component { ); } - handleApplyPic = (pic) => + + _HandleApplyPic = (pic) => { const store = this.props.store; if (store instanceof MaterialStore) @@ -69,6 +71,32 @@ export class ImgList extends React.Component { store.currentTextureTable.Name = app.Database.TextureTable.AllocateName(); } }; + + _ShowContextMenu = (e: React.MouseEvent, data) => + { + + ContextMenu.show( + + + { + this.props.info.fid = data.image_id; + this.props.info.name = data.name; + this.props.isRename.set(true); + }} + /> + , + { left: e.clientX, top: e.clientY }, + () => this.setState({ isContextMenuOpen: false }), + ); + this.setState({ isContextMenuOpen: true }); + + e.stopPropagation(); + e.preventDefault(); + }; + public render() { const isMatStore = this.props.store instanceof MaterialStore; @@ -81,7 +109,8 @@ export class ImgList extends React.Component { select={this.props.select} showInfos={this.props.showInfos} selectData={this.props.selectIds} - dbclickImg={(data) => this.handleApplyPic(data)} + showContextMenu={this._ShowContextMenu} + dbclickImg={(data) => this._HandleApplyPic(data)} preview={true} hintClassName={isMatStore && "apply-img-hint"} renderButtons={(data) => <> @@ -90,7 +119,7 @@ export class ImgList extends React.Component { <>