Skip to content

Commit

Permalink
fix(market): fix version select for bulk installation, fix #279
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Dec 26, 2023
1 parent 0d8f60c commit bc3c587
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
4 changes: 2 additions & 2 deletions plugins/market/client/components/confirm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
</div>
<div class="right">
<el-button @click="showConfirm = false">取消</el-button>
<el-button type="danger" @click="clear">丢弃</el-button>
<el-button type="primary" @click="confirm">确定</el-button>
<el-button type="danger" @click="clear">丢弃改动</el-button>
<el-button type="primary" @click="confirm">确认安装</el-button>
</div>
</template>
</el-dialog>
Expand Down
8 changes: 6 additions & 2 deletions plugins/market/client/components/dependencies.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@
<script lang="ts" setup>
import { computed, watch, WatchStopHandle } from 'vue'
import { store, useContext, mapValues } from '@koishijs/client'
import { store, useContext } from '@koishijs/client'
import { config, hasUpdate } from '../utils'
import { manualDeps } from './utils'
import ManualInstall from './manual.vue'
import PackageView from './package.vue'
import { compare } from 'semver'
const names = computed(() => {
return Object
Expand All @@ -61,7 +62,10 @@ watch(() => store.market?.registry, (registry) => {
if (store.dependencies[name]) return
const response = await fetch(`${registry}/${name}`)
const data = await response.json()
manualDeps[name] = mapValues(data.versions, () => ({ peers: {}, result: 'success' }))
manualDeps[name] = Object.fromEntries(Object
.entries(data.versions)
.map(([key]) => [key, { peers: {}, result: 'success' }] as const)
.sort(([a], [b]) => compare(b, a)))
})
}, { immediate: true })
}, { immediate: true })
Expand Down
9 changes: 5 additions & 4 deletions plugins/market/client/components/install.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
<p>正在加载版本数据……</p>
</div>

<k-comment v-if="store.dependencies?.[active] && !current" type="danger">
<p>该依赖的安装发生了错误,你可以尝试修复或移除它。</p>
</k-comment>
<p v-if="store.dependencies?.[active] && !current" class="danger">
该依赖的安装发生了错误,你可以尝试修复或移除它。
</p>

<el-scrollbar v-if="data?.[version] && Object.keys(data[version].peers).length">
<table>
Expand Down Expand Up @@ -75,6 +75,7 @@
</div>
</template>
</el-dialog>

<el-dialog v-model="confirmRemoveConfig" destroy-on-close>
检测到你正在卸载一个已配置的插件,是否同时删除其配置?
<template #footer>
Expand Down Expand Up @@ -162,7 +163,7 @@ const data = computed(() => {
const danger = computed(() => {
if (workspace.value) return
const deprecated = versions.value?.[version.value]?.deprecated
if (deprecated) return deprecated
if (deprecated) return '此版本已废弃:' + deprecated
if (store.market?.data[active.value]?.insecure) {
return '警告:从此插件的最新版本中检测出安全性问题。安装或升级此插件可能导致严重问题。'
}
Expand Down
5 changes: 2 additions & 3 deletions plugins/market/client/components/package.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
</td>

<td>
<template v-if="!local || local.invalid">暂不支持</template>
<el-button v-else-if="local.workspace || versions" @click="active = name">修改</el-button>
<template v-if="local?.invalid">暂不支持</template>
<el-button v-else-if="local?.workspace || data" @click="active = name">修改</el-button>
<template v-else>版本获取失败</template>
</td>
</tr>
Expand All @@ -44,7 +44,6 @@ const props = defineProps({
})
const local = computed(() => store.dependencies?.[props.name])
const versions = computed(() => store.registry?.[props.name])
const compare = computed(() => {
const result = hasUpdate(props.name)
Expand Down

0 comments on commit bc3c587

Please sign in to comment.