Skip to content

Commit

Permalink
fix: 添加插件失效, 更新一言 API 接口, 更新文档
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-light committed Jan 17, 2025
1 parent 2fb8a73 commit b06958e
Show file tree
Hide file tree
Showing 20 changed files with 320 additions and 43 deletions.
115 changes: 115 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
这个项目的所有显著变化都将记录在这个文件中。请参阅[约定式提交](https://www.conventionalcommits.org/zh-hans/v1.0.0/)了解提交指南。

## 1.0.7-rc.1

### 🐛 修复

+ 添加插件失效
+ 更新一言 API 接口
+ 更新文档

## 1.0.7

### ✨ 功能

+ 添加返回首页的功能
+ 添加插件导出

### 🐛 修复

+ 在模型数量为 1 时切换不会出现加载元素

### 📌 测试

+ 添加 FHomePlugin 插件测试
+ 修改 FBaseSwitchPlugin 插件测试

## 1.0.6

### ✨ 功能

+ 添加自定义 talk api 处理

### 🐛 修复

+ 在创建 app 之前将元素添加到文档中, 这样在加载模型时出现贴图确实的概率就会变小

### 📌 测试

+ 添加复现测试
+ 修改 talk 插件测试

### 📑 文档

+ 修改文档, 添加 gif 图片

## 1.0.5

### 🐛 修复

+ 重构 models 类型名称
+ 重构 jsodc 注释
+ 修复 test 代码

## v1.0.4

### ✨ 功能

+ 添加 copy event message
+ 添加 control open message
+ 添加 visibility change message
+ 添加 tutorials 教程
+ 切换模型时显示加载提示

### 🐛 修复

+ 修复拖拽后切换模型后的位置问题
+ 根据优先级执行插件
+ 修改FHelp.random的参数顺序

### 📌 测试

+ 添加c copy message plugin 测试
+ 添加c onsole message plugin 测试
+ 添加c visibility message plugin 测试

## 1.0.3

### ✨ 功能

+ 添加模型的motion消息

### 📌 测试

+ 添加 motion plugin 测试

### 🐛 修复

+ 将 Tips 的样式更改为 min-类型

## 1.0.2

### ✨ 功能

+ 添加 tips 拖拽

### 🐛 修复

+ 修复class样式添加方式
+ 修复Model中的event监听

### 1.0.1

#### 🐛 修复

+ 修复在没有message时循环显示的问题

## 1.0.0

### ✨ 功能

+ 切换服装
+ 切换模型
+ 捕获l看板娘图片
+ 开启和关闭看板娘
+ 拖拽看板娘
8 changes: 8 additions & 0 deletions docs/tutorials/update-log.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
这个项目的所有显著变化都将记录在这个文件中。请参阅[约定式提交](https://www.conventionalcommits.org/zh-hans/v1.0.0/)了解提交指南。

## 1.0.7-rc.1

### 🐛 修复

+ 添加插件失效
+ 更新一言 API 接口
+ 更新文档

## 1.0.7

### ✨ 功能
Expand Down
4 changes: 2 additions & 2 deletions lib/controller/live2d.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,12 @@ export class ULive2dController {
names[current.name] = current.name;
return names;
}, {});
// 筛选出有效插件,并且按照优先级从高到低排列及执行
// 筛选出有效插件,并且按照优先级从高到低排列及执行, 如果插件的名称已经存在则跳过, 该插件将由用户自己实现
plugins = plugins.filter(plugin => FHelp.is(FBasePlugin, plugin) && !names[plugin.name])
.sort((prev, next) => next.priority - prev.priority);
this.plugins.push(...plugins);
this.plugins.sort((prev, next) => next.priority - prev.priority);
for (const plugin of plugins) {
for (const plugin of this.plugins) {
plugin.install(this);
}
}
Expand Down
4 changes: 4 additions & 0 deletions lib/controller/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ export class UModelController extends UBaseController {

/**
* 加载与 modelId 及 textureId 对应的模型
*
* modelId 指 {@link TModels} 的第一维的数组索引
*
* textureId 指 {@link TModels} 的第二维的数组索引, 并且存在于 modelId 对应的一维数组内
* @summary 加载模型
* @param {number} modelId 模型索引
* @param {number} [textureId=0] 模型服装索引
Expand Down
18 changes: 9 additions & 9 deletions lib/controller/stage.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@ export class UStageController extends UBaseController {
*/
constructor(live2d, selector = null, data = null) {
super(live2d);
data = FHelp.mergeAll(
data ?? {},
{ parent: this.getParentFromSelector(selector) }
);
data = FHelp.mergeAll(data ?? {}, { parent: this.getParentFromSelector(selector) });
this._data = new DStage(data);
this._menuItems = [];
// 监听事件
Expand Down Expand Up @@ -341,15 +338,18 @@ export class UStageController extends UBaseController {
getParentFromSelector(selector = null) {
let parent;
try {
parent = document.querySelector(selector);
}
catch (_) {
try {
parent = document.evaluate(selector, document).iterateNext();
parent = document.querySelector(selector);
}
catch (_) {}
if (!parent) {
parent = document.evaluate(selector, document).iterateNext();
}
return parent ?? document.body;
}
catch (_) {
return document.body;
}
return parent ?? document.body;
}

/**
Expand Down
3 changes: 2 additions & 1 deletion lib/index.cubism2.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ PIXI.utils.skipHello();

export default wlLive2d;
export { wlLive2d };
export { FBasePlugin } from './plugins';
export * from './plugins';
export * from './models';
3 changes: 2 additions & 1 deletion lib/index.cubism4.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ window.wlLive2d = wlLive2d;

export default wlLive2d;
export { wlLive2d };
export { FBasePlugin } from './plugins';
export * from './plugins';
export * from './models';
3 changes: 2 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,5 @@ window.wlLive2d = wlLive2d;

export default wlLive2d;
export { wlLive2d };
export { FBasePlugin } from './plugins';
export * from './plugins';
export * from './models';
25 changes: 23 additions & 2 deletions lib/models/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@

/**
* 模型数据项目可以为 DModel 或者 DModel[]
*
* DModel 指模型, 用于切换模型按钮
*
* DModel[] 指同一模型的不同服饰, 用于切换服装按钮
* @summary 模型项目
* @typedef {DModel | Array<DModel>} TModelItem
* @global
Expand All @@ -42,8 +46,15 @@
* @global
* @example
* [
* [new DModel, new DModel],
* new DModel,
* // 使用不同的模型
* new DModel,
* new DModel,
* new DModel,
* [ // 同一个模型的不同服装
* new DModel,
* new DModel,
* new DModel,
* ],
* ]
*/

Expand All @@ -64,6 +75,16 @@
* @property {TTalkHandle} handle 处理函数
* @property {RequestInit | undefined} init fetch 初始化数据
* @global
* @example
* // 数据
* const api = {
* url: 'https://v1.hitokoto.cn/',
* handle: async (res) => (await res.json()).hitokoto
* }
*
* // 处理
* const response = await fetch(api.url, api.init);
* const text = await api.handle(response);
*/

export * from './message.js';
Expand Down
10 changes: 8 additions & 2 deletions lib/models/message.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import { FHelp } from '../utils/index.js';
*/
export class DMessage {
/**
* 条件函数, 模组条件时显示消息, 不满足时不显示消息
* 条件函数, 满足条件时显示消息, 不满足时不显示消息
*
* 消息从 `condition() == true` 中的集合中选取
* @summary 条件函数
* @type {?TBoolCallback}
* @default FHelp.T
Expand All @@ -22,6 +24,8 @@ export class DMessage {

/**
* 在提示框中显示的消息文本, 可以是 string 也可以是 string[]
*
* 是数组的话将会从其中随机选取
* @summary 消息文本
* @type {string|string[]}
* @default ''
Expand All @@ -38,6 +42,8 @@ export class DMessage {

/**
* 消息的类型, 例如: hour, date, event 等等
*
* 也可以自定义类型用于自定义插件
* @summary 消息类型
* @type {?string}
* @default null
Expand All @@ -47,7 +53,7 @@ export class DMessage {
/**
* 创建消息数据实例
* @summary 消息数据构造
* @constructor
* @hideconstructor
* @param {DMessage | null} [data=null] 消息数据
*/
constructor(data = null) {
Expand Down
9 changes: 8 additions & 1 deletion lib/models/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ export class DModel {
* @summary url 地址
* @type {string}
* @default ''
* @example
* // 绝对路径
* https://fastly.jsdelivr.net/gh/Eikanya/Live2d-model/%E5%B4%A9%E5%9D%8F%E5%AD%A6%E5%9B%AD2/yiselin/model.json
*
* // 相对路径
* // 假设你的主机URL为https://fastly.jsdelivr.net, 那么相对路径如下
* /gh/Eikanya/Live2d-model/%E5%B4%A9%E5%9D%8F%E5%AD%A6%E5%9B%AD2/yiselin/model.json
*/
path;

Expand Down Expand Up @@ -67,7 +74,7 @@ export class DModel {
/**
* 创建模型数据实例
* @summary 模型数据构造
* @constructor
* @hideconstructor
* @param {DModel | null} [data=null] 模型数据
*/
constructor(data = null) {
Expand Down
Loading

0 comments on commit b06958e

Please sign in to comment.