From 0607f3013a5acbeff55da2fb633e2cb7809f6b29 Mon Sep 17 00:00:00 2001 From: sunhao Date: Wed, 29 Nov 2023 14:33:51 +0800 Subject: [PATCH] * zin: support to update user toolbar after save user avatar. --- lib/zin/wg/header/js/v1.js | 6 ------ lib/zin/wg/header/v1.php | 5 ----- module/index/js/index.ui.js | 15 ++++++++++++++- module/user/control.php | 2 +- www/js/zui3/zin.js | 13 +++++++------ 5 files changed, 22 insertions(+), 19 deletions(-) delete mode 100644 lib/zin/wg/header/js/v1.js diff --git a/lib/zin/wg/header/js/v1.js b/lib/zin/wg/header/js/v1.js deleted file mode 100644 index 1787b15e2b..0000000000 --- a/lib/zin/wg/header/js/v1.js +++ /dev/null @@ -1,6 +0,0 @@ -window.updateUserAvatar = function(dialog) -{ - const newSrc = $(dialog).find('.avatar-img').prop('src'); - const code = $('#toolbar').find('.avatar-img').dataset('code'); - $('.avatar-img[data-code="' + code + '"]').prop('src', newSrc); -}; diff --git a/lib/zin/wg/header/v1.php b/lib/zin/wg/header/v1.php index 0c6f27f263..4ae9b2b3be 100644 --- a/lib/zin/wg/header/v1.php +++ b/lib/zin/wg/header/v1.php @@ -18,11 +18,6 @@ class header extends wg 'toolbar' => array('map' => 'btn') ); - public static function getPageJS(): string|false - { - return file_get_contents(__DIR__ . DS . 'js' . DS . 'v1.js'); - } - protected function buildHeading() { if($this->hasBlock('heading')) return $this->block('heading'); diff --git a/module/index/js/index.ui.js b/module/index/js/index.ui.js index 64e84482ac..858e77d118 100644 --- a/module/index/js/index.ui.js +++ b/module/index/js/index.ui.js @@ -730,6 +730,18 @@ function changeAppsTheme(theme) }); } +function updateUserToolbar() +{ + $.each(apps.openedMap, function(_code, app) + { + if(app.iframe && app.iframe.contentWindow && app.iframe.contentWindow.loadPage) + { + app.iframe.contentWindow.loadPage({selector: '#toolbar', partial: true, target: '#toolbar'}); + } + }); +} + + initAppsMenu(); /* Refresh more menu on window resize */ $(window).on('resize', refreshMenu); @@ -808,7 +820,8 @@ $.apps = $.extend(apps, getAppCode: getAppCode, updateAppsMenu: updateAppsMenu, changeAppsLang: changeAppsLang, - changeAppsTheme: changeAppsTheme + changeAppsTheme: changeAppsTheme, + updateUserToolbar: updateUserToolbar }); window.notifyMessage = function(data) diff --git a/module/user/control.php b/module/user/control.php index 9d86b49cd7..60663af960 100755 --- a/module/user/control.php +++ b/module/user/control.php @@ -996,7 +996,7 @@ class user extends control $this->app->user->avatar = $image->webPath; $this->session->set('user', $this->app->user); $this->dao->update(TABLE_USER)->set('avatar')->eq($image->webPath)->where('account')->eq($this->app->user->account)->exec(); - return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'callback' => "loadModal('" . $this->createLink('my', 'profile') . "', 'profile', {}, window.updateUserAvatar);")); + return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'callback' => "loadModal('" . $this->createLink('my', 'profile') . "', 'profile', {}, $.apps.updateUserToolbar);")); } $this->view->title = $this->lang->user->cropAvatar; diff --git a/www/js/zui3/zin.js b/www/js/zui3/zin.js index 2a685a4667..4fc8f756ac 100644 --- a/www/js/zui3/zin.js +++ b/www/js/zui3/zin.js @@ -54,12 +54,13 @@ if(DEBUG) console.log('[APP]', 'update:', {code, url, title}); return state; }, - isOldPage: () => false, - reloadApp: function(_code, url){loadPage(url);}, - openApp: function(url, options){loadPage(url, options);}, - goBack: function(){history.go(-1);}, - changeAppsLang: changeAppLang, - changeAppsTheme: changeAppTheme + isOldPage: () => false, + reloadApp: function(_code, url){loadPage(url);}, + openApp: function(url, options){loadPage(url, options);}, + goBack: function(){history.go(-1);}, + changeAppsLang: changeAppLang, + changeAppsTheme: changeAppTheme, + updateUserToolbar: function(){loadPage({selector: '#toolbar', partial: true, target: '#toolbar'})}, }, parent.window.$.apps); const renderMap =