test.html 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Layer.js Test</title>
  7. <style>
  8. body {
  9. font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  10. text-align: center;
  11. padding: 50px;
  12. background: #f0f2f5;
  13. }
  14. h1 { margin-bottom: 30px; }
  15. .btn-group {
  16. display: flex;
  17. flex-wrap: wrap;
  18. justify-content: center;
  19. gap: 15px;
  20. }
  21. button {
  22. padding: 10px 20px;
  23. font-size: 16px;
  24. cursor: pointer;
  25. border: none;
  26. border-radius: 5px;
  27. background: #fff;
  28. box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  29. transition: transform 0.1s;
  30. }
  31. button:active {
  32. transform: scale(0.98);
  33. }
  34. #result {
  35. margin-top: 30px;
  36. font-size: 18px;
  37. color: #555;
  38. height: 30px;
  39. }
  40. </style>
  41. </head>
  42. <body>
  43. <h1>Layer.js Test</h1>
  44. <div class="btn-group">
  45. <button onclick="testBasic()">Basic Message</button>
  46. <button onclick="testSuccess()">Success Icon</button>
  47. <button onclick="testError()">Error Icon</button>
  48. <button onclick="testWarning()">Warning Icon</button>
  49. <button onclick="testConfirm()">Confirm Dialog</button>
  50. <button onclick="testChaining()">Chain Promises</button>
  51. </div>
  52. <div id="result"></div>
  53. <script src="xjs.js"></script>
  54. <script>
  55. function log(msg) {
  56. document.getElementById('result').textContent = msg;
  57. console.log(msg);
  58. }
  59. function testBasic() {
  60. Layer.fire('Hello World');
  61. }
  62. function testSuccess() {
  63. Layer.fire('Good job!', 'You clicked the button!', 'success');
  64. }
  65. function testError() {
  66. Layer.fire({
  67. icon: 'error',
  68. title: 'Oops...',
  69. text: 'Something went wrong!',
  70. });
  71. }
  72. function testWarning() {
  73. Layer.fire({
  74. title: 'Are you sure?',
  75. text: "You won't be able to revert this!",
  76. icon: 'warning',
  77. showCancelButton: true,
  78. confirmButtonColor: '#3085d6',
  79. cancelButtonColor: '#d33',
  80. confirmButtonText: 'Yes, delete it!'
  81. }).then((result) => {
  82. if (result.isConfirmed) {
  83. Layer.fire(
  84. 'Deleted!',
  85. 'Your file has been deleted.',
  86. 'success'
  87. )
  88. }
  89. });
  90. }
  91. function testConfirm() {
  92. Layer.fire({
  93. title: 'Do you want to save the changes?',
  94. showCancelButton: true,
  95. confirmButtonText: 'Save',
  96. }).then((result) => {
  97. if (result.isConfirmed) {
  98. log('Saved!');
  99. } else if (result.isDismissed) {
  100. log('Changes are not saved');
  101. }
  102. });
  103. }
  104. function testChaining() {
  105. Layer.fire({
  106. title: 'Step 1',
  107. text: 'Proceed to step 2?',
  108. showCancelButton: true
  109. }).then((result) => {
  110. if (result.isConfirmed) {
  111. return Layer.fire({
  112. title: 'Step 2',
  113. text: 'Last step!',
  114. icon: 'success'
  115. });
  116. }
  117. }).then(() => {
  118. log('Process completed');
  119. });
  120. }
  121. </script>
  122. </body>
  123. </html>