Skip to content

Commit

Permalink
v1.3.5
Browse files Browse the repository at this point in the history
  • Loading branch information
friend-nicen committed Oct 12, 2022
1 parent 1bb96eb commit be91df4
Show file tree
Hide file tree
Showing 7 changed files with 334 additions and 289 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: nicen-localize-image
Plugin URI:https://nicen.cn/2893.html
Description: 用于本地化文章的外部图片的插件,支持文章发布前通过编辑器插件本地化、文章发布时自动本地化、定时发布文章时自动本地化、已发布的文章批量本地化。
Version: 1.3.4
Version: 1.3.5
Author: 友人a丶
Author URI: https://nicen.cn
Text Domain: nicen-localize-image
Expand All @@ -22,6 +22,11 @@ nicen-localize-image,是一款用于本地化文章的外部图片的插件,

# 更新日志:

## v1.3.5

1. 修复插件日志无法清空的问题
2. 更新图片压缩页面加载目录时异步加载,避免文件数量太多导致卡死;

## v1.3.4

1. 修复不规范的img标签,不会被匹配到的问题。
Expand Down
3 changes: 2 additions & 1 deletion admin/render.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,14 @@ function Nicen_form_compress()
echo '<a-space>
<a-button type="primary" :loading="tree.loading" @click="compress">{{tree.loading?"正在压缩第"+tree.count+"张图片,点击取消压缩...":"开始压缩"}}</a-button>
<a-button type="primary" v-if="tree.loading" @click="compress">取消压缩</a-button>
<a-button type="primary" @click="loadFiles">加载图片目录</a-button>
<a-button type="primary" @click="loadFiles()">加载图片目录</a-button>
</a-space>';
echo '</a-form-item>';

echo "<a-form-item label='选择指定文件或目录'>
<a-tree
checkable
:load-data='loadFiles'
v-model='tree.selected'
:tree-data='tree.data'
>
Expand Down
65 changes: 49 additions & 16 deletions assets/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -663,29 +663,62 @@ jQuery(function () {

},

loadFiles() {
loadFiles(TreeNode = null) {


let that = this;

load.loading('正在加载文件目录...');
axios.get(
`/?nicen_make_files=1&private=${that.data.nicen_make_plugin_private}&timestamp=${(new Date()).getTime()}`)
.then((res) => {
if (res.data.code) {
load.success(res.data.errMsg);
that.tree.data = that.decode(res.data.data);
} else {
load.error(res.data.errMsg);
}
}).catch((e) => {
load.error(e.message)
}).finally(() => {
load.loaded();
})
/*
* 获取请求的路径
* */
if (TreeNode === null) {
var path = '/wp-content/uploads';
} else {

if (TreeNode.dataRef.children) {
resolve();
return;
} else {
var path = TreeNode.dataRef.key;
}
}


return new Promise(resolve => {

load.loading('正在加载文件目录...');

axios.post(
`/?nicen_make_files=1&private=${that.data.nicen_make_plugin_private}&timestamp=${(new Date()).getTime()}`, {
path: path
})
.then((res) => {
if (res.data.code) {
load.success(res.data.errMsg);

if (TreeNode === null) {
that.tree.data = that.decode(res.data.data);
resolve();
} else {
TreeNode.dataRef.children =that.decode(res.data.data);
that.tree.data = [...that.tree.data];
resolve();
}

} else {
load.error(res.data.errMsg);
}
}).catch((e) => {
load.error(e.message)
}).finally(() => {
load.loaded();
})
});
}
},
created() {
let that = this;
/*同步插件更新日志*/
axios.get("https://weixin.nicen.cn/api/update")
.then((res) => {
if (res.data.code) {
Expand Down
19 changes: 7 additions & 12 deletions class/compress.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,10 @@ public function readDirs( $path ) {

} else {

/*读取文件*/
$children = $this->readDirs( $path . '/' . $file );

if ( ! empty( $children ) ) {
$list[] = [
"title" => base64_encode( $file ),
"key" => base64_encode( $path . '/' . $file ),
"children" => $children
];
}
$list[] = [
"title" => base64_encode( $file ),
"key" => base64_encode( $path . '/' . $file )
];

}

Expand Down Expand Up @@ -114,7 +108,7 @@ function get( $url ) {
$res = wp_remote_get( $url, [
'headers' => $headers,
'sslverify' => false,
'timeout' => 120,
'timeout' => 120,
] );

return wp_remote_retrieve_body( $res );
Expand Down Expand Up @@ -147,14 +141,15 @@ function post( $file ) {
'method' => 'POST',
'sslverify' => false,
'body' => $post_data,
'timeout' => 120,
'timeout' => 120,
'httpversion' => '1.1'
);

$res = $Http->request( 'http://api.resmush.it/ws.php', $args );

if ( is_wp_error( $res ) ) {
$errors = $res->get_error_messages();

return $errors;
}

Expand Down
2 changes: 1 addition & 1 deletion nicen-localize-image.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: nicen-localize-image
* Plugin URI:https://nicen.cn/2893.html
* Description: 用于本地化文章的外部图片的插件,支持文章发布前通过编辑器插件本地化、文章发布时自动本地化、定时发布文章时自动本地化、已发布的文章批量本地化。
* Version: 1.3.4
* Version: 1.3.5
* Author: 友人a丶
* Author URI: https://nicen.cn
* Text Domain: nicen-localize-image
Expand Down
8 changes: 7 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Donate link: https://nicen.cn/donate
Requires at least: 5.6
Tested up to: 6.0.1
Requires PHP: 7.3
Stable tag: 1.3.4
Stable tag: 1.3.5
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Expand All @@ -28,6 +28,12 @@ Gitee:https://gitee.com/friend-nicen/nicen-localize-image

== Changelog ==


v1.3.5

1. 修复插件日志无法清空的问题
2. 更新图片压缩页面加载目录时异步加载,避免文件数量太多导致卡死;

v1.3.4

1. 修复不规范的img标签,不会被匹配到的问题。
Expand Down
Loading

0 comments on commit be91df4

Please sign in to comment.