mirror of
https://github.com/ZZZure/ZZZ-Plugin.git
synced 2025-12-16 21:27:47 +00:00
feat: 角色天赋图鉴(支持自定义等级)
This commit is contained in:
parent
4f02e6b2ce
commit
15b14eece4
23 changed files with 937 additions and 124 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import path from 'path';
|
||||
import { imageResourcesPath } from '../path.js';
|
||||
import { imageResourcesPath, dataResourcesPath } from '../path.js';
|
||||
|
||||
export const ZZZ_SQUARE_AVATAR_PATH = path.join(
|
||||
imageResourcesPath,
|
||||
|
|
@ -18,7 +18,7 @@ export const ZZZ_SQUARE_AVATAR_PATH = path.join(
|
|||
// const ZZZ_GUIDES_PATH = path.join(imageResourcesPath, 'guides');
|
||||
|
||||
export const HAKUSH_CHARACTER_DATA_PATH = path.join(
|
||||
imageResourcesPath,
|
||||
dataResourcesPath,
|
||||
'hakush/data/character'
|
||||
),
|
||||
HAKUSH_WEAPON_DATA_PATH = path.join(imageResourcesPath, 'hakush/data/weapon');
|
||||
HAKUSH_WEAPON_DATA_PATH = path.join(dataResourcesPath, 'hakush/data/weapon');
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import { checkFile } from './core.js';
|
||||
import { getResourceRemotePath } from '../assets.js';
|
||||
import * as MysURL from '../assets/mysurl.js';
|
||||
|
|
@ -10,6 +11,7 @@ import * as LocalURI from './const.js';
|
|||
* @param {keyof LocalURI} localBase 本地地址
|
||||
* @param {string} filename 文件名
|
||||
* @param {keyof MysURL} newBase 新远程地址
|
||||
* @returns {Promise<string | null>} 保存路径
|
||||
*/
|
||||
export const downloadMysImage = async (
|
||||
base,
|
||||
|
|
@ -38,6 +40,7 @@ export const downloadMysImage = async (
|
|||
* @param {keyof LocalURI} localBase 本地地址
|
||||
* @param {string} filename 文件名
|
||||
* @param {string} replaceFilename 替换文件名(如果资源不存在)
|
||||
* @returns {Promise<string | null>} 保存路径
|
||||
*/
|
||||
export const downloadResourceImage = async (
|
||||
remoteLabel,
|
||||
|
|
@ -62,6 +65,7 @@ export const downloadResourceImage = async (
|
|||
* @param {keyof HakushURL} base 远程地址
|
||||
* @param {keyof LocalURI} localBase 本地地址
|
||||
* @param {string} filename 文件名
|
||||
* @returns {Promise<object | null>} 文件内容(JSON)
|
||||
*/
|
||||
export const downloadHakushFile = async (base, localBase, filename = '') => {
|
||||
base = HakushURL[base];
|
||||
|
|
@ -71,5 +75,17 @@ export const downloadHakushFile = async (base, localBase, filename = '') => {
|
|||
if (filename) {
|
||||
url += `/${filename}`;
|
||||
}
|
||||
return checkFile(url, finalPath);
|
||||
const filepath = await checkFile(url, finalPath);
|
||||
if (filepath) {
|
||||
// 打开文件
|
||||
const file = fs.openSync(filepath, 'r');
|
||||
// 读取文件内容
|
||||
const content = fs.readFileSync(file);
|
||||
// 关闭文件
|
||||
fs.closeSync(file);
|
||||
// 返回文件内容
|
||||
return JSON.parse(content.toString());
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue