文件操作 - url-helper.js
返回文件管理
返回主菜单
删除本文件
文件: /home/www/public/wp-content/plugins/ionos-journey/js/journey/helpers/url-helper.js
编辑文件内容
export default class UrlHelper { static getUrl() { return new URL( window.location ); } static getAllParams() { return Array.from( this.getUrl().searchParams.entries() ); } static getParam( name ) { return this.getUrl().searchParams.get( name ); } static addParam( key, value ) { const url = this.getUrl(); url.searchParams.append( key, value ); window.history.pushState( {}, '', url ); } static deleteParam( key ) { const url = this.getUrl(); url.searchParams.delete( key ); window.history.pushState( {}, '', url ); } static getPageName() { return window.location.pathname.split( '/' ).pop() || 'index.php'; } static convertToJson( urlParams ) { const params = {}; for ( const value in urlParams ) { params[ urlParams[ value ][ 0 ] ] = urlParams[ value ][ 1 ]; } return params; } static redirectToPage( page, urlParams ) { const params = urlParams instanceof Array ? this.convertToJson( urlParams ) : urlParams; if ( ! Object.prototype.hasOwnProperty.call( params, 'wp-tour' ) ) { params.wp_tour = 'started'; } const pageName = page.includes( '.php' ) ? page : page + '.php'; let url = this.getUrl().toString().includes( '?' ) ? new URL( this.getUrl().toString().split( '?' )[ 0 ] ) : this.getUrl(); if ( window.location.pathname.split( '/' ).pop().length > 1 ) { url = new URL( url.toString().replace( this.getPageName(), pageName ) ); } else { url = new URL( url.toString() + pageName ); } for ( const key in params ) { url.searchParams.append( key, params[ key ] ); } if ( UrlHelper.getParam( 'autoplay' ) !== null ) { url.searchParams.append( 'autoplay', 'enabled' ); } window.location = url.toString(); } } /* getUrlParam: function (url) { var vars = {}; url.replace(/[?&]+([^=&]+)=([^&]*)/gi, function (m, key, value) { vars[key] = value; }); return vars; }, changeQueryParameter: function (query, index, param) { let queryParams = new URLSearchParams(query); queryParams.delete(index); queryParams.set(index, param); return queryParams.toString(); } */
修改文件时间
将文件时间修改为当前时间的前一年
删除文件