| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- const sharp = require("sharp");
- const fs = require("fs");
- const path = require("path");
- const iconPath = path.resolve(__dirname, "res", "icon", "ios");
- if (!fs.existsSync(iconPath)) {
- if (fs.mkdirSync(iconPath, { recursive: true })) {
- return;
- }
- }
- var sizeList = [
- 20, 29, 40, 50, 57, 58, 60, 72, 76, 80, 87, 100, 114, 120, 144, 152, 167,
- 180, 1024,
- ];
- var config = "";
- sizeList.forEach((size) => {
- config += `<icon height="${size}" src="res/icon/ios/icon-${size}.png" width="${size}" />\n`;
- sharp("icon.png")
- .resize(size)
- .toBuffer()
- .then((data) => {
- var file = fs.open(
- path.resolve(iconPath, `icon-${size}.png`),
- "w",
- (err, fd) => {
- if (err) {
- return console.error(err);
- }
- fs.writeFile(fd, data, (err) => {
- if (err) {
- return console.error(err);
- }
- });
- }
- );
- })
- .catch((e) => {
- console.log(e);
- });
- });
- fs.writeFile(path.resolve(iconPath, "config"), config, (err) => {});
|