图片列表窗口代码优化。

This commit is contained in:
liteng 2018-10-09 20:37:28 +08:00
parent f3ffe24577
commit 398712062c
6 changed files with 29 additions and 58 deletions

View File

@ -18,19 +18,13 @@ function AudioWindow(options) {
this.preImageUrl = this.app.options.server;
this.showUploadButton = true;
this.beforeUpdateList = this.beforeUpdateAudioList;
this.onUpload = this.onUploadAudio;
this.onClick = this.onClickAudio;
this.onEdit = this.onEditAudio;
this.onDelete = this.onDeleteAudio;
this.onSelect = options.onSelect || null;
}
AudioWindow.prototype = Object.create(UI.ImageListWindow.prototype);
AudioWindow.prototype.constructor = AudioWindow;
AudioWindow.prototype.beforeUpdateAudioList = function () {
AudioWindow.prototype.beforeUpdateList = function () {
var server = this.app.options.server;
return new Promise(resolve => {
@ -40,12 +34,12 @@ AudioWindow.prototype.beforeUpdateAudioList = function () {
});
};
AudioWindow.prototype.onUploadAudio = function (obj) {
AudioWindow.prototype.onUpload = function (obj) {
this.update();
UI.msg(obj.Msg);
};
AudioWindow.prototype.onClickAudio = function (data) {
AudioWindow.prototype.onClick = function (data) {
if (typeof (this.onSelect) === 'function') {
this.onSelect(data);
} else {
@ -53,7 +47,7 @@ AudioWindow.prototype.onClickAudio = function (data) {
}
};
AudioWindow.prototype.onEditAudio = function (data) {
AudioWindow.prototype.onEdit = function (data) {
if (this.editWindow === undefined) {
this.editWindow = new AudioEditWindow({
app: this.app,
@ -66,7 +60,7 @@ AudioWindow.prototype.onEditAudio = function (data) {
this.editWindow.show();
};
AudioWindow.prototype.onDeleteAudio = function (data) {
AudioWindow.prototype.onDelete = function (data) {
var server = this.app.options.server;
UI.confirm('询问', `是否删除音频${data.Name}`, (event, btn) => {

View File

@ -20,19 +20,13 @@ function MMDWindow(options) {
this.preImageUrl = this.app.options.server;
this.showUploadButton = true;
this.beforeUpdateList = this.beforeUpdateMMDList;
this.onUpload = this.onUploadMMD;
this.onClick = this.onClickMMD;
this.onEdit = this.onEditMMD;
this.onDelete = this.onDeleteMMD;
this.onSelect = options.onSelect || null;
}
MMDWindow.prototype = Object.create(UI.ImageListWindow.prototype);
MMDWindow.prototype.constructor = MMDWindow;
MMDWindow.prototype.beforeUpdateMMDList = function () {
MMDWindow.prototype.beforeUpdateList = function () {
var server = this.app.options.server;
return new Promise(resolve => {
@ -42,12 +36,12 @@ MMDWindow.prototype.beforeUpdateMMDList = function () {
});
};
MMDWindow.prototype.onUploadMMD = function (obj) {
MMDWindow.prototype.onUpload = function (obj) {
this.update();
UI.msg(obj.Msg);
};
MMDWindow.prototype.onClickMMD = function (model) {
MMDWindow.prototype.onClick = function (model) {
if (model.Type === 'vmd') {
if (this.onSelect) {
this.onSelect(model);
@ -91,7 +85,7 @@ MMDWindow.prototype.onClickMMD = function (model) {
});
};
MMDWindow.prototype.onEditMMD = function (data) {
MMDWindow.prototype.onEdit = function (data) {
if (this.editWindow === undefined) {
this.editWindow = new MMDEditWindow({
app: this.app,
@ -104,7 +98,7 @@ MMDWindow.prototype.onEditMMD = function (data) {
this.editWindow.show();
};
MMDWindow.prototype.onDeleteMMD = function (data) {
MMDWindow.prototype.onDelete = function (data) {
var server = this.app.options.server;
UI.confirm('询问', `是否删除MMD资源${data.Name}`, (event, btn) => {

View File

@ -19,18 +19,12 @@ function ModelWindow(options) {
this.uploadUrl = `${this.app.options.server}/api/Mesh/Add`;
this.preImageUrl = this.app.options.server;
this.showUploadButton = true;
this.beforeUpdateList = this.beforeUpdateModelList;
this.onUpload = this.onUploadModel;
this.onClick = this.onClickModel;
this.onEdit = this.onEditModel;
this.onDelete = this.onDeleteModel;
}
ModelWindow.prototype = Object.create(UI.ImageListWindow.prototype);
ModelWindow.prototype.constructor = ModelWindow;
ModelWindow.prototype.beforeUpdateModelList = function () {
ModelWindow.prototype.beforeUpdateList = function () {
var server = this.app.options.server;
return new Promise(resolve => {
@ -40,12 +34,12 @@ ModelWindow.prototype.beforeUpdateModelList = function () {
});
};
ModelWindow.prototype.onUploadModel = function (obj) {
ModelWindow.prototype.onUpload = function (obj) {
this.update();
UI.msg(obj.Msg);
};
ModelWindow.prototype.onClickModel = function (model) {
ModelWindow.prototype.onClick = function (model) {
var loader = new ModelLoader(this.app);
var url = model.Url;
@ -78,7 +72,7 @@ ModelWindow.prototype.onClickModel = function (model) {
});
};
ModelWindow.prototype.onEditModel = function (data) {
ModelWindow.prototype.onEdit = function (data) {
if (this.editWindow === undefined) {
this.editWindow = new ModelEditWindow({
app: this.app,
@ -91,7 +85,7 @@ ModelWindow.prototype.onEditModel = function (data) {
this.editWindow.show();
};
ModelWindow.prototype.onDeleteModel = function (data) {
ModelWindow.prototype.onDelete = function (data) {
var server = this.app.options.server;
UI.confirm('询问', `是否删除模型${data.Name}`, (event, btn) => {

View File

@ -19,17 +19,12 @@ function SceneWindow(options) {
this.title = '场景列表';
this.imageIcon = 'icon-scenes';
this.preImageUrl = this.app.options.server;
this.beforeUpdateList = this.beforeUpdateSceneList;
this.onClick = this.onClickScene;
this.onEdit = this.onEditScene;
this.onDelete = this.onDeleteScene;
}
SceneWindow.prototype = Object.create(UI.ImageListWindow.prototype);
SceneWindow.prototype.constructor = SceneWindow;
SceneWindow.prototype.beforeUpdateSceneList = function () {
SceneWindow.prototype.beforeUpdateList = function () {
var server = this.app.options.server;
return new Promise(resolve => {
@ -39,7 +34,7 @@ SceneWindow.prototype.beforeUpdateSceneList = function () {
});
};
SceneWindow.prototype.onClickScene = function (data) {
SceneWindow.prototype.onClick = function (data) {
var app = this.app;
var editor = app.editor;
var server = app.options.server;
@ -177,7 +172,7 @@ SceneWindow.prototype.onLoadScene = function (obj) {
this.app.editor.camera.updateProjectionMatrix();
};
SceneWindow.prototype.onEditScene = function (data) {
SceneWindow.prototype.onEdit = function (data) {
if (this.editWindow === undefined) {
this.editWindow = new SceneEditWindow({
app: this.app,
@ -190,7 +185,7 @@ SceneWindow.prototype.onEditScene = function (data) {
this.editWindow.show();
};
SceneWindow.prototype.onDeleteScene = function (data) {
SceneWindow.prototype.onDelete = function (data) {
var server = this.app.options.server;
UI.confirm('询问', `是否删除场景${data.Name}`, (event, btn) => {

View File

@ -19,19 +19,13 @@ function TextureWindow(options) {
this.preImageUrl = this.app.options.server;
this.showUploadButton = true;
this.beforeUpdateList = this.beforeUpdateTextureList;
this.onUpload = this.onUploadTexture;
this.onClick = this.onClickTexture;
this.onEdit = this.onEditTexture;
this.onDelete = this.onDeleteTexture;
this.onSelect = options.onSelect || null;
}
TextureWindow.prototype = Object.create(UI.ImageListWindow.prototype);
TextureWindow.prototype.constructor = TextureWindow;
TextureWindow.prototype.beforeUpdateTextureList = function () {
TextureWindow.prototype.beforeUpdateList = function () {
var server = this.app.options.server;
return new Promise(resolve => {
@ -41,12 +35,12 @@ TextureWindow.prototype.beforeUpdateTextureList = function () {
});
};
TextureWindow.prototype.onUploadTexture = function (obj) {
TextureWindow.prototype.onUpload = function (obj) {
this.update();
UI.msg(obj.Msg);
};
TextureWindow.prototype.onClickTexture = function (data) {
TextureWindow.prototype.onClick = function (data) {
if (typeof (this.onSelect) === 'function') {
this.onSelect(data);
} else {
@ -54,7 +48,7 @@ TextureWindow.prototype.onClickTexture = function (data) {
}
};
TextureWindow.prototype.onEditTexture = function (data) {
TextureWindow.prototype.onEdit = function (data) {
if (this.editWindow === undefined) {
this.editWindow = new TextureEditWindow({
app: this.app,
@ -67,7 +61,7 @@ TextureWindow.prototype.onEditTexture = function (data) {
this.editWindow.show();
};
TextureWindow.prototype.onDeleteTexture = function (data) {
TextureWindow.prototype.onDelete = function (data) {
var server = this.app.options.server;
UI.confirm('询问', `是否删除纹理${data.Name}`, (event, btn) => {

View File

@ -20,11 +20,11 @@ function ImageListWindow(options) {
this.preImageUrl = options.preImageUrl || '/'; // 缩略图url前缀一般是服务端url
this.showUploadButton = options.showUploadButton || false; // 是否显示上传按钮
this.beforeUpdateList = options.beforeUpdateList || null; // 图片列表刷新前调用返回Promiseresolve(data)。
this.onUpload = options.onUpload || null; // 上传成功回调
this.onClick = options.onClick || null; // 点击图片列表
this.onEdit = options.onEdit || null; // 编辑图片列表
this.onDelete = options.onDelete || null; // 删除图片列表
this.beforeUpdateList = options.beforeUpdateList || this.beforeUpdateList; // 图片列表刷新前调用返回Promiseresolve(data)。
this.onUpload = options.onUpload || this.onUpload; // 上传成功回调
this.onClick = options.onClick || this.onClick; // 点击图片列表
this.onEdit = options.onEdit || this.onEdit; // 编辑图片列表
this.onDelete = options.onDelete || this.onDelete; // 删除图片列表
this.data = [];
this.keyword = '';