Skip to content

Commit

Permalink
feat: $app & Console
Browse files Browse the repository at this point in the history
Update boxjs.settings.json
Update CHANGELOG.md
Update response.dev.js
Update request.dev.js
Update response.js
Update request.js
  • Loading branch information
VirgilClyne committed Nov 30, 2024
1 parent 1e089be commit 6d380db
Show file tree
Hide file tree
Showing 10 changed files with 578 additions and 660 deletions.
14 changes: 10 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
### 🆕 New Features
* `翻译器`允许通过`参数面板`传入任意`语言代码`
* 传入的`语言代码`如不受`翻译API`支持,则可能导致翻译失败,请先查阅各`翻译API``支持语言列表`进行确认
* 例如:当使用`微软翻译`时,在`参数面板``Language[1]`填入`lzh`,可以将翻译语言设置为`中文(文言文)`
### 🛠️ Bug Fixes
* 修复 `$argument``$persistentStore` 载入顺序颠倒的问题
* 正确顺序为先读取 `$argument` 再读取 `$persistentStore (BoxJs)`
* 即,有相同键名时,`$persistentStore (BoxJs)` 的值会覆盖 `$argument` 的值

### 🔣 Dependencies
* 升级了 `@nsnanocat/util`
* `util``submodule` 更改为 `package`
* `$platform` 改为 `$app`
* 使用了全新的 `Console` polyfill
2 changes: 0 additions & 2 deletions src/function/database.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
export default {
Default: {
Settings: {
Switch: true,
Type: "Translate",
Types: ["Official", "Translate"],
Languages: ["EN", "ZH"],
Expand All @@ -20,7 +19,6 @@ export default {
},
Spotify: {
Settings: {
Switch: true,
CountryCode: "US",
Types: ["Translate", "External"],
Languages: ["AUTO", "ZH"],
Expand Down
6 changes: 4 additions & 2 deletions src/function/setCache.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Console } from "@nsnanocat/util";

/**
* Set Cache
* @author VirgilClyne
Expand All @@ -6,9 +8,9 @@
* @return {Boolean} isSaved
*/
export default function setCache(cache, cacheSize = 100) {
console.log(`☑️ Set Cache, cacheSize: ${cacheSize}`, "");
Console.log("☑️ Set Cache", `cacheSize: ${cacheSize}`);
cache = Array.from(cache || []); // Map转Array
cache = cache.slice(-cacheSize); // 限制缓存大小
console.log("✅ Set Cache", "");
Console.log("✅ Set Cache");
return cache;
};
9 changes: 5 additions & 4 deletions src/function/setENV.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Lodash as _, getStorage, log } from "@nsnanocat/util";
import { Console, getStorage, Lodash as _ } from "@nsnanocat/util";

/**
* Set Environment Variables
Expand All @@ -9,19 +9,20 @@ import { Lodash as _, getStorage, log } from "@nsnanocat/util";
* @return {Object} { Settings, Caches, Configs }
*/
export default function setENV(name, platforms, database) {
log("☑️ Set Environment Variables", "");
Console.log("☑️ Set Environment Variables");
const { Settings, Caches, Configs } = getStorage(name, platforms, database);
/***************** Settings *****************/
if (!Array.isArray(Settings?.Types)) Settings.Types = (Settings.Types) ? [Settings.Types] : []; // 只有一个选项时,无逗号分隔
log(`✅ Set Environment Variables, Settings: ${typeof Settings}, Settings内容: ${JSON.stringify(Settings)}`, "");
Console.debug(`typeof Settings: ${typeof Settings}`, `Settings: ${JSON.stringify(Settings)}`);
/***************** Caches *****************/
//console.log(`✅ Set Environment Variables, Caches: ${typeof Caches}, Caches内容: ${JSON.stringify(Caches)}`, "");
//Console.debug(`typeof Caches: ${typeof Caches}`, `Caches: ${JSON.stringify(Caches)}`);
if (typeof Caches?.Playlists !== "object" || Array.isArray(Caches?.Playlists)) Caches.Playlists = {}; // 创建Playlists缓存
Caches.Playlists.Master = new Map(JSON.parse(Caches?.Playlists?.Master || "[]")); // Strings转Array转Map
Caches.Playlists.Subtitle = new Map(JSON.parse(Caches?.Playlists?.Subtitle || "[]")); // Strings转Array转Map
if (typeof Caches?.Subtitles !== "object") Caches.Subtitles = new Map(JSON.parse(Caches?.Subtitles || "[]")); // Strings转Array转Map
if (typeof Caches?.Metadatas !== "object" || Array.isArray(Caches?.Metadatas)) Caches.Metadatas = {}; // 创建Playlists缓存
if (typeof Caches?.Metadatas?.Tracks !== "object") Caches.Metadatas.Tracks = new Map(JSON.parse(Caches?.Metadatas?.Tracks || "[]")); // Strings转Array转Map
/***************** Configs *****************/
Console.log("✅ Set Environment Variables");
return { Settings, Caches, Configs };
};
Loading

0 comments on commit 6d380db

Please sign in to comment.