Skip to content

内置第三方库

Font Awesome

Font Awesome 网站内有非常多图标可供你使用。

示例: 电脑图标

html
<html>
<body>
  <i class="fa-solid fa-laptop-code"></i>
</body>
</html>

file-saver

通过 file-saver,你可以很方便地下载文件,所以你也许可以内置检查角色卡更新等? 这是 iframe 本来就支持的功能,加入 file-saver 只是为了方便我们的某些功能。

示例

typescript
const blob = new Blob(["hello,world!"],{type: "text/plain;charset=utf-8"});
saveAs(blob,"filename.txt");
typescript
// 链接是本地链接或域外支持 CORS 的链接,则直接下载:
saveAs(`https://gitgud.io/api/v4/projects/${encodeURIComponent("SmilingFace/tavern_resource")}/repository/files/${encodeURIComponent("角色卡/妹妹请求你保护她/妹妹请求你保护她.png")}/raw?ref=main`"妹妹请求你保护她.png");

// 否则将会弹窗到对应的链接 (浏览器会默认拦截):
saveAs("https://gitgud.io/SmilingFace/tavern_resource/-/raw/main/角色卡/妹妹请求你保护她/妹妹请求你保护她.png?inline=false""妹妹请求你保护她.png")

JQuery

通过 JQuery,你可以很方便地设置界面 DOM 元素。

示例: 向 body 末尾添加一行文本

html
<html>
  <body>
    <script>
      const variables = {神乐光: {好感度: 5}};
      $("body").append($("<p></p>").text(JSON.stringify(variables)));
    </script>
  </body>
</html>

JQuery UI

通过 JQuery UI,你可以很方便地设置界面 DOM 元素可以如何被交互。

示例: 向 body 末尾添加一行可以拖动的文本

html
<html>
<body>
  <div id="draggable" class="ui-widget-content">
    <p>随意拖动我</p>
  </div>
  <script>
    $(document).ready(function () {
      $("#draggable").draggable();
    });
  </script>
</body>
</html>

Lodash

通过 Lodash,你可以很方便地对 Array、Object 等类型进行操作。

示例

html
<html>
  <body>
    <script>
      const array = _.uniq([13231454]);
      // => array == [1,3,2,4,5]
      $("body").append($("<p></p>").text(JSON.stringify(array)));
    </script>
  </body>
</html>
html
<html>
  <body>
    <script>
      const result = {a: 1,b: 2};
      const source = {b: 3,c: 4};
      _.merge(result,source);
      // => result == {a: 1,b: 3,c: 4}
      $("body").append($("<p></p>").text(JSON.stringify(result)));
    </script>
  </body>
</html>

yamljs

允许你像 JavaScript 内置的 JSON 那样解析 yaml 语法。

示例

html
<html>
<body>
  <script>
    const variables =
    {
      角色变量:
      {
        爱城华恋: {
          好感度: 10
        },
        神乐光: {
          好感度: 5
        },
      }
    }
    $("body").append($("<p></p>").text(YAML.stringify(variables)));
  </script>
</body>
</html>
html
<html>
<body>
  <script>
    const variables = `
    角色变量:
      爱城华恋:
        好感度: 10
      神乐光:
        好感度: 5
    `
    $("body").append($("<p></p>").text(JSON.stringify(YAML.parse(variables))));
  </script>
</body>
</html>

作者:KAKAA, 青空莉想做舞台少女的狗