Explorar o código

【初始】创建应用启动器页面

- 新增应用启动器的 HTML 结构和样式
- 添加应用数据加载和渲染逻辑
- 实现应用搜索和分组功能
- 集成拼音转换工具以支持中文搜索
PJ568 hai 1 ano
achega
d32bca61ce
Modificáronse 8 ficheiros con 945 adicións e 0 borrados
  1. 1 0
      .gitignore
  2. 195 0
      LICENSE.md
  3. 5 0
      README.md
  4. 16 0
      assets/icon.svg
  5. 338 0
      index.html
  6. 372 0
      lib/pinyinjs/pinyinUtil.js
  7. 0 0
      lib/pinyinjs/pinyin_dict_withtone.js
  8. 18 0
      metadata.json

+ 1 - 0
.gitignore

@@ -0,0 +1 @@
+/参考/

+ 195 - 0
LICENSE.md

@@ -0,0 +1,195 @@
+# Mozilla Public License  
+
+Version 2.0
+
+## 1\. Definitions
+
+1.1. “Contributor”
+
+means each individual or legal entity that creates, contributes to the creation of, or owns Covered Software.
+
+1.2. “Contributor Version”
+
+means the combination of the Contributions of others (if any) used by a Contributor and that particular Contributor’s Contribution.
+
+1.3. “Contribution”
+
+means Covered Software of a particular Contributor.
+
+1.4. “Covered Software”
+
+means Source Code Form to which the initial Contributor has attached the notice in Exhibit A, the Executable Form of such Source Code Form, and Modifications of such Source Code Form, in each case including portions thereof.
+
+1.5. “Incompatible With Secondary Licenses”
+
+means
+
+1. that the initial Contributor has attached the notice described in Exhibit B to the Covered Software; or
+
+2. that the Covered Software was made available under the terms of version 1.1 or earlier of the License, but not also under the terms of a Secondary License.
+
+1.6. “Executable Form”
+
+means any form of the work other than Source Code Form.
+
+1.7. “Larger Work”
+
+means a work that combines Covered Software with other material, in a separate file or files, that is not Covered Software.
+
+1.8. “License”
+
+means this document.
+
+1.9. “Licensable”
+
+means having the right to grant, to the maximum extent possible, whether at the time of the initial grant or subsequently, any and all of the rights conveyed by this License.
+
+1.10. “Modifications”
+
+means any of the following:
+
+1. any file in Source Code Form that results from an addition to, deletion from, or modification of the contents of Covered Software; or
+
+2. any new file in Source Code Form that contains any Covered Software.
+
+1.11. “Patent Claims” of a Contributor
+
+means any patent claim(s), including without limitation, method, process, and apparatus claims, in any patent Licensable by such Contributor that would be infringed, but for the grant of the License, by the making, using, selling, offering for sale, having made, import, or transfer of either its Contributions or its Contributor Version.
+
+1.12. “Secondary License”
+
+means either the GNU General Public License, Version 2.0, the GNU Lesser General Public License, Version 2.1, the GNU Affero General Public License, Version 3.0, or any later versions of those licenses.
+
+1.13. “Source Code Form”
+
+means the form of the work preferred for making modifications.
+
+1.14. “You” (or “Your”)
+
+means an individual or a legal entity exercising rights under this License. For legal entities, “You” includes any entity that controls, is controlled by, or is under common control with You. For purposes of this definition, “control” means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity.
+
+## 2\. License Grants and Conditions
+
+### 2.1. Grants
+
+Each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license:
+
+1. under intellectual property rights (other than patent or trademark) Licensable by such Contributor to use, reproduce, make available, modify, display, perform, distribute, and otherwise exploit its Contributions, either on an unmodified basis, with Modifications, or as part of a Larger Work; and
+
+2. under Patent Claims of such Contributor to make, use, sell, offer for sale, have made, import, and otherwise transfer either its Contributions or its Contributor Version.
+
+### 2.2. Effective Date
+
+The licenses granted in Section 2.1 with respect to any Contribution become effective for each Contribution on the date the Contributor first distributes such Contribution.
+
+### 2.3. Limitations on Grant Scope
+
+The licenses granted in this Section 2 are the only rights granted under this License. No additional rights or licenses will be implied from the distribution or licensing of Covered Software under this License. Notwithstanding Section 2.1(b) above, no patent license is granted by a Contributor:
+
+1. for any code that a Contributor has removed from Covered Software; or
+
+2. for infringements caused by: (i) Your and any other third party’s modifications of Covered Software, or (ii) the combination of its Contributions with other software (except as part of its Contributor Version); or
+
+3. under Patent Claims infringed by Covered Software in the absence of its Contributions.
+
+This License does not grant any rights in the trademarks, service marks, or logos of any Contributor (except as may be necessary to comply with the notice requirements in Section 3.4).
+
+### 2.4. Subsequent Licenses
+
+No Contributor makes additional grants as a result of Your choice to distribute the Covered Software under a subsequent version of this License (see Section 10.2) or under the terms of a Secondary License (if permitted under the terms of Section 3.3).
+
+### 2.5. Representation
+
+Each Contributor represents that the Contributor believes its Contributions are its original creation(s) or it has sufficient rights to grant the rights to its Contributions conveyed by this License.
+
+### 2.6. Fair Use
+
+This License is not intended to limit any rights You have under applicable copyright doctrines of fair use, fair dealing, or other equivalents.
+
+### 2.7. Conditions
+
+Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in Section 2.1.
+
+## 3\. Responsibilities
+
+### 3.1. Distribution of Source Form
+
+All distribution of Covered Software in Source Code Form, including any Modifications that You create or to which You contribute, must be under the terms of this License. You must inform recipients that the Source Code Form of the Covered Software is governed by the terms of this License, and how they can obtain a copy of this License. You may not attempt to alter or restrict the recipients’ rights in the Source Code Form.
+
+### 3.2. Distribution of Executable Form
+
+If You distribute Covered Software in Executable Form then:
+
+1. such Covered Software must also be made available in Source Code Form, as described in Section 3.1, and You must inform recipients of the Executable Form how they can obtain a copy of such Source Code Form by reasonable means in a timely manner, at a charge no more than the cost of distribution to the recipient; and
+
+2. You may distribute such Executable Form under the terms of this License, or sublicense it under different terms, provided that the license for the Executable Form does not attempt to limit or alter the recipients’ rights in the Source Code Form under this License.
+
+### 3.3. Distribution of a Larger Work
+
+You may create and distribute a Larger Work under terms of Your choice, provided that You also comply with the requirements of this License for the Covered Software. If the Larger Work is a combination of Covered Software with a work governed by one or more Secondary Licenses, and the Covered Software is not Incompatible With Secondary Licenses, this License permits You to additionally distribute such Covered Software under the terms of such Secondary License(s), so that the recipient of the Larger Work may, at their option, further distribute the Covered Software under the terms of either this License or such Secondary License(s).
+
+### 3.4. Notices
+
+You may not remove or alter the substance of any license notices (including copyright notices, patent notices, disclaimers of warranty, or limitations of liability) contained within the Source Code Form of the Covered Software, except that You may alter any license notices to the extent required to remedy known factual inaccuracies.
+
+### 3.5. Application of Additional Terms
+
+You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Software. However, You may do so only on Your own behalf, and not on behalf of any Contributor. You must make it absolutely clear that any such warranty, support, indemnity, or liability obligation is offered by You alone, and You hereby agree to indemnify every Contributor for any liability incurred by such Contributor as a result of warranty, support, indemnity or liability terms You offer. You may include additional disclaimers of warranty and limitations of liability specific to any jurisdiction.
+
+## 4\. Inability to Comply Due to Statute or Regulation
+
+If it is impossible for You to comply with any of the terms of this License with respect to some or all of the Covered Software due to statute, judicial order, or regulation then You must: (a) comply with the terms of this License to the maximum extent possible; and (b) describe the limitations and the code they affect. Such description must be placed in a text file included with all distributions of the Covered Software under this License. Except to the extent prohibited by statute or regulation, such description must be sufficiently detailed for a recipient of ordinary skill to be able to understand it.
+
+## 5\. Termination
+
+5.1. The rights granted under this License will terminate automatically if You fail to comply with any of its terms. However, if You become compliant, then the rights granted under this License from a particular Contributor are reinstated (a) provisionally, unless and until such Contributor explicitly and finally terminates Your grants, and (b) on an ongoing basis, if such Contributor fails to notify You of the non-compliance by some reasonable means prior to 60 days after You have come back into compliance. Moreover, Your grants from a particular Contributor are reinstated on an ongoing basis if such Contributor notifies You of the non-compliance by some reasonable means, this is the first time You have received notice of non-compliance with this License from such Contributor, and You become compliant prior to 30 days after Your receipt of the notice.
+
+5.2. If You initiate litigation against any entity by asserting a patent infringement claim (excluding declaratory judgment actions, counter-claims, and cross-claims) alleging that a Contributor Version directly or indirectly infringes any patent, then the rights granted to You by any and all Contributors for the Covered Software under Section 2.1 of this License shall terminate.
+
+5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user license agreements (excluding distributors and resellers) which have been validly granted by You or Your distributors under this License prior to termination shall survive termination.
+
+## 6\. Disclaimer of Warranty
+
+_Covered Software is provided under this License on an “as is” basis, without warranty of any kind, either expressed, implied, or statutory, including, without limitation, warranties that the Covered Software is free of defects, merchantable, fit for a particular purpose or non-infringing. The entire risk as to the quality and performance of the Covered Software is with You. Should any Covered Software prove defective in any respect, You (not any Contributor) assume the cost of any necessary servicing, repair, or correction. This disclaimer of warranty constitutes an essential part of this License. No use of any Covered Software is authorized under this License except under this disclaimer._
+
+## 7\. Limitation of Liability
+
+_Under no circumstances and under no legal theory, whether tort (including negligence), contract, or otherwise, shall any Contributor, or anyone who distributes Covered Software as permitted above, be liable to You for any direct, indirect, special, incidental, or consequential damages of any character including, without limitation, damages for lost profits, loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses, even if such party shall have been informed of the possibility of such damages. This limitation of liability shall not apply to liability for death or personal injury resulting from such party’s negligence to the extent applicable law prohibits such limitation. Some jurisdictions do not allow the exclusion or limitation of incidental or consequential damages, so this exclusion and limitation may not apply to You._
+
+## 8\. Litigation
+
+Any litigation relating to this License may be brought only in the courts of a jurisdiction where the defendant maintains its principal place of business and such litigation shall be governed by laws of that jurisdiction, without reference to its conflict-of-law provisions. Nothing in this Section shall prevent a party’s ability to bring cross-claims or counter-claims.
+
+## 9\. Miscellaneous
+
+This License represents the complete agreement concerning the subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not be used to construe this License against a Contributor.
+
+## 10\. Versions of the License
+
+### 10.1. New Versions
+
+Mozilla Foundation is the license steward. Except as provided in Section 10.3, no one other than the license steward has the right to modify or publish new versions of this License. Each version will be given a distinguishing version number.
+
+### 10.2. Effect of New Versions
+
+You may distribute the Covered Software under the terms of the version of the License under which You originally received the Covered Software, or under the terms of any subsequent version published by the license steward.
+
+### 10.3. Modified Versions
+
+If you create software not governed by this License, and you want to create a new license for such software, you may create and use a modified version of this License if you rename the license and remove any references to the name of the license steward (except to note that such modified license differs from this License).
+
+### 10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses
+
+If You choose to distribute Source Code Form that is Incompatible With Secondary Licenses under the terms of this version of the License, the notice described in Exhibit B of this License must be attached.
+
+## Exhibit A - Source Code Form License Notice
+
+> This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0/>.
+
+If it is not possible or desirable to put the notice in a particular file, then You may include the notice in a location (such as a LICENSE file in a relevant directory) where a recipient would be likely to look for such a notice.
+
+You may add additional accurate notices of copyright ownership.
+
+## Exhibit B - “Incompatible With Secondary Licenses” Notice
+
+> This Source Code Form is “Incompatible With Secondary Licenses”, as defined by the Mozilla Public License, v. 2.0.

