Explorar o código

Merge pull request #296 from Xiayucheng1212/keep_params

Keep the query params in the url started with '/app/*'
Nariman Jelveh hai 1 ano
pai
achega
915152d3b9
Modificáronse 2 ficheiros con 11 adicións e 1 borrados
  1. 10 1
      src/UI/UIWindow.js
  2. 1 0
      src/helpers.js

+ 10 - 1
src/UI/UIWindow.js

@@ -172,6 +172,14 @@ async function UIWindow(options) {
 
     // Window
     let zindex = options.stay_on_top ? (99999999 + last_window_zindex + 1 + ' !important') : last_window_zindex;
+    let user_set_url_params = [];
+    if (options.params !== undefined) {
+        for (let key in options.params) {
+            user_set_url_params.push(key + "=" + options.params[key]);
+        }
+        user_set_url_params = '?'+ user_set_url_params.join('&');
+
+    }
     h += `<div class="window window-active 
                         ${options.cover_page ? 'window-cover-page' : ''}
                         ${options.uid !== undefined ? 'window-'+options.uid : ''} 
@@ -206,6 +214,7 @@ async function UIWindow(options) {
                 data-sort_order ="${options.sort_order ?? 'asc'}"
                 data-multiselectable = "${options.selectable_body}"
                 data-update_window_url = "${options.update_window_url}"
+                data-user_set_url_params = "${html_encode(user_set_url_params)}"
                 data-initial_zindex = "${zindex}"
                 style=" z-index: ${zindex}; 
                         ${options.width !== undefined ? 'width: ' + html_encode(options.width) +'; ':''}
@@ -3133,7 +3142,7 @@ $.fn.focusWindow = function(event) {
         //change window URL
         const update_window_url = $(this).attr('data-update_window_url');
         if(update_window_url === 'true' || update_window_url === null){
-            window.history.replaceState({window_id: $(this).attr('data-id')}, '', '/app/'+$(this).attr('data-app'));
+            window.history.replaceState({window_id: $(this).attr('data-id')}, '', '/app/'+$(this).attr('data-app')+$(this).attr('data-user_set_url_params'));
             document.title = $(this).attr('data-name');
         }
         $(`.taskbar .taskbar-item[data-app="${$(this).attr('data-app')}"]`).addClass('taskbar-item-active');

+ 1 - 0
src/helpers.js

@@ -1843,6 +1843,7 @@ window.launch_app = async (options)=>{
             element_uuid: uuid,
             title: title,
             iframe_url: iframe_url.href,
+            params: options.params ?? undefined,
             icon: icon,
             window_class: 'window-app',
             update_window_url: true,