Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

求教:版本备份仓库vue怎么选择release版本 #32

Open
wants to merge 34 commits into
base: 2.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
ae3ce29
add functions
Harry-zklcdc Aug 26, 2019
61d4be2
fix bugs
Harry-zklcdc Aug 27, 2019
821d9dd
fix bugs
Harry-zklcdc Aug 27, 2019
f7d06cd
fix bugs
Harry-zklcdc Aug 27, 2019
e0044d1
fix bugs
Harry-zklcdc Aug 27, 2019
ef5d17f
fix bugs
Harry-zklcdc Aug 27, 2019
060a2b0
fix bugs
Harry-zklcdc Aug 27, 2019
cc78229
添加lnmp Docker镜像
Harry-zklcdc Sep 7, 2019
e7d453e
delete files
Harry-zklcdc Sep 7, 2019
f32041b
fix bugs
Harry-zklcdc Sep 7, 2019
0a54703
.
Sep 8, 2019
eed43b0
Add live2d-api; Fix some bugs
Sep 10, 2019
2bea0ba
Fix some bugs
Sep 10, 2019
c443dad
Fix some bugs
Sep 10, 2019
f1d3de7
Fix some bugs
Sep 10, 2019
f42ac86
Fix some bugs
Sep 10, 2019
ff6c9d0
fix bugs
Sep 10, 2019
01e30b3
update
Sep 10, 2019
f0030c4
添加model文件的添加说明
Harry-zklcdc Sep 12, 2019
c03c23f
添加model文件的添加说明
Harry-zklcdc Sep 12, 2019
2ac977b
添加model文件的添加说明
Harry-zklcdc Sep 12, 2019
cd71e10
update
Harry-zklcdc Sep 30, 2019
c9945c4
rm nginx.cong
Harry-zklcdc Sep 30, 2019
2b0488a
fix bugs
Harry-zklcdc Sep 30, 2019
892dc84
升级GCC和G++编译器
Harry-zklcdc Nov 14, 2019
374ee85
Update README.md
Harry-zklcdc Jan 22, 2020
a2154a6
[Fix] PHP7.4 Support Problem
Harry-zklcdc May 2, 2020
0390e23
[Fix] Reduce Live2d Memory Usage
Harry-zklcdc May 2, 2020
5d02043
[Fix] Live2d Nginx 502
Harry-zklcdc May 2, 2020
7f953b1
[Fix] JudgeServer Debug default off
Harry-zklcdc May 2, 2020
cef0502
[Fix] Tiny Docker Image Size
Harry-zklcdc May 3, 2020
ca33169
Merge branch '2.0' of https://github.com/Harry-zklcdc/OnlineJudgeDepl…
Harry-zklcdc May 3, 2020
0fae729
Update README.md
Harry-zklcdc Jul 8, 2020
7c64437
[Fix] Live2D Support CDN
Harry-zklcdc Aug 6, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
data/
!data/forum/api/live2d/model/readme.md
backup/
!backup/db_backup.sh
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

2. 安装 Docker

国内用户使用脚本一键安装: `sudo curl -sSL https://get.daocloud.io/docker | sh`
国内用户使用脚本一键安装: `sudo curl -sSL https://get.daocloud.io/docker | sh /dev/stdin --mirror Aliyun`
国外用户使用脚本一键安装: `sudo curl -sSL get.docker.com | sh`