+ 5 - 0
README.md

@@ -0,0 +1,5 @@
+# PageOS 应用程序起动器
+
+## 附加许可
+
+- MIT license: [pinyinjs](https://github.com/sxei/pinyinjs/);

+ 16 - 0
assets/icon.svg

@@ -0,0 +1,16 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
+  <!-- 外层圆环 -->
+  <circle cx="50" cy="50" r="45" fill="#558B2F" stroke="#33691E" stroke-width="6"/>
+  
+  <!-- 内层白色圆环 -->
+  <circle cx="50" cy="50" r="32" fill="#F1F8E9"/>
+  
+  <!-- 应用启动器图标元素 -->
+  <g transform="translate(50,60)">
+    <!-- 应用网格 -->
+    <rect x="-11" y="-11" width="10" height="10" fill="#26A69A"/>
+    <rect x="1" y="-11" width="10" height="10" fill="#26A69A"/>
+    <rect x="-11" y="-23" width="10" height="10" fill="#26A69A"/>
+    <rect x="1" y="-21" width="8" height="8" fill="#26A69A"/>
+  </g>
+</svg>

+ 338 - 0
index.html

@@ -0,0 +1,338 @@
+<!DOCTYPE html>
+<html lang="zh-Hans-CN">
+  <head>
+    <meta charset="UTF-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+    <title>PageOS 应用启动器</title>
+    <style>
+      /* 全局样式 - 从pageos-ui继承 */
+      * {
+        color: var(--secondary-font-color);
+        font-family: "Maple Mono CN", "Courier New", Courier, monospace;
+        box-sizing: border-box;
+        transition: all 0.2s ease;
+      }
+
+      ::selection {
+        background: var(--accent-bg-color);
+        color: var(--accent-font-color);
+      }
+
+      :root,
+      body {
+        height: 100%;
+        margin: 0;
+        overflow: hidden;
+        background: var(--content-bg-color);
+        padding: var(--margin-padding);
+
+        --accent-color: #64ffda; /* 强调色:边框 */
+        --secondary-color: #00695c; /* 次要色:未激活边框 */
+        --danger-color: #ff6d00; /* 着重色:边框 */
+        --accent-bg-color: #009688;
+        --secondary-bg-color: #616161;
+        --content-bg-color: #424242;
+        --accent-font-color: #f5f5f5;
+        --secondary-font-color: #eeeeee;
+
+        --margin-padding: 0.5rem;
+        --border-thickness: 0.2rem;
+        --border-radius: 0.5rem;
+        --shadow: 0.6rem 0.6rem 0.1rem 0.1rem rgba(0, 0, 0, 0.2);
+        --focused-bg-color: rgba(255, 255, 255, 0.1);
+      }
+
+      /* 应用启动器特定样式 */
+      .container {
+        width: 100%;
+        height: 100%;
+        max-height: 100%;
+      }
+
+      .container.focused {
+        --secondary-font-color: var(--accent-font-color);
+        --secondary-color: var(--accent-color);
+      }
+
+      #apps-container {
+        overflow-y: auto;
+        height: calc(100% - 3.5rem); /* 减去搜索框高度 */
+      }
+
+      #apps-container > *:last-child {
+        margin-bottom: 0;
+      }
+
+      .search-box {
+        width: 100%;
+        padding: var(--margin-padding);
+        margin-bottom: 1rem;
+        border-radius: var(--border-radius);
+        border: var(--border-thickness) solid var(--secondary-color);
+        background: var(--secondary-bg-color);
+        color: var(--secondary-font-color);
+        font-size: 1rem;
+        outline: none;
+      }
+
+      .search-box:focus {
+        border-color: var(--accent-color);
+      }
+
+      .group {
+        margin-bottom: 1.5rem;
+        background: var(--secondary-bg-color);
+        border-radius: var(--border-radius);
+        padding: var(--margin-padding);
+      }
+
+      .group-title {
+        font-size: 1.2rem;
+        margin-bottom: 0.5rem;
+        padding-bottom: 0.3rem;
+        border-bottom: var(--border-thickness) solid var(--accent-color);
+        color: var(--accent-color);
+      }
+
+      .apps-grid {
+        display: grid;
+        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
+        gap: 1rem;
+      }
+
+      .app-item {
+        display: flex;
+        flex-direction: column;
+        align-items: center;
+        text-align: center;
+        cursor: pointer;
+      }
+
+      .app-item:hover {
+        color: var(--accent-font-color);
+        .app-icon {
+          background: var(--accent-bg-color);
+        }
+      }
+
+      .app-icon {
+        width: 70px;
+        height: 70px;
+        border-radius: calc(var(--border-radius) * 0.7);
+        background: var(--focused-bg-color);
+        display: flex;
+        align-items: center;
+        justify-content: center;
+        margin-bottom: 0.5rem;
+        overflow: hidden;
+      }
+
+      .app-icon .icon-fallback {
+        font-size: 1.5rem;
+        color: var(--accent-color);
+      }
+
+      .app-name {
+        font-size: 0.9rem;
+        word-break: break-all;
+      }
+
+      .no-results {
+        text-align: center;
+        padding: 1rem;
+        color: var(--danger-color);
+      }
+    </style>
+    <link
+      rel="icon"
+      type="image/svg+xml"
+      href="data:image/svg+xml;charset=utf-8;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzMiIgaGVpZ2h0PSIzMiIgdmlld0JveD0iMCAwIDMyIDMyIj4KICA8IS0tIOWkluahhuefqeW9oiAtLT4KICA8cmVjdCB4PSIyIiB5PSIyIiB3aWR0aD0iMjgiIGhlaWdodD0iMjgiIHJ4PSIxMCIgcnk9IjEwIgogICAgZmlsbD0iIzQyNDI0MiIKICAgIHN0cm9rZT0iIzAwNjk1YyIKICAgIHN0cm9rZS13aWR0aD0iNCIvPgoKICA8IS0tIOW3puecvO+8muWwj+WchueCuSAtLT4KICA8Y2lyY2xlIGN4PSIxMiIgY3k9IjE0IiByPSIxLjUiIGZpbGw9IiNmNWY1ZjUiIC8+CgogIDwhLS0g5Y+z55y877ya5bCP5ZyG54K5IC0tPgogIDxjaXJjbGUgY3g9IjIwIiBjeT0iMTQiIHI9IjEuNSIgZmlsbD0iI2Y1ZjVmNSIgLz4KCiAgPCEtLSDpvLvlrZDvvJrnq5bnur8gLS0+CiAgPGxpbmUgeDE9IjE2IiB5MT0iMTYiIHgyPSIxNiIgeTI9IjE4IiBzdHJva2U9IiNmNWY1ZjUiIHN0cm9rZS13aWR0aD0iMS41IiAvPgoKICA8IS0tIOW+rueskeeahOWYtO+8muS4iuaJrOeahOW8p+e6vyAtLT4KICA8cGF0aCBkPSJNIDE0IDIwIFEgMTYgMjIgMTggMjAiIAogICAgICAgIGZpbGw9Im5vbmUiIAogICAgICAgIHN0cm9rZT0iI2Y1ZjVmNSIgCiAgICAgICAgc3Ryb2tlLXdpZHRoPSIxLjUiIAogICAgICAgIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgLz4KPC9zdmc+"
+    />
+  </head>
+  <body>
+    <div class="container">
+      <input
+        type="text"
+        class="search-box"
+        placeholder="搜索应用..."
+        oninput="filterApps()"
+      />
+
+      <div id="apps-container"></div>
+    </div>
+
+    <script src="lib/pinyinjs/pinyin_dict_withtone.js"></script>
+    <script src="lib/pinyinjs/pinyinUtil.js"></script>
+    <script>
+      let apps = [];
+
+      // 从index.json加载应用数据
+      async function loadApps() {
+        try {
+          const response = await fetch("/index.json");
+          const data = await response.json();
+
+          // 转换数据格式并添加拼音
+          apps = data.packages.map((app) => ({
+            id: app.id,
+            name: app.name,
+            icon: app.icon,
+            description: app.description,
+            location: app.location,
+            pinyin: pinyinUtil.getPinyin(app.name, "", false), // 不带声调的拼音
+          }));
+
+          renderAppGroups();
+        } catch (error) {
+          console.error("加载应用数据失败:", error);
+        }
+      }
+
+      // 按首字母分组应用
+      function groupAppsByInitial() {
+        const groups = {};
+
+        apps.forEach((app) => {
+          // 获取拼音首字母,如果拼音不存在则使用名称首字母
+          var initial = app.pinyin
+            ? app.pinyin.charAt(0).toUpperCase()
+            : app.name.charAt(0).toUpperCase();
+
+          // 特殊符号开头的归类到 #
+          if (/[^a-zA-Z0-9\u4e00-\u9fa5]/.test(initial)) {
+            initial = "#";
+          }
+          // 数字开头的归类到 &
+          else if (/[0-9]/.test(initial)) {
+            initial = "&";
+          }
+
+          if (!groups[initial]) {
+            groups[initial] = [];
+          }
+          groups[initial].push(app);
+        });
+
+        return groups;
+      }
+
+      // 渲染应用分组
+      function renderAppGroups() {
+        const container = document.getElementById("apps-container");
+        container.innerHTML = "";
+
+        const groups = groupAppsByInitial();
+
+        // 按字母顺序排序分组
+        const sortedKeys = Object.keys(groups).sort();
+
+        sortedKeys.forEach((key) => {
+          const groupHTML = `
+          <div class="group">
+            <div class="group-title">${key}</div>
+            <div class="apps-grid">
+              ${groups[key]
+                .map(
+                  (app) => `
+                <a href="${app.location}/metadata.json" class="app-item" data-id="${app.id}" data-pageos="app">
+                  <div class="app-icon">
+                    ${
+                      app.icon
+                        ? `<img src="${
+                            app.icon.startsWith("/") ? app.icon : "/" + app.icon
+                          }" alt="${
+                            app.name
+                          }" onerror="this.parentNode.innerHTML='<span class=\\'icon-fallback\\'>${app.name.charAt(
+                            0
+                          )}</span>'">`
+                        : `<span class="icon-fallback">${app.name.charAt(
+                            0
+                          )}</span>`
+                    }
+                  </div>
+                  <div class="app-name">${app.name}</div>
+                </a>
+              `
+                )
+                .join("")}
+            </div>
+          </div>
+        `;
+
+          container.innerHTML += groupHTML;
+        });
+      }
+
+      // 应用搜索过滤
+      function filterApps() {
+        const searchTerm = document
+          .querySelector(".search-box")
+          .value.toLowerCase();
+
+        if (!searchTerm) {
+          renderAppGroups();
+          return;
+        }
+
+        const container = document.getElementById("apps-container");
+        container.innerHTML = "";
+
+        const filteredApps = apps.filter(
+          (app) =>
+            app.name.toLowerCase().includes(searchTerm) ||
+            (app.pinyin && app.pinyin.includes(searchTerm))
+        );
+
+        if (filteredApps.length === 0) {
+          container.innerHTML =
+            '<div class="no-results">未找到匹配的应用</div>';
+          return;
+        }
+
+        const groupHTML = `
+        <div class="group">
+          <div class="group-title">搜索结果</div>
+          <div class="apps-grid">
+            ${filteredApps
+              .map(
+                (app) => `
+              <a href="${app.location}/metadata.json" class="app-item" data-id="${app.id}" data-pageos="app">
+                <div class="app-icon">
+                  ${
+                    app.icon
+                      ? `<img src="${
+                          app.icon.startsWith("/") ? app.icon : "/" + app.icon
+                        }" alt="${
+                          app.name
+                        }" onerror="this.parentNode.innerHTML='<span class=\\'icon-fallback\\'>${app.name.charAt(
+                          0
+                        )}</span>'">`
+                      : `<span class="icon-fallback">${app.name.charAt(
+                          0
+                        )}</span>`
+                  }
+                </div>
+                <div class="app-name">${app.name}</div>
+              </a>
+            `
+              )
+              .join("")}
+          </div>
+        </div>
+      `;
+
+        container.innerHTML = groupHTML;
+      }
+
+      // 初始加载应用数据
+      document.addEventListener("DOMContentLoaded", loadApps);
+
+      // 阻止滚动事件冒泡
+      document
+        .getElementById("apps-container")
+        .addEventListener("wheel", (e) => {
+          e.stopPropagation();
+        });
+    </script>
+  </body>
+</html>

