needFilePasswordHeader.ftl 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <#setting classic_compatible=true>
  2. <link rel="icon" href="./favicon.ico" type="image/x-icon">
  3. <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css"/>
  4. <script src="js/jquery-3.6.1.min.js" type="text/javascript"></script>
  5. <script src="bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
  6. <script src="js/bootbox.min.js" type="text/javascript"></script>
  7. <script>
  8. // 中文环境
  9. var locale_zh_CN = {
  10. OK: '确定',
  11. CONFIRM: '确认',
  12. CANCEL: '取消'
  13. };
  14. bootbox.addLocale('locale_zh_CN', locale_zh_CN);
  15. /**
  16. * 需要文件密码
  17. */
  18. function needFilePassword() {
  19. if ('${needFilePassword}' == 'true') {
  20. let promptTitle = "你正在预览加密文件,请输入文件密码。";
  21. if ('${filePasswordError}' == 'true') {
  22. promptTitle = "密码错误,请重新输入密码。";
  23. }
  24. bootbox.prompt({
  25. title: promptTitle,
  26. inputType: 'password',
  27. centerVertical: true,
  28. locale: 'locale_zh_CN',
  29. callback: function (filePassword) {
  30. if (filePassword != null) {
  31. const locationHref = window.location.href;
  32. const isInclude = locationHref.includes("filePassword=");
  33. let redirectUrl = null;
  34. if (isInclude) {
  35. const url = new URL(locationHref);
  36. url.searchParams.set("filePassword", filePassword);
  37. redirectUrl = url.href;
  38. } else {
  39. redirectUrl = locationHref + '&filePassword=' + filePassword;
  40. }
  41. window.location.replace(redirectUrl);
  42. } else {
  43. location.reload();
  44. }
  45. }
  46. });
  47. }
  48. }
  49. </script>
  50. <style>
  51. * {
  52. margin: 0;
  53. padding: 0;
  54. }
  55. html, body {
  56. height: 100%;
  57. width: 100%;
  58. }
  59. </style>