Skip to content

Commit

Permalink
fix(appstore): 修复、优化应用商店一些bug和使用体验
Browse files Browse the repository at this point in the history
  • Loading branch information
kanyxmo committed Nov 14, 2024
1 parent 2589a7d commit 959fd83
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 26 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ vendor/
.phpunit*
*.cache
.vscode/
storage/swagger/http.json
tests/cover
tests/coverage.xml
tests/coding_standard.xml
Expand Down
2 changes: 1 addition & 1 deletion config/autoload/mine-extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
*
* 前端包管理执行工具 可选 npm yarn pnpm,默认使用 npm
*/
'type' => 'yarn',
'type' => 'pnpm',
/*
* The default directory for executing programs is npm,
* but if you don't have the npm environment variable configured,
Expand Down
2 changes: 1 addition & 1 deletion config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
return [
'app_name' => env('APP_NAME', 'MineAdmin'),
'scan_cacheable' => ! env('APP_DEBUG', false),
'debug' => env('APP_DEBUG', false),
'debug' => env('APP_DEBUG', true),
StdoutLoggerInterface::class => [
'log_level' => [
LogLevel::ALERT,
Expand Down
4 changes: 2 additions & 2 deletions plugin/mine-admin/app-store/mine.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "mine-admin/app-store",
"description": "MineAdmin 应用商店可视化管理插件",
"version": "1.0",
"version": "1.0.0",
"author": [
{
"name": "mineadmin"
"name": "MineAdmin"
}
],
"package": {
Expand Down
30 changes: 17 additions & 13 deletions plugin/mine-admin/app-store/src/Service/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use App\Exception\BusinessException;
use App\Http\Common\ResultCode;
use Hyperf\HttpMessage\Upload\UploadedFile;
use Mine\AppStore\Exception\PluginNotFoundException;
use Mine\AppStore\Plugin;
use Mine\AppStore\Service\Impl\AppStoreServiceImpl;
use Psr\Container\ContainerExceptionInterface;
Expand All @@ -24,14 +25,14 @@ class Service
{
public function download(array $params): bool
{
if (empty($params['space']) || empty($params['identifier']) || empty($params['version'])) {
if (empty($params['identifier']) || empty($params['version'])) {
$this->throwParamsFail();
}

$service = make(AppStoreServiceImpl::class);

if (! is_dir(BASE_PATH . '/plugin/' . $params['space'] . '/' . $params['identifier'])) {
$result = $service->download($params['space'], $params['identifier'], $params['version']);
if (! is_dir(BASE_PATH . '/plugin/' . $params['identifier'])) {
$result = $service->download($params['identifier'], $params['version']);
if (! $result) {
$this->throwDownloadFail();
}
Expand All @@ -41,25 +42,24 @@ public function download(array $params): bool
}

/**
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
* @param array $params
* @return bool
*/
public function install(array $params): bool
{
if (empty($params['space']) || empty($params['identifier']) || empty($params['version'])) {
if (empty($params['identifier']) || empty($params['version'])) {
$this->throwParamsFail();
}

$path = BASE_PATH . '/plugin/' . $params['space'] . '/' . $params['identifier'];
$path = BASE_PATH . '/plugin/' . $params['identifier'];

if (file_exists($path . '/install.lock')) {
$this->throwAppInstalled();
}

$pluginName = $params['space'] . '/' . $params['identifier'];
try {
Plugin::forceRefreshJsonPath();
Plugin::install($pluginName);
Plugin::install($params['identifier']);
} catch (\RuntimeException $e) {
throw new \RuntimeException($e->getMessage());
}
Expand All @@ -69,26 +69,28 @@ public function install(array $params): bool

public function unInstall(array $params): bool
{
if (empty($params['space']) || empty($params['identifier']) || empty($params['version'])) {
if (empty($params['identifier']) || empty($params['version'])) {
$this->throwParamsFail();
}

$path = BASE_PATH . '/plugin/' . $params['space'] . '/' . $params['identifier'];
$path = BASE_PATH . '/plugin/' . $params['identifier'];

if (! file_exists($path . '/install.lock')) {
$this->throwAppNoInstall();
}

$pluginName = $params['space'] . '/' . $params['identifier'];
try {
Plugin::forceRefreshJsonPath();
Plugin::uninstall($pluginName);
Plugin::uninstall($params['identifier']);
} catch (\RuntimeException $e) {
throw new \RuntimeException($e->getMessage());
}
return true;
}

/**
* @throws PluginNotFoundException
*/
public function getLocalAppInstallList(): array
{
$list = Plugin::getPluginJsonPaths();
Expand All @@ -100,6 +102,8 @@ public function getLocalAppInstallList(): array
$items[$info['name']] = [
'status' => $info['status'],
'version' => $info['version'],
'description' => $info['description'],
'author' => $info['author'],
];
}
}
Expand Down
2 changes: 1 addition & 1 deletion storage/swagger/http.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion web/src/plugins/mine-admin/app-store/api/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ export function getDetail(params: Record<string, string>) {
export function download(data: any) {
return http.post(
'/admin/plugin/store/download',
data,
{
timeout: 500000,
data,
},
)
}
Expand Down
8 changes: 6 additions & 2 deletions web/src/plugins/mine-admin/app-store/views/detail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,12 @@ defineExpose({ open })
indicator-type="line"
show-arrow="hover"
>
<el-carousel-item v-for="image in data?.app?.homepage" :key="image">
<el-image :src="image" fit="cover" />
<el-carousel-item v-for="(image, idx) in data?.app?.homepage" :key="idx">
<el-image
:src="image"
fit="contain"
class="h-full w-full"
/>
</el-carousel-item>
</el-carousel>
<el-space class="mt-2">
Expand Down
2 changes: 1 addition & 1 deletion web/src/plugins/mine-admin/app-store/views/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const filterParams = ref<Record<string, any>>({
tag: undefined,
})
function requestAppList(params = { page: 1, size: 9999 }) {
function requestAppList(params = { page: 1, size: 9999, created_at_desc: true }) {
const requestParams = Object.assign(filterParams.value, params)
storeMeta.value.loading = true
getAppList(requestParams).then((res: any) => {
Expand Down
16 changes: 12 additions & 4 deletions web/src/plugins/mine-admin/app-store/views/localList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@ en:
pluginNotExists: 'Plugin to install:%{name} Does not exist'
</i18n>

<script setup lang="ts">
<script setup lang="tsx">
import type { MaTableExpose } from '@mineadmin/table'
const tableRef = ref<MaTableExpose>()
const storeMeta = inject('storeMeta') as Record<string, any>
const dataList = inject('dataList') as Record<string, any>
nextTick(() => {
Expand All @@ -29,13 +28,22 @@ nextTick(() => {
name,
status: dataList.value.local[name].status,
version: dataList.value.local[name].version,
description: dataList.value.local[name].description,
author: dataList.value.local[name].author,
}
})
tableRef.value?.setData(data)
tableRef.value?.setColumns([
{ label: '名称', prop: 'name', width: '300px', headerAlign: 'left', align: 'left' },
{ label: '状态', prop: 'status' },
{ label: '名称', prop: 'name' },
{ label: '版本', prop: 'version' },
{ label: '描述', prop: 'description' },
{ label: '作者', prop: 'author', cellRender: ({ row }) => row.author.map((item: any) => item.name).join(',') },
{ label: '状态', prop: 'status', cellRender: ({ row }) => (
<el-tag type={row.status === true ? 'success' : 'error'}>
{row.status === true ? '已安装' : '未安装' }
</el-tag>
),
},
])
})
</script>
Expand Down

0 comments on commit 959fd83

Please sign in to comment.