Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
starsw001
ShopXO
提交
9b74beec
ShopXO
项目概览
starsw001
/
ShopXO
与 Fork 源项目一致
Fork自
纵之格 / ShopXO
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
ShopXO
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
9b74beec
编写于
8月 10, 2021
作者:
D
Devil
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
小程序主题上传优化
上级
9d73dde2
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
76 addition
and
15 deletion
+76
-15
app/admin/view/default/appmini/upload.html
app/admin/view/default/appmini/upload.html
+8
-6
app/service/AppMiniService.php
app/service/AppMiniService.php
+68
-9
未找到文件。
app/admin/view/default/appmini/upload.html
浏览文件 @
9b74beec
...
...
@@ -12,12 +12,14 @@
<!-- form start -->
<form
class=
"am-form form-validation view-save am-margin-top-sm"
action=
"{{:MyUrl('admin/appmini/themeupload')}}"
method=
"POST"
request-type=
"ajax-url"
request-value=
"{{:MyUrl('admin/appmini/index', ['nav_type'=>$nav_type])}}"
enctype=
"multipart/form-data"
>
<div
class=
"am-form-group am-form-group-refreshing am-margin-bottom-0 am-form-file"
>
<button
type=
"button"
class=
"am-btn am-btn-default am-btn-sm am-radius"
>
<i
class=
"am-icon-cloud-upload"
></i>
选择文件
</button>
<input
type=
"file"
name=
"theme"
class=
"file-event"
data-tips-tag=
"#form-theme-tips"
data-validation-message=
"请选择需要上传的文件"
accept=
".zip"
required
/>
<span
class=
"tips am-text-xs"
>
上传一个zip压缩格式的主题安装包
</span>
<div
id=
"form-theme-tips"
class=
"am-margin-top-xs"
></div>
<div
class=
"am-form-group am-form-group-refreshing am-margin-bottom-0"
>
<div
class=
"am-form-file"
>
<button
type=
"button"
class=
"am-btn am-btn-default am-btn-sm am-radius"
>
<i
class=
"am-icon-cloud-upload"
></i>
选择文件
</button>
<input
type=
"file"
name=
"theme"
class=
"file-event"
data-tips-tag=
"#form-theme-tips"
data-validation-message=
"请选择需要上传的文件"
accept=
".zip"
required
/>
<span
class=
"tips am-text-xs"
>
上传一个zip压缩格式的主题安装包
</span>
<div
id=
"form-theme-tips"
class=
"am-margin-top-xs"
></div>
</div>
</div>
<div
class=
"am-form-group am-form-group-refreshing"
>
<input
type=
"hidden"
name=
"nav_type"
value=
"{{$nav_type}}"
/>
...
...
app/service/AppMiniService.php
浏览文件 @
9b74beec
...
...
@@ -33,6 +33,9 @@ class AppMiniService
// 当前默认主题
public
static
$default_theme
;
// 排除的文件后缀
private
static
$exclude_ext
=
[
'php'
];
/**
* @author Devil
* @blog http://gong.gg/
...
...
@@ -46,6 +49,12 @@ class AppMiniService
// 当前小程序包名称
self
::
$application_name
=
isset
(
$params
[
'application_name'
])
?
$params
[
'application_name'
]
:
'weixin'
;
// 小程序类型校验
if
(
!
array_key_exists
(
self
::
$application_name
,
lang
(
'common_appmini_type'
)))
{
return
DataReturn
(
'小程序类型有误['
.
self
::
$application_name
.
']'
,
-
1
);
}
// 原包地址/操作地址
self
::
$old_root
=
ROOT
.
'sourcecode'
;
self
::
$new_root
=
ROOT
.
'public'
.
DS
.
'download'
.
DS
.
'sourcecode'
;
...
...
@@ -54,6 +63,8 @@ class AppMiniService
// 默认主题
self
::
$default_theme
=
self
::
DefaultTheme
();
return
DataReturn
(
'success'
,
0
);
}
/**
...
...
@@ -84,7 +95,12 @@ class AppMiniService
if
(
empty
(
self
::
$application_name
))
{
// 初始化
self
::
Init
(
$params
);
$ret
=
self
::
Init
(
$params
);
if
(
$ret
[
'code'
]
!=
0
)
{
// 如果类型错误则使用 weixin 作为默认
self
::
$application_name
=
'weixin'
;
}
}
return
'common_app_mini_'
.
self
::
$application_name
.
'_default_theme'
;
...
...
@@ -102,7 +118,11 @@ class AppMiniService
public
static
function
ThemeList
(
$params
=
[])
{
// 初始化
self
::
Init
(
$params
);
$ret
=
self
::
Init
(
$params
);
if
(
$ret
[
'code'
]
!=
0
)
{
return
[];
}
// 读取目录
$result
=
[];
...
...
@@ -192,7 +212,11 @@ class AppMiniService
public
static
function
ThemeUploadHandle
(
$package_file
,
$params
=
[])
{
// 初始化
self
::
Init
(
$params
);
$ret
=
self
::
Init
(
$params
);
if
(
$ret
[
'code'
]
!=
0
)
{
return
$ret
;
}
// 主题目录
$dir
=
self
::
$old_path
.
DS
;
...
...
@@ -218,6 +242,17 @@ class AppMiniService
continue
;
}
// 排除后缀文件
$pos
=
strripos
(
$file
,
'.'
);
if
(
$pos
!==
false
)
{
$info
=
pathinfo
(
$file
);
if
(
isset
(
$info
[
'extension'
])
&&
in_array
(
$info
[
'extension'
],
self
::
$exclude_ext
))
{
continue
;
}
}
// 截取文件路径
$file_path
=
$dir
.
substr
(
$file
,
0
,
strrpos
(
$file
,
'/'
));
...
...
@@ -268,7 +303,11 @@ class AppMiniService
}
// 初始化
self
::
Init
(
$params
);
$ret
=
self
::
Init
(
$params
);
if
(
$ret
[
'code'
]
!=
0
)
{
return
$ret
;
}
// 防止路径回溯
$id
=
htmlentities
(
str_replace
(
array
(
'.'
,
'/'
,
'\\'
,
':'
),
''
,
strip_tags
(
$params
[
'id'
])));
...
...
@@ -323,7 +362,11 @@ class AppMiniService
}
// 初始化
self
::
Init
(
$params
);
$ret
=
self
::
Init
(
$params
);
if
(
$ret
[
'code'
]
!=
0
)
{
return
$ret
;
}
// 是否开启开发者模式
if
(
MyConfig
(
'shopxo.is_develop'
)
!==
true
)
...
...
@@ -401,7 +444,11 @@ class AppMiniService
public
static
function
MiniThemeConfig
(
$theme
,
$params
)
{
// 初始化
self
::
Init
(
$params
);
$ret
=
self
::
Init
(
$params
);
if
(
$ret
[
'code'
]
!=
0
)
{
return
$ret
;
}
// 获取配置信息
$config_file
=
self
::
$old_path
.
DS
.
$theme
.
DS
.
'config.json'
;
...
...
@@ -428,7 +475,11 @@ class AppMiniService
public
static
function
DownloadDataList
(
$params
=
[])
{
// 初始化
self
::
Init
(
$params
);
$ret
=
self
::
Init
(
$params
);
if
(
$ret
[
'code'
]
!=
0
)
{
return
$ret
;
}
// 获取包列表
$result
=
[];
...
...
@@ -477,7 +528,11 @@ class AppMiniService
}
// 初始化
self
::
Init
(
$params
);
$ret
=
self
::
Init
(
$params
);
if
(
$ret
[
'code'
]
!=
0
)
{
return
$ret
;
}
// 配置内容
$title
=
MyC
(
'common_app_mini_'
.
self
::
$application_name
.
'_title'
);
...
...
@@ -708,7 +763,11 @@ class AppMiniService
}
// 初始化
self
::
Init
(
$params
);
$ret
=
self
::
Init
(
$params
);
if
(
$ret
[
'code'
]
!=
0
)
{
return
$ret
;
}
// 循环操作
$sucs
=
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录