详细步骤参照: [https://docs.docker.com/install/](https://docs.docker.com/install/)
Expand All @@ -35,7 +35,7 @@ Windows 下的安装仅供体验,勿在生产环境使用。如有必要,请
1. 请选择磁盘空间富余的位置,运行下面的命令

```bash
git clone -b 2.0 https://github.com/QingdaoU/OnlineJudgeDeploy.git && cd OnlineJudgeDeploy
git clone -b 2.0 https://github.com/Harry-zklcdc/OnlineJudgeDeploy.git && cd OnlineJudgeDeploy
```

2. 启动服务
Expand Down
2 changes: 2 additions & 0 deletions data/forum/api/live2d/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
model/
!model/readme.md
176 changes: 176 additions & 0 deletions data/forum/api/live2d/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
# Live2D API

Live2D 看板娘插件 (https://www.fghrsh.net/post/123.html) 上使用的后端 API

### 特性

- 原生 PHP 开发,无需伪静态,开箱即用
- 支持 模型、皮肤 的 顺序切换 和 随机切换
- 支持 单模型 单皮肤 切换、多组皮肤 递归穷举
- 支持 同分组 多个模型 或 多个路径 的 加载切换

## 使用

### 环境要求
- PHP 版本 >= 5.2
- 依赖 PHP 扩展:json

### 目录结构

```shell
│ model_list.json // 模型列表
├─model // 模型路径
│ └─GroupName // 模组分组
│ └─ModelName // 模型名称
├─add // 更新皮肤列表
├─get // 获取模型配置
├─rand // 随机切换模型
├─rand_textures // 随机切换皮肤
├─switch // 顺序切换模型
├─switch_textures // 顺序切换皮肤
└─tools
modelList.php // 列出模型列表
modelTextures.php // 列出皮肤列表
name-to-lower.php // 文件名格式化
```

### 添加模型

- 单模型 单皮肤 切换
- 单次加载只输出一个皮肤
- 皮肤放在 `textures` 文件夹,自动识别

```shell
│ index.json
│ model.moc
│ textures.cache // 皮肤列表缓存,自动生成
├─motions
│ idle_01.mtn
│ idle_02.mtn
│ idle_03.mtn
└─textures
default-costume.png
school-costume.png
winter-costume.png
```

- 单模型 多组皮肤 递归穷举
- 多组皮肤 组合模型、穷举组合
- 皮肤文件夹按 `texture_XX` 命名
- 添加 `textures_order.json` 列出组合
```shell
│ index.json
│ model.moc
│ textures.cache
│ textures_order.json
├─motions
│ idle_01.mtn
│ idle_02.mtn
│ idle_03.mtn
├─texture_00
│ 00.png
├─texture_01
│ 00.png
│ 01.png
│ 02.png
├─texture_02
│ 00.png
│ 01.png
│ 02.png
└─texture_03
00.png
01.png
```

textures_order.json

```json
[
["texture_00"],
["texture_01","texture_02"],
["texture_03"]
]
```

textures.cache

```json
[
["texture_00/00.png","texture_01/00.png","texture_02/00.png","texture_03/00.png"],
["texture_00/00.png","texture_01/00.png","texture_02/00.png","texture_03/01.png"],
["texture_00/00.png","texture_01/01.png","texture_02/01.png","texture_03/00.png"],
["texture_00/00.png","texture_01/01.png","texture_02/01.png","texture_03/01.png"],
["texture_00/00.png","texture_01/02.png","texture_02/02.png","texture_03/00.png"],
["texture_00/00.png","texture_01/02.png","texture_02/02.png","texture_03/01.png"]
]
```

- 同分组 多个模型 或 多个路径 切换
- 修改 `model_list.json` 添加多个模型

```shell
├─model
│ ├─Group1
│ │ ├─Model1
│ │ │ index.json
│ │ │
│ │ └─Model2
│ │ index.json
│ │
│ ├─Group2
│ │ └─Model1
│ │ index.json
│ │
│ └─GroupName
│ └─ModelName
│ │ index.json
│ │ model.moc
│ │
│ ├─motions
│ └─textures
```

model_list.json
```json
{
"models": [
"GroupName/ModelName",
[
"Group1/Model1",
"Group1/Model2",
"Group2/Model1"
]
],
"messages": [
"Example 1",
"Example 2"
]
}
```

### 接口用法
- `/add/` - 检测 新增皮肤 并更新 缓存列表
- `/get/?id=1-23` 获取 分组 1 的 第 23 号 皮肤
- `/rand/?id=1` 根据 上一分组 随机切换
- `/switch/?id=1` 根据 上一分组 顺序切换
- `/rand_textures/?id=1-23` 根据 上一皮肤 随机切换 同分组其他皮肤
- `/switch_textures/?id=1-23` 根据 上一皮肤 顺序切换 同分组其他皮肤

## 版权声明

> (>▽<) 都看到这了,点个 Star 吧 ~

**API 内所有模型 版权均属于原作者,仅供研究学习,不得用于商业用途**

MIT © FGHRSH
33 changes: 33 additions & 0 deletions data/forum/api/live2d/add/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

require '../tools/modelList.php';
require '../tools/modelTextures.php';

$modelList = new modelList();
$modelTextures = new modelTextures();

$modelList = $modelList->get_list();
$modelList = $modelList['models'];

foreach ($modelList as $modelName) {
if (!is_array($modelName) && file_exists('../model/'.$modelName.'/textures.cache')) {

$textures = $texturesNew = array();
$modelTexturesList = $modelTextures->get_list($modelName);
$modelNameTextures = $modelTextures->get_textures($modelName);
if (is_array($modelTexturesList)) foreach ($modelTexturesList['textures'] as $v) $textures[] = str_replace('\/', '/', json_encode($v));
if (is_array($modelNameTextures)) foreach ($modelNameTextures as $v) $texturesNew[] = str_replace('\/', '/', json_encode($v));

$texturesDiff = array_diff($texturesNew, $textures);
if (empty($textures)) continue; elseif (empty($texturesDiff)) {
echo '<p>'.$modelName.' / textures.cache / No Update.</p>';
} else {
foreach (array_values(array_unique(array_merge($textures, $texturesNew))) as $v) $texturesMerge[] = json_decode($v, 1);
file_put_contents('../model/'.$modelName.'/textures.cache', str_replace('\/', '/', json_encode($texturesMerge)));
echo '<p>'.$modelName.' / textures.cache / Updated.</p>';
}

}
elseif (is_array($modelName)) continue;
elseif ($modelTextures->get_list($modelName)) echo '<p>'.$modelName.' / textures.cache / Created.</p>';
}
65 changes: 65 additions & 0 deletions data/forum/api/live2d/get/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php
isset($_GET['id']) ? $id = $_GET['id'] : exit('error');

require '../tools/modelList.php';
require '../tools/modelTextures.php';
require '../tools/jsonCompatible.php';

$modelList = new modelList();
$modelTextures = new modelTextures();
$jsonCompatible = new jsonCompatible();

$STATIC_CDN_HOST = getenv('STATIC_CDN_HOST');
if ($STATIC_CDN_HOST) {
$URL = $STATIC_CDN_HOST.'/api/live2d';
} else {
$URL = '..';
}

$id = explode('-', $id);
$modelId = (int)$id[0];
$modelTexturesId = isset($id[1]) ? (int)$id[1] : 0;

$modelName = $modelList->id_to_name($modelId);

if (is_array($modelName)) {
$modelName = $modelTexturesId > 0 ? $modelName[$modelTexturesId-1] : $modelName[0];
$json = json_decode(file_get_contents('../model/'.$modelName.'/index.json'), 1);
} else {
$json = json_decode(file_get_contents('../model/'.$modelName.'/index.json'), 1);
if ($modelTexturesId > 0) {
$modelTexturesName = $modelTextures->get_name($modelName, $modelTexturesId);
if (isset($modelTexturesName)) $json['textures'] = is_array($modelTexturesName) ? $modelTexturesName : array($modelTexturesName);
}
}

$textures = json_encode($json['textures']);
$textures = str_replace('texture', $URL.'/model/'.$modelName.'/texture', $textures);
$textures = str_replace('moc', $URL.'/model/'.$modelName.'/moc', $textures);
$textures = json_decode($textures, 1);
$json['textures'] = $textures;

$json['model'] = $URL.'/model/'.$modelName.'/'.$json['model'];
if (isset($json['pose'])) $json['pose'] = $URL.'/model/'.$modelName.'/'.$json['pose'];
if (isset($json['physics'])) $json['physics'] = $URL.'/model/'.$modelName.'/'.$json['physics'];

if (isset($json['motions'])) {
$motions = json_encode($json['motions']);
$motions = str_replace('sounds', $URL.'/model/'.$modelName.'/sounds', $motions);
$motions = str_replace('snd\/', $URL.'/model/'.$modelName.'/snd/', $motions);
$motions = str_replace('motions', $URL.'/model/'.$modelName.'/motions', $motions);
$motions = str_replace('mtn\/', $URL.'/model/'.$modelName.'/mtn/', $motions);
$motions = json_decode($motions, 1);
$json['motions'] = $motions;
}

if (isset($json['expressions'])) {
$expressions = json_encode($json['expressions']);
$expressions = str_replace('expressions', $URL.'/model/'.$modelName.'/expressions', $expressions);
$expressions = str_replace('exp\/', $URL.'/model/'.$modelName.'/exp/', $expressions);
$expressions = json_decode($expressions, 1);
$json['expressions'] = $expressions;
}

header("Content-type: application/json");
echo $jsonCompatible->json_encode($json);
16 changes: 16 additions & 0 deletions data/forum/api/live2d/model/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
## 使用教程

1.拉取model模型数据

~~~bash
git clone https://github.com/Harry-zklcdc/live2d_models.git && cd live2d_models
#国内用户使用以下命令拉取model仓库数据
git clone https://gitee.com/zklcdc/live2d_models.git && cd live2d_models
~~~

2.将 live2d_models 文件夹下的所有文件复制到此文件夹

3.将 model_list.json 复制到上级文件夹

4.大功告成,开始食用吧

Loading