将自动保存修改为点击按钮保存:import * as THREE from 'three'; import { UIPanel, UIText } from './libs/ui.js'; import { UIBoolean } from './libs/ui.three.js'; function MenubarStatus( editor ) { const strings = editor.strings; const container = new UIPanel(); container.setClass( 'menu right' ); const autosave = new UIBoolean( editor.config.getKey( 'autosave' ), strings.getKey( 'menubar/status/autosave' ) ); autosave.text.setColor( '#888' ); autosave.onChange( function () { const value = this.getValue(); editor.config.setKey( 'autosave', value ); if ( value === true ) { editor.signals.sceneGraphChanged.dispatch(); } } ); container.add( autosave ); editor.signals.savingStarted.add( function () { autosave.text.setTextDecoration( 'underline' ); } ); editor.signals.savingFinished.add( function () { autosave.text.setTextDecoration( 'none' ); } ); const version = new UIText( 'r' + THREE.REVISION ); version.setClass( 'title' ); version.setOpacity( 0.5 ); container.add( version ); return container; } export { MenubarStatus };
时间: 2024-02-01 20:02:14 浏览: 61
FlaUInspect V1.3.0
为了将自动保存修改为点击按钮保存,你需要将以下代码:
```
const autosave = new UIBoolean( editor.config.getKey( 'autosave' ), strings.getKey( 'menubar/status/autosave' ) );
autosave.text.setColor( '#888' );
autosave.onChange( function () {
const value = this.getValue();
editor.config.setKey( 'autosave', value );
if ( value === true ) {
editor.signals.sceneGraphChanged.dispatch();
}
} );
container.add( autosave );
```
替换为以下代码:
```
const saveButton = new UIButton(strings.getKey('menubar/status/save'));
saveButton.onClick(() => {
editor.signals.saveRequested.dispatch(); //触发保存请求信号
});
container.add(saveButton);
```
这样,就会将原来的自动保存变成了一个“保存”按钮,当用户点击该按钮时,将会触发保存请求信号,然后你可以在其他地方监听该信号并执行保存操作。
阅读全文