From b495ebcb348ac1b75501a0664c59d83e3fff0ec3 Mon Sep 17 00:00:00 2001 From: sunhao Date: Tue, 21 Nov 2023 14:27:54 +0800 Subject: [PATCH] * zin: fix zin header not work in compatible mode. --- lib/zin/wg/header/v1.php | 72 ++++++++++++++++++----------------- module/index/js/index.js | 24 +++++++++++- www/js/zui3/zin.compatible.js | 14 ++++++- 3 files changed, 74 insertions(+), 36 deletions(-) diff --git a/lib/zin/wg/header/v1.php b/lib/zin/wg/header/v1.php index 6a39baec9d..e8c7049ac3 100644 --- a/lib/zin/wg/header/v1.php +++ b/lib/zin/wg/header/v1.php @@ -148,29 +148,30 @@ class header extends wg $noRole = empty($user->role) || !isset($lang->user->roleList[$user->role]); $items[] = array ( - 'url' => createLink('my', 'profile', '', '', true), + 'url' => createLink('my', 'profile', '', '', true), 'leadingClass' => 'row items-center gap-2 px-2 py-1 text-inherit', - 'icon' => ' hidden', - 'title' => empty($user->realname) ? $user->account : $user->realname, - 'titleClass' => 'text-lg', - 'subtitle' => $noRole ? null : $lang->user->roleList[$user->role], - // 'style' => array('padding-left' => 0), - 'data-toggle' => 'modal', - 'data-size' => 700, - 'data-id' => 'profile', - 'leading' => array('html' => userAvatar(set::user($user))->render(), 'className' => 'center mr-1') + 'icon' => ' hidden', + 'title' => empty($user->realname) ? $user->account : $user->realname, + 'titleClass' => 'text-lg', + 'subtitle' => $noRole ? null : $lang->user->roleList[$user->role], + 'innerClass' => 'open-in-parent', + 'data-toggle' => 'modal', + 'data-size' => 700, + 'data-id' => 'profile', + 'leading' => array('html' => userAvatar(set::user($user))->render(), 'className' => 'center mr-1') ); $items[] = array('type' => 'divider'); $items[] = array ( - 'url' => createLink('my', 'profile', '', '', true), - 'icon' => 'account', - 'text' => $lang->profile, + 'url' => createLink('my', 'profile', '', '', true), + 'icon' => 'account', + 'text' => $lang->profile, + 'innerClass' => 'open-in-parent', 'data-toggle' => 'modal', - 'data-size' => 700, - 'data-id' => 'profile' + 'data-size' => 700, + 'data-id' => 'profile' ); if($app->config->vision === 'rnd') @@ -179,26 +180,28 @@ class header extends wg { $items[] = array ( - 'url' => createLink('tutorial', 'start'), - 'icon' => 'guide', - 'text' => $lang->tutorialAB, - 'class' => '800', - 'outerClass' => 'user-tutorial', - 'data-width' => 700, + 'url' => createLink('tutorial', 'start'), + 'icon' => 'guide', + 'text' => $lang->tutorialAB, + 'class' => '800', + 'outerClass' => 'user-tutorial', + 'data-width' => 700, 'data-class-name' => 'modal-inverse', 'data-headerless' => true, - 'data-backdrop' => true, - 'data-keyboard' => true, - 'data-toggle' => 'modal' + 'data-backdrop' => true, + 'data-keyboard' => true, + 'innerClass' => 'open-in-parent', + 'data-toggle' => 'modal' ); } $items[] = array ( - 'url' => createLink('my', 'preference', 'showTip=false', '', true), - 'icon' => 'controls', - 'text' => $lang->preference, - 'data-width' => 700, + 'url' => createLink('my', 'preference', 'showTip=false', '', true), + 'icon' => 'controls', + 'text' => $lang->preference, + 'data-width' => 700, + 'innerClass' => 'open-in-parent', 'data-toggle' => 'modal' ); } @@ -207,11 +210,12 @@ class header extends wg { $items[] = array ( - 'url' => createLink('my', 'changepassword', '', '', true), - 'icon' => 'cog-outline', - 'text' => $lang->changePassword, + 'url' => createLink('my', 'changepassword', '', '', true), + 'icon' => 'cog-outline', + 'text' => $lang->changePassword, + 'innerClass' => 'open-in-parent', 'data-toggle' => 'modal', - 'data-size' => 'sm' + 'data-size' => 'sm' ); } @@ -241,12 +245,12 @@ class header extends wg $helpItems = array(); $manualUrl = ((!empty($config->isINT)) ? $config->manualUrl['int'] : $config->manualUrl['home']) . '&theme=' . $_COOKIE['theme']; $helpItems[] = array('text' => $lang->manual, 'url' => $manualUrl, 'attrs' => array('data-app' => 'help')); - $helpItems[] = array('text' => $lang->changeLog, 'url' => createLink('misc', 'changeLog'), 'data-toggle' => 'modal'); + $helpItems[] = array('text' => $lang->changeLog, 'url' => createLink('misc', 'changeLog'), 'data-toggle' => 'modal', 'innerClass' => 'open-in-parent'); $items[] = array('text' => $lang->help, 'icon' => 'help', 'items' => $helpItems); /* printClientLink */ - $items[] = array('text' => $lang->aboutZenTao, 'icon' => 'about', 'url' => createLink('misc', 'about'), 'data-toggle' => 'modal'); + $items[] = array('text' => $lang->aboutZenTao, 'icon' => 'about', 'url' => createLink('misc', 'about'), 'data-toggle' => 'modal', 'innerClass' => 'open-in-parent'); $items[] = array('type' => 'html', 'className' => 'menu-item', 'html' => $lang->designedByAIUX); $items[] = array('type' => 'divider'); diff --git a/module/index/js/index.js b/module/index/js/index.js index ed87a017b5..40fe2baef3 100644 --- a/module/index/js/index.js +++ b/module/index/js/index.js @@ -528,6 +528,27 @@ document.title = title; } + /** + * Logout current user. + * + * @param {string} url + */ + function logout(url) + { + if(!url) url = getLastApp().appUrl; + $.get($.createLink('user', 'logout', 'referer=' + btoa(url)), function(data) + { + let load = $.createLink('user', 'login'); + try + { + data = JSON.parse(data); + if(data.load) load = data.load; + } + catch (error) {} + location.href = load; + }); + } + /* Bind helper methods to global object "$.apps" */ $.apps = window.apps = { @@ -541,7 +562,8 @@ getAppCode: getAppCodeFromUrl, getLastApp: getLastApp, openedApps: openedApps, - appsMap: appsMap + appsMap: appsMap, + logout: logout }; /** diff --git a/www/js/zui3/zin.compatible.js b/www/js/zui3/zin.compatible.js index fa58421e5a..24a751a5d9 100644 --- a/www/js/zui3/zin.compatible.js +++ b/www/js/zui3/zin.compatible.js @@ -1177,12 +1177,24 @@ parent.selectTheme(theme); } + /** + * Select vision. + * @param {string} vision + */ + function selectVision(vision) + { + $.get($.createLink('my', 'ajaxSwitchVision', 'vision=' + vision), function() + { + window.top.location.href = $.createLink('index', 'index'); + }); + } + function updatePageLayout() { layoutNanavbar(); } - $.extend(window, {registerRender: registerRender, fetchContent: fetchContent, loadTable: loadTable, loadPage: loadPage, postAndLoadPage: postAndLoadPage, loadCurrentPage: loadCurrentPage, parseSelector: parseSelector, toggleLoading: toggleLoading, openUrl: openUrl, openPage: openPage, goBack: goBack, registerTimer: registerTimer, loadModal: loadModal, loadTarget: loadTarget, loadComponent: loadComponent, loadPartial: loadPartial, reloadPage: reloadPage, selectLang: selectLang, selectTheme: selectTheme, changeAppLang, changeAppTheme: changeAppTheme, uploadFileByChunk: uploadFileByChunk}); + $.extend(window, {registerRender: registerRender, fetchContent: fetchContent, loadTable: loadTable, loadPage: loadPage, postAndLoadPage: postAndLoadPage, loadCurrentPage: loadCurrentPage, parseSelector: parseSelector, toggleLoading: toggleLoading, openUrl: openUrl, openPage: openPage, goBack: goBack, registerTimer: registerTimer, loadModal: loadModal, loadTarget: loadTarget, loadComponent: loadComponent, loadPartial: loadPartial, reloadPage: reloadPage, selectLang: selectLang, selectTheme: selectTheme, selectVision: selectVision, changeAppLang, changeAppTheme: changeAppTheme, uploadFileByChunk: uploadFileByChunk}); $.extend($.apps, {openUrl: openUrl}); $.extend($, {ajaxSendScore: ajaxSendScore, selectLang: selectLang});