Преглед изворни кода

更新赞助商和贡献者页面链接及样式

将赞助商和贡献者页面的链接修改为相对路径并添加新窗口打开属性,新增离开页面及其相关样式和脚本文件,调整了赞助商列表页面的样式。
SongZihuan пре 3 месеци
родитељ
комит
4c5e8b49e1
10 измењених фајлова са 115 додато и 14 уклоњено
  1. 36 0
      src/html/contributors.html
  2. 2 2
      src/html/index.html
  3. 26 0
      src/html/leave.html
  4. 0 11
      src/html/sponsors.html
  5. 14 0
      src/js/leave.js
  6. 6 1
      src/js/sponsors.js
  7. 2 0
      src/leave.js
  8. 12 0
      src/style/leave.css
  9. 9 0
      src/style/sponsors.css
  10. 8 0
      webpack_config_dev.js

+ 36 - 0
src/html/contributors.html

@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html lang="zh">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>赞助商列表</title>
+</head>
+<body>
+
+<header>
+    <h1>赞助商列表</h1>
+</header>
+
+<main>
+    <table id="sponsor-table">
+        <thead>
+        <tr>
+            <th>Logo</th>
+            <th>类型</th>
+            <th>名称</th>
+            <th>邮箱</th>
+            <th>联系电话</th>
+            <th>联系网站</th>
+            <th>赞助时间</th>
+            <th>赞助金额</th>
+            <th>累计赞助金额</th>
+            <th>备注</th>
+        </tr>
+        </thead>
+        <tbody>
+        </tbody>
+    </table>
+</main>
+<script src="../js/sponsors.js"></script>
+</body>
+</html>

+ 2 - 2
src/html/index.html

@@ -14,8 +14,8 @@
         进行。如果您愿意支持我的工作,非常欢迎您加入赞助行列。</p>
         进行。如果您愿意支持我的工作,非常欢迎您加入赞助行列。</p>
     <p>我的项目通常采用 <a href="https://mit-license.song-zh.com" target="_blank">MIT开源协议</a>,鼓励共享与创新。</p>
     <p>我的项目通常采用 <a href="https://mit-license.song-zh.com" target="_blank">MIT开源协议</a>,鼓励共享与创新。</p>
     <div class="buttons">
     <div class="buttons">
-        <a href="sponsors.html" class="button">赞助商页面</a>
-        <a href="contributors.html" class="button">贡献者页面</a>
+        <a href="./sponsors.html" class="button" target="_blank">赞助商页面</a>
+        <a href="./contributors.html" class="button" target="_blank">贡献者页面</a>
     </div>
     </div>
 </main>
 </main>
 <footer>
 <footer>

+ 26 - 0
src/html/leave.html

@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html lang="zh">
+<head>
+  <meta charset="UTF-8">
+  <title>即将前往...</title>
+  <script src="../js/leave.js"></script>
+</head>
+<body>
+<header>
+  <h1> 你即将离开本站 </h1>
+</header>
+<main>
+  <p>你即将离开本站,前往赞助商/贡献者提供的个人或商业网站。本网站不对此些网站做任何担保,请您小心谨慎,谨防上当受骗。</p>
+  <p>溃烂和操作相关网页时,请遵守当地法律法规和中国的法律法规,谢谢。</p>
+  <p id="destinationURL"></p>
+  <div class="buttons">
+    <button class="button" onclick="gotoURL()">确定</button>
+    <button class="button" onclick="closePage()">取消</button>
+  </div>
+</main>
+
+<script>
+  document.getElementById("destinationURL").innerText = "目标URL: " + (new URLSearchParams(window.location.search).get('toURL') || '未提供');
+</script>
+</body>
+</html>

+ 0 - 11
src/html/sponsors.html

@@ -4,17 +4,6 @@
     <meta charset="UTF-8">
     <meta charset="UTF-8">
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
     <title>赞助商列表</title>
     <title>赞助商列表</title>
-
-    <style>
-        /* Main content styles */
-        main {
-            width: 95%;
-            margin: 3rem auto;
-            padding: 2rem;
-            background-color: #fff;
-            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
-        }
-    </style>
 </head>
 </head>
 <body>
 <body>
 
 

+ 14 - 0
src/js/leave.js