+ 372 - 0
lib/pinyinjs/pinyinUtil.js

@@ -0,0 +1,372 @@
+
+/**
+ * 汉字与拼音互转工具,根据导入的字典文件的不同支持不同
+ * 对于多音字目前只是将所有可能的组合输出,准确识别多音字需要完善的词库,而词库文件往往比字库还要大,所以不太适合web环境。
+ * @start 2016-09-26
+ * @last 2016-09-29
+ */
+;(function(global, factory) {
+	if (typeof module === "object" && typeof module.exports === "object") {
+		module.exports = factory(global);
+	} else {
+		factory(global);
+	}
+})(typeof window !== "undefined" ? window : this, function(window) {
+
+	var toneMap = 
+	{
+		"ā": "a1",
+		"á": "a2",
+		"ǎ": "a3",
+		"à": "a4",
+		"ō": "o1",
+		"ó": "o2",
+		"ǒ": "o3",
+		"ò": "o4",
+		"ē": "e1",
+		"é": "e2",
+		"ě": "e3",
+		"è": "e4",
+		"ī": "i1",
+		"í": "i2",
+		"ǐ": "i3",
+		"ì": "i4",
+		"ū": "u1",
+		"ú": "u2",
+		"ǔ": "u3",
+		"ù": "u4",
+		"ü": "v0",
+		"ǖ": "v1",
+		"ǘ": "v2",
+		"ǚ": "v3",
+		"ǜ": "v4",
+		"ń": "n2",
+		"ň": "n3",
+		"": "m2"
+	};
+
+	var dict = {}; // 存储所有字典数据
+	var pinyinUtil =
+	{
+		/**
+		 * 解析各种字典文件,所需的字典文件必须在本JS之前导入
+		 */
+		parseDict: function()
+		{
+			// 如果导入了 pinyin_dict_firstletter.js
+			if(window.pinyin_dict_firstletter)
+			{
+				dict.firstletter = pinyin_dict_firstletter;
+			}
+			// 如果导入了 pinyin_dict_notone.js
+			if(window.pinyin_dict_notone)
+			{
+				dict.notone = {};
+				dict.py2hz = pinyin_dict_notone; // 拼音转汉字
+				for(var i in pinyin_dict_notone)
+				{
+					var temp = pinyin_dict_notone[i];
+					for(var j=0, len=temp.length; j<len; j++)
+					{
+						if(!dict.notone[temp[j]]) dict.notone[temp[j]] = i; // 不考虑多音字
+					}
+				}
+			}
+			// 如果导入了 pinyin_dict_withtone.js
+			if(window.pinyin_dict_withtone)
+			{
+				dict.withtone = {}; // 汉字与拼音映射,多音字用空格分开,类似这种结构:{'大': 'da tai'}
+				var temp = pinyin_dict_withtone.split(',');
+				for(var i=0, len = temp.length; i<len; i++)
+				{
+					// 这段代码耗时28毫秒左右,对性能影响不大,所以一次性处理完毕
+					dict.withtone[String.fromCharCode(i + 19968)] = temp[i]; // 这里先不进行split(' '),因为一次性循环2万次split比较消耗性能
+				}
+
+				// 拼音 -> 汉字
+				if(window.pinyin_dict_notone)
+				{
+					// 对于拼音转汉字,我们优先使用pinyin_dict_notone字典文件
+					// 因为这个字典文件不包含生僻字,且已按照汉字使用频率排序
+					dict.py2hz = pinyin_dict_notone; // 拼音转汉字
+				}
+				else
+				{
+					// 将字典文件解析成拼音->汉字的结构
+					// 与先分割后逐个去掉声调相比,先一次性全部去掉声调然后再分割速度至少快了3倍,前者大约需要120毫秒,后者大约只需要30毫秒(Chrome下)
+					var notone = pinyinUtil.removeTone(pinyin_dict_withtone).split(',');
+					var py2hz = {}, py, hz;
+					for(var i=0, len = notone.length; i<len; i++)
+					{
+						hz = String.fromCharCode(i + 19968); // 汉字
+						py = notone[i].split(' '); // 去掉了声调的拼音数组
+						for(var j=0; j<py.length; j++)
+						{
+							py2hz[py[j]] = (py2hz[py[j]] || '') + hz;
+						}
+					}
+					dict.py2hz = py2hz;
+				}
+			}
+		},
+		/**
+		 * 根据汉字获取拼音,如果不是汉字直接返回原字符
+		 * @param chinese 要转换的汉字
+		 * @param splitter 分隔字符,默认用空格分隔
+		 * @param withtone 返回结果是否包含声调,默认是
+		 * @param polyphone 是否支持多音字,默认否
+		 */
+		getPinyin: function(chinese, splitter, withtone, polyphone)
+		{
+			if(!chinese || /^ +$/g.test(chinese)) return '';
+			splitter = splitter == undefined ? ' ' : splitter;
+			withtone = withtone == undefined ? true : withtone;
+			polyphone = polyphone == undefined ? false : polyphone;
+			var result = [];
+			if(dict.withtone) // 优先使用带声调的字典文件
+			{
+				var noChinese = '';
+				for (var i=0, len = chinese.length; i < len; i++)
+				{
+					var pinyin = dict.withtone[chinese[i]];
+					if(pinyin)
+					{
+						// 如果不需要多音字,默认返回第一个拼音,后面的直接忽略
+						// 所以这对数据字典有一定要求,常见字的拼音必须放在最前面
+						if(!polyphone) pinyin = pinyin.replace(/ .*$/g, '');
+						if(!withtone) pinyin = this.removeTone(pinyin); // 如果不需要声调
+						//空格,把noChinese作为一个词插入
+						noChinese && ( result.push( noChinese), noChinese = '' );
+						result.push( pinyin ); 
+					}
+					else if ( !chinese[i] || /^ +$/g.test(chinese[i]) ){
+						//空格,把noChinese作为一个词插入
+						noChinese && ( result.push( noChinese), noChinese = '' );
+					}
+					else{
+						noChinese += chinese[i];
+					}
+				}
+				if ( noChinese ){
+					result.push( noChinese);
+					noChinese = '';
+				}
+			}
+			else if(dict.notone) // 使用没有声调的字典文件
+			{
+				if(withtone) console.warn('pinyin_dict_notone 字典文件不支持声调!');
+				if(polyphone) console.warn('pinyin_dict_notone 字典文件不支持多音字!');
+				var noChinese = '';
+				for (var i=0, len = chinese.length; i < len; i++)
+				{
+					var temp = chinese.charAt(i),
+						pinyin = dict.notone[temp];
+					if ( pinyin ){ //插入拼音
+						//空格,把noChinese作为一个词插入
+						noChinese && ( result.push( noChinese), noChinese = '' );
+						result.push( pinyin );
+					}
+					else if ( !temp || /^ +$/g.test(temp) ){
+						//空格,插入之前的非中文字符
+						noChinese && ( result.push( noChinese), noChinese = '' );
+					}
+					else {
+						//非空格,关联到noChinese中
+						noChinese += temp;
+					}
+				}
+
+				if ( noChinese ){
+					result.push( noChinese );
+					noChinese = '';
+				}
+			}
+			else
+			{
+				throw '抱歉,未找到合适的拼音字典文件!';
+			}
+			if(!polyphone) return result.join(splitter);
+			else
+			{
+				if(window.pinyin_dict_polyphone) return parsePolyphone(chinese, result, splitter, withtone);
+				else return handlePolyphone(result, ' ', splitter);
+			}
+		},
+		/**
+		 * 获取汉字的拼音首字母
+		 * @param str 汉字字符串,如果遇到非汉字则原样返回
+		 * @param polyphone 是否支持多音字,默认false,如果为true,会返回所有可能的组合数组
+		 */
+		getFirstLetter: function(str, polyphone)
+		{
+			polyphone = polyphone == undefined ? false : polyphone;
+			if(!str || /^ +$/g.test(str)) return '';
+			if(dict.firstletter) // 使用首字母字典文件
+			{
+				var result = [];
+				for(var i=0; i<str.length; i++)
+				{
+					var unicode = str.charCodeAt(i);
+					var ch = str.charAt(i);
+					if(unicode >= 19968 && unicode <= 40869)
+					{
+						ch = dict.firstletter.all.charAt(unicode-19968);
+						if(polyphone) ch = dict.firstletter.polyphone[unicode] || ch;
+					}
+					result.push(ch);
+				}
+				if(!polyphone) return result.join(''); // 如果不用管多音字,直接将数组拼接成字符串
+				else return handlePolyphone(result, '', ''); // 处理多音字,此时的result类似于:['D', 'ZC', 'F']
+			}
+			else
+			{
+				var py = this.getPinyin(str, ' ', false, polyphone);
+				py = py instanceof Array ? py : [py];
+				var result = [];
+				for(var i=0; i<py.length; i++)
+				{
+					result.push(py[i].replace(/(^| )(\w)\w*/g, function(m,$1,$2){return $2.toUpperCase();}));
+				}
+				if(!polyphone) return result[0];
+				else return simpleUnique(result);
+			}
+		},
+		/**
+		 * 拼音转汉字,只支持单个汉字,返回所有匹配的汉字组合
+		 * @param pinyin 单个汉字的拼音,可以包含声调
+		 */
+		getHanzi: function(pinyin)
+		{
+			if(!dict.py2hz)
+			{
+				throw '抱歉,未找到合适的拼音字典文件!';
+			}
+			return dict.py2hz[this.removeTone(pinyin)] || '';
+		},
+		/**
+		 * 获取某个汉字的同音字,本方法暂时有问题,待完善
+		 * @param hz 单个汉字
+		 * @param sameTone 是否获取同音同声调的汉字,必须传进来的拼音带声调才支持,默认false
+		 */
+		getSameVoiceWord: function(hz, sameTone)
+		{
+			sameTone = sameTone || false
+			return this.getHanzi(this.getPinyin(hz, ' ', false))
+		},
+		/**
+		 * 去除拼音中的声调,比如将 xiǎo míng tóng xué 转换成 xiao ming tong xue
+		 * @param pinyin 需要转换的拼音
+		 */
+		removeTone: function(pinyin)
+		{
+			return pinyin.replace(/[āáǎàōóǒòēéěèīíǐìūúǔùüǖǘǚǜńň]/g, function(m){ return toneMap[m][0]; });
+		},
+		/**
+		 * 将数组拼音转换成真正的带标点的拼音
+		 * @param pinyinWithoutTone 类似 xu2e这样的带数字的拼音
+		 */
+		getTone: function(pinyinWithoutTone)
+		{
+			var newToneMap = {};
+			for(var i in toneMap) newToneMap[toneMap[i]] = i;
+			return (pinyinWithoutTone || '').replace(/[a-z]\d/g, function(m) {
+				return newToneMap[m] || m;
+			});
+		}
+	};
+
+
+	/**
+	 * 处理多音字,将类似['D', 'ZC', 'F']转换成['DZF', 'DCF']
+	 * 或者将 ['chang zhang', 'cheng'] 转换成 ['chang cheng', 'zhang cheng']
+	 */
+	function handlePolyphone(array, splitter, joinChar)
+	{
+		splitter = splitter || '';
+		var result = [''], temp = [];
+		for(var i=0; i<array.length; i++)
+		{
+			temp = [];
+			var t = array[i].split(splitter);
+			for(var j=0; j<t.length; j++)
+			{
+				for(var k=0; k<result.length; k++)
+					temp.push(result[k] + (result[k]?joinChar:'') + t[j]);
+			}
+			result = temp;
+		}
+		return simpleUnique(result);
+	}
+
+	/**
+	 * 根据词库找出多音字正确的读音
+	 * 这里只是非常简单的实现,效率和效果都有一些问题
+	 * 推荐使用第三方分词工具先对句子进行分词,然后再匹配多音字
+	 * @param chinese 需要转换的汉字
+	 * @param result 初步匹配出来的包含多个发音的拼音结果
+	 * @param splitter 返回结果拼接字符
+	 */
+	function parsePolyphone(chinese, result, splitter, withtone)
+	{
+		var poly = window.pinyin_dict_polyphone;
+		var max = 7; // 最多只考虑7个汉字的多音字词,虽然词库里面有10个字的,但是数量非常少,为了整体效率暂时忽略之
+		var temp = poly[chinese];
+		if(temp) // 如果直接找到了结果
+		{
+			temp = temp.split(' ');
+			for(var i=0; i<temp.length; i++)
+			{
+				result[i] = temp[i] || result[i];
+				if(!withtone) result[i] = pinyinUtil.removeTone(result[i]);
+			}
+			return result.join(splitter);
+		}
+		for(var i=0; i<chinese.length; i++)
+		{
+			temp = '';
+			for(var j=0; j<max && (i+j)<chinese.length; j++)
+			{
+				if(!/^[\u2E80-\u9FFF]+$/.test(chinese[i+j])) break; // 如果碰到非汉字直接停止本次查找
+				temp += chinese[i+j];
+				var res = poly[temp];
+				if(res) // 如果找到了多音字词语
+				{
+					res = res.split(' ');
+					for(var k=0; k<=j; k++)
+					{
+						if(res[k]) result[i+k] = withtone ? res[k] : pinyinUtil.removeTone(res[k]);
+					}
+					break;
+				}
+			}
+		}
+		// 最后这一步是为了防止出现词库里面也没有包含的多音字词语
+		for(var i=0; i<result.length; i++)
+		{
+			result[i] = result[i].replace(/ .*$/g, '');
+		}
+		return result.join(splitter);
+	}
+
+	// 简单数组去重
+	function simpleUnique(array)
+	{
+		var result = [];
+		var hash = {};
+		for(var i=0; i<array.length; i++)
+		{
+			var key = (typeof array[i]) + array[i];
+			if(!hash[key])
+			{
+				result.push(array[i]);
+				hash[key] = true;
+			}
+		}
+		return result;
+	}
+
+	pinyinUtil.parseDict();
+	pinyinUtil.dict = dict;
+	window.pinyinUtil = pinyinUtil;
+
+});

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 0 - 0
lib/pinyinjs/pinyin_dict_withtone.js


+ 18 - 0
metadata.json

@@ -0,0 +1,18 @@
+{
+  "name": "PageOS 应用启动器",
+  "id": "pageos-app-launcher",
+  "version": "0.1.0",
+  "description": "PageOS 应用启动器",
+  "icon": "assets/icon.svg",
+  "author": "PJ568",
+  "type": "software",
+  "category": "pageos",
+  "permissions": [],
+  "entry": "index.html",
+  "all_files": {
+    "lib/pinyinjs/pinyin_dict_withtone.js": "e822cf20885ae7d6adcb35a3cbd94c3372e8dc6dbf04b1407f240c8c8da7d437",
+    "assets/icon.svg": "4a60a778bbbcc370e9f593d2260d3bac003750f5ba73d9a33f2b31303687f7b5",
+    "lib/pinyinjs/pinyinUtil.js": "8b71ceebda777d1cc7b1afdcc9096f59676ce0fbe151d21db06f35d7e2ad7986",
+    "index.html": "77d771b851889431cddd520aff6f67cbeae59efbc01cbc9c025c3029df1250e1"
+  }
+}

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio