之前续写抖音开发者接入字节小游戏的缓存一下,现在说一下在 Windows 或者 Mac 如何用终端更换路径?

window:

比方说你的 window 目录下是这个路径:

第一:E:\project\Q1\trunk\client\src,然后你想切换到下一个路径的话,你可以这样子操作:

第二:E:\project\Q1\trunk\client\src> cd .\usersetting 然后回车,这里不会计较大小写

第三:你就可以在这个目录下执行你的脚本:E:\project\Q1\trunk\client\src\usersetting>

比如我是在E:\project\Q1\trunk\client\src\usersetting>下面有一个 js 脚本的那么你就可以执行下面这行操作,前提你要安装 node.js哦E:\project\Q1\trunk\client\src\usersetting> node .\imgmetachange.js然后回车即可;

然后就可以实现 window 的所有操作了,如果你想回到上一个目录的话.你可以这样子操作:

E:\project\Q1\trunk\client\src\usersetting>cd ..//(输入 cd..)两点就回车就可以回到上一个目录啦

E:\project\Q1\trunk\client\src>

===============以上是针对 window 操作系统的哈====================

macOS 系统操作如何下:

第一:zghMacBook-Pro:~ zghMacBookPro$ cd desktop//回车就可以指定你的桌面所有的内容,如果你想指定桌面的某一个文件

第二:你可以输入:zghMacBook-Pro:desktop zhengguohai$ cd 好了之后看然后回车就可以看见这个目录:zghMacBook-Pro:好看 zghMacBookPro$,如果你想在里面找某一个文件你可以这样子

第三:输入:zghMacBook-Pro:好看 zghMacBookPro$ ls回车就回出现很多文件夹,如果你想返回上一个目录的话,你可以输入:zghMacBook-Pro:好看 zghMacBookPro$ cd就会得到这个目录:zghMacBook-Pro:~ zghMacBookPro$ cd

===========以上就是针对 macOS 系统的目录如何更换目录的方法啦======

这个 imgmetachege.js 如下:

const fs = require("fs");

const path = require("path");

const projectPath = path.join(__dirname, "../assets/resources"); // 目录

const platformSettings = {

"default": {

"formats": [

{

"name": "astc_6x6",

"quality": "exhaustive"

},

{

"name": "webp",

"quality": 80

}

]

},

"android": {

"formats": [

{

"name": "astc_6x6",

"quality": "exhaustive"

}

]

},

"ios": {

"formats": [

{

"name": "astc_6x6",

"quality": "exhaustive"

}

]

},

"web": {

"formats": [

{

"name": "astc_8x8",

"quality": "exhaustive"

},

{

"name": "webp",

"quality": 80

}

]

},

"minigame": {

"formats": [

{

"name": "astc_8x8",

"quality": "exhaustive"

},

{

"name": "webp",

"quality": 80

},

{

"name": "png",

"quality": 80

}

]

}

}

const platformSettingsJPG = {

"default": {

"formats": [

{

"name": "astc_6x6",

"quality": "exhaustive"

},

{

"name": "webp",

"quality": 80

}

]

},

"android": {

"formats": [

{

"name": "astc_6x6",

"quality": "exhaustive"

}

]

},

"ios": {

"formats": [

{

"name": "astc_6x6",

"quality": "exhaustive"

}

]

},

"web": {

"formats": [

{

"name": "astc_8x8",

"quality": "exhaustive"

},

{

"name": "webp",

"quality": 80

}

]

},

"minigame": {

"formats": [

{

"name": "astc_8x8",

"quality": "exhaustive"

},

{

"name": "webp",

"quality": 80

},

{

"name": "jpg",

"quality": 80

}

]

}

}

let num = 0;

function checkImgDir(dir) {

if (fs.existsSync(dir))

{

let dirList = [];

let pngList = [];

let jpgList = [];

let hasPac = false;

let fileList = fs.readdirSync(dir);

for (let file of fileList)

{

let filePath = path.join(dir, file);

// 判断是文件还是目录

let stats = fs.statSync(filePath);

if (stats.isDirectory())

{

dirList.push(filePath);

} else if (stats.isFile())

{

if (file.endsWith(".pac.meta"))

{

hasPac = true;

writeFileSync(filePath, "pac");

break;

} else if (file.endsWith(".png.meta"))

{

pngList.push(filePath);

} else if (file.endsWith(".jpg.meta"))

{

jpgList.push(filePath);

}

}

}

if (!hasPac)

{

for (let i in dirList)

{

checkImgDir(dirList[i]);

}

for (let filePath of pngList)

{

writeFileSync(filePath, "png");

}

for (let filePath of jpgList)

{

writeFileSync(filePath, "jpg");

}

}

}

}

function writeFileSync(filePath, type) {

num++;

let content = fs.readFileSync(filePath, "utf-8");

let obj = JSON.parse(content);

obj['platformSettings'] = platformSettings;

if (type == "pac")

{

obj['filterUnused'] = false;

}

if(type == "jpg")

{

obj['platformSettings'] = platformSettingsJPG;

}

fs.writeFileSync(filePath, JSON.stringify(obj, null, 2), "utf-8");

}

var time = Date.now();

console.log('---开始查询---');

checkImgDir(projectPath);

console.log('---修改结束,耗时:' + (Date.now() - time) + "ms" + " 修改文件数:" + num);

相关推荐
nicekwell10 分钟前
macos sequoia 禁用 ctrl+enter 打开鼠标右键菜单功能
macos
丁总学Java4 小时前
在 Mac ARM 架构的 macOS 系统上启用 F1 键作为 Snipaste 的截屏快捷键
macos·snipaste
天下皆白_唯我独黑8 小时前
brew Nushell mac升级版本
macos
刘什么洋啊Zz13 小时前
MacOS下使用Ollama本地构建DeepSeek并使用本地Dify构建AI应用
人工智能·macos·ai·ollama·deepseek
goodmao13 小时前
【DeepSeek】-macOS本地终端部署后运行DeepSeek如何分析图片
gpt·macos·大模型·ollama·deepseek·本地图片分析
Macdo_cn19 小时前
Infuse Pro for Mac v8.1 全能视频播放器 支持M、Intel芯片
macos·音视频
软件技术NINI21 小时前
Deepseek本地部署指南:在linux服务器部署,在mac远程web-ui访问
linux·服务器·macos
清风细雨_林木木1 天前
Mac 清理缓存,提高内存空间
macos·缓存
Macdo_cn1 天前
Screen Wonders for Mac v3.3.1 3D屏保应用 支持M、Intel芯片
macos·音视频
秋窗72 天前
Mac下Python版本管理,适用于pyenv不起作用的情况
开发语言·python·macos