@@ -0,0 +1,14 @@
+const urlParams = new URLSearchParams(window.location.search);
+const toURL = urlParams.get("toURL");
+
+if (!toURL) {
+    window.close()
+}
+
+function gotoURL() {
+    window.location.href = toURL;
+}
+
+function closePage() {
+    window.close();
+}

+ 6 - 1
src/js/sponsors.js

@@ -15,13 +15,18 @@ function populateTable(sponsors) {
     const tableBody = document.querySelector('#sponsor-table tbody');
     const tableBody = document.querySelector('#sponsor-table tbody');
     sponsors.data.forEach(sponsor => {
     sponsors.data.forEach(sponsor => {
         const row = document.createElement('tr');
         const row = document.createElement('tr');
+        let website = sponsor.website
+        if (website !== "" || website !== "#") {
+            website = "/leave.html?toURL=" + encodeURIComponent(sponsor.website)
+        }
+
         row.innerHTML = `
         row.innerHTML = `
                 <td><img class="logo" src="${sponsor.logo || window.defaultLogo}" alt="Logo"></td>
                 <td><img class="logo" src="${sponsor.logo || window.defaultLogo}" alt="Logo"></td>
                 <td>${sponsor.type || "匿名"}</td>
                 <td>${sponsor.type || "匿名"}</td>
                 <td>${sponsor.name || "匿名"}</td>
                 <td>${sponsor.name || "匿名"}</td>
                 <td>${sponsor.email || "-"}</td>
                 <td>${sponsor.email || "-"}</td>
                 <td>${sponsor.phone || "-"}</td>
                 <td>${sponsor.phone || "-"}</td>
-                <td><a href="${sponsor.website}" target="_blank">访问网站</a></td>
+                <td><a href="${website}" target="_blank">访问网站</a></td>
                 <td>${sponsor.sponsorDate}</td>
                 <td>${sponsor.sponsorDate}</td>
                 <td>¥${sponsor.amount}</td>
                 <td>¥${sponsor.amount}</td>
                 <td>¥${sponsor.totalAmount}</td>
                 <td>¥${sponsor.totalAmount}</td>

+ 2 - 0
src/leave.js

@@ -0,0 +1,2 @@
+import "./style/header.css"
+import "./style/leave.css"

+ 12 - 0
src/style/leave.css

@@ -0,0 +1,12 @@
+/* Main content styles */
+main {
+    max-width: 800px;
+    margin: 3rem auto;
+    padding: 2rem;
+    background-color: #fff;
+    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
+}
+
+p {
+    margin-bottom: 1rem;
+}

+ 9 - 0
src/style/sponsors.css

@@ -1,3 +1,12 @@
+/* Main content styles */
+main {
+    width: 95%;
+    margin: 3rem auto;
+    padding: 2rem;
+    background-color: #fff;
+    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
+}
+
 table {
 table {
     width: 100%;
     width: 100%;
     border-collapse: collapse;
     border-collapse: collapse;

+ 8 - 0
webpack_config_dev.js

@@ -24,6 +24,7 @@ const config = {
   entry: {
   entry: {
     common: path.resolve(__dirname, 'src/common.js'),
     common: path.resolve(__dirname, 'src/common.js'),
     index: path.resolve(__dirname, 'src/index.js'),
     index: path.resolve(__dirname, 'src/index.js'),
+    leave: path.resolve(__dirname, 'src/leave.js'),
     sponsors: path.resolve(__dirname, 'src/sponsors.js'),
     sponsors: path.resolve(__dirname, 'src/sponsors.js'),
   },
   },
 
 
@@ -118,6 +119,13 @@ const config = {
       chunks: ['common', 'index'],
       chunks: ['common', 'index'],
       publicPath: './'
       publicPath: './'
     }),
     }),
+    new HtmlWebpackPlugin({
+      inject: 'body',
+      template: path.resolve(__dirname, 'src/html/leave.html'), //指定模板文件
+      filename: 'leave.html',
+      chunks: ['common', 'leave'],
+      publicPath: './'
+    }),
     new HtmlWebpackPlugin({
     new HtmlWebpackPlugin({
       inject: 'body',
       inject: 'body',
       template: path.resolve(__dirname, 'src/html/sponsors.html'), //指定模板文件
       template: path.resolve(__dirname, 'src/html/sponsors.html'), //指定模板文件