* [misc] support for getting current step from request header x-zin-tutorial.

This commit is contained in:
sunhao
2024-09-04 17:31:41 +08:00
committed by 王于听
parent db0c2e71af
commit d1f6d50955
2 changed files with 13 additions and 1 deletions
+5
View File
@@ -417,6 +417,11 @@ function activeGuide(guideName)
}
}
window.getCurrentStepID = function()
{
return currentStep ? currentStep.id : '';
};
window.handleClickGuide = function(event)
{
const guideName = $(event.target).closest('.tutorial-guide').data('name');
+8 -1
View File
@@ -42,6 +42,7 @@
let historyState = parent.window.history.state;
const hasZinBar = DEBUG && window.zin && window.zin.zinTool && !isIndexPage;
const localCacheFirst = config.clientCache === 'local-first';
const isTutorial = top.config.currentModule === 'tutorial';
function getUrlID(url)
{
@@ -529,8 +530,14 @@
if(DEBUG && !selectors.includes('zinDebug()')) selectors.push('zinDebug()');
const isDebugRequest = DEBUG && selectors.length === 1 || selectors[0] === 'zinDebug()';
if(options.modal === undefined) options.modal = $(target[0] !== '#' && target[0] !== '.' ? `#${target}` : target).closest('.modal').length;
const headers = {'X-ZIN-Options': JSON.stringify($.extend({selector: selectors, type: 'list'}, options.zinOptions)), 'X-ZIN-App': currentCode, 'X-Zin-Cache-Time': 0};
const headers =
{
'X-ZIN-Options': JSON.stringify($.extend({selector: selectors, type: 'list'}, options.zinOptions)),
'X-ZIN-App': currentCode,
'X-Zin-Cache-Time': 0,
};
if(options.modal) headers['X-Zui-Modal'] = 'true';
if(isTutorial && top.getCurrentStepID) headers['X-ZIN-Tutorial'] = top.getCurrentStepID();
const requestMethod = (options.method || 'GET').toUpperCase();
if(!options.cache && options.cache !== false) options.cache = !!(requestMethod === 'GET' && config.clientCache && !options.partial);
if(options.cache === true) options.cache = url + (url.includes('?') ? '&zin=' : '?zin=') + encodeURIComponent(selectors.join(','));