Skip to content

Commit

Permalink
Develop (#42)
Browse files Browse the repository at this point in the history
* Update test.vue

* update 支持群bot;优化插件排序;
  • Loading branch information
vivien8261 authored Jan 5, 2024
1 parent 46717b0 commit 2421edc
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 50 deletions.
64 changes: 42 additions & 22 deletions src/views/app/instance.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
</v-table>

<v-form-dialog title="编辑实例" :form="form" ref="dialog">
<el-form-item label="APP ID">
<el-input v-model="form.appid" placeholder="实例的 app id"/>
<el-form-item label="AppID">
<el-input v-model="form.appid" placeholder="机器人ID"/>
</el-form-item>
<el-form-item label="TOKEN">
<el-input v-model="form.token" placeholder="实例的 token"/>
<el-form-item label="Token">
<el-input v-model="form.token" placeholder="机器人令牌"/>
</el-form-item>
<el-form-item label="适配器类型">
<el-form-item label="适配器">
<el-select v-model="form.adapter">
<el-option :label="name" :value="item" v-for="(name, item) in adapterType" :key="item"/>
</el-select>
Expand All @@ -47,15 +47,27 @@
<el-form-item label="控制台群组ID" v-if="form.is_main">
<el-input v-model="form.console_channel" placeholder="控制实例的群组"/>
</el-form-item>
<template v-if="form.adapter === 'tencent'">
<el-divider content-position="left">QQ-Bot 配置</el-divider>
<template v-if="form.adapter === 'tencent' || form.adapter === 'qq_guild'">
<el-divider content-position="left">频道配置</el-divider>
<el-form-item label="属性">
<el-radio-group v-model="form.private">
<el-radio :label="0">公域</el-radio>
<el-radio :label="1">私域</el-radio>
</el-radio-group>
</el-form-item>
</template>
<template v-if="form.adapter === 'qq_group'">
<el-divider content-position="left">资源服务配置</el-divider>
<el-form-item label="AppSecret">
<el-input v-model="form.client_secret" placeholder="机器人密钥"/>
</el-form-item>
<el-form-item label="Host地址">
<el-input v-model="form.host" placeholder="资源服务的地址,默认为 0.0.0.0"/>
</el-form-item>
<el-form-item label="HTTP端口">
<el-input v-model="form.http_port" placeholder="资源服务的 HTTP 端口,默认为 8086"/>
</el-form-item>
</template>
<template v-if="serverAdapters.indexOf(form.adapter) >= 0">
<el-divider content-position="left">服务配置</el-divider>
<el-form-item label="Host地址">
Expand Down Expand Up @@ -117,7 +129,7 @@ import VFormDialog from '@/components/v-form-dialog.vue'
is_main: '可控实例',
console_channel: '控制台群组ID',
adapter: {
title: '适配器类型',
title: '适配器',
format: (row: any, value: any) => {
return this.adapterType[value]
}
Expand All @@ -130,7 +142,8 @@ export default class Instance extends Vue {
dialog!: VFormDialog
public adapterType = {
tencent: 'QQ频道机器人',
qq_guild: 'QQ频道机器人(官方)',
qq_group: 'QQ群机器人(官方)',
kook: 'KOOK机器人',
mirai_api_http: 'Mirai-api-http QQ群机器人',
cq_http: 'CQ-Http QQ群机器人',
Expand Down Expand Up @@ -165,12 +178,13 @@ export default class Instance extends Vue {
appid: '',
token: '',
private: 0,
adapter: 'tencent',
adapter: 'qq_guild',
is_main: 0,
is_start: 1,
host: '',
http_port: 0,
ws_port: 0
ws_port: 0,
client_secret: ''
}
this.formType = 'add'
this.dialog.show()
Expand Down Expand Up @@ -217,19 +231,25 @@ export default class Instance extends Vue {
</script>

<style lang="scss">
.instance-manage .status {
&:before {
content: '';
display: inline-block;
width: 10px;
height: 10px;
border-radius: 50%;
background: #67c23a;
margin-right: 5px;
.instance-manage {
.status {
&:before {
content: '';
display: inline-block;
width: 10px;
height: 10px;
border-radius: 50%;
background: #67c23a;
margin-right: 5px;
}
&.status-0:before {
background: #9e9e9e;
}
}
&.status-0:before {
background: #9e9e9e;
.el-select {
width: 100%;
}
}
</style>
51 changes: 23 additions & 28 deletions src/views/app/shop/shop.vue
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,6 @@ interface Authors {
[key: string]: Array<PluginItem>
}
interface AuthorsSort {
[key: string]: number
}
interface BatchInstallProcess {
percentage: number
status: { [key: string]: string }
Expand Down Expand Up @@ -331,7 +327,7 @@ export default class ShopCustom extends Vue {
installedPlugin[item.plugin_id] = item.version
}
}
const authorsSort: AuthorsSort = {}
const pluginsList: Array<PluginItem> = shop.data.filter((item: PluginItem) => {
item.installed = item.plugin_id in installedPlugin
item.upgrade = installedPlugin[item.plugin_id] ? item.version > installedPlugin[item.plugin_id] : false
Expand All @@ -343,35 +339,34 @@ export default class ShopCustom extends Vue {
if (item.higher) {
item.curr_version = installedPlugin[item.plugin_id] + ' << '
}
const author = item.plugin_info.author
const lastUpdate = new Date(item.upload_time).getTime()
if (author in authorsSort) {
if (lastUpdate > authorsSort[author]) {
authorsSort[author] = lastUpdate
}
} else {
authorsSort[author] = lastUpdate
}
return true
})
const authors: Authors = {}
const sorted = Object.keys(authorsSort).sort((a, b) => {
return authorsSort[b] - authorsSort[a]
})
for (const name of sorted) {
authors[name] = []
}
const plugins: Authors = {}
for (const item of pluginsList) {
authors[item.plugin_info.author].push(item)
if (!(item.plugin_info.author in plugins)) {
plugins[item.plugin_info.author] = []
}
plugins[item.plugin_info.author].push(item)
}
for (const key in plugins) {
plugins[key].sort((a, b) => new Date(b.upload_time).getTime() - new Date(a.upload_time).getTime())
}
const pluginArray = Object.entries(plugins).map(([name, arr]) => ({
name,
arr,
maxTime: new Date(arr[0].upload_time).getTime()
}))
pluginArray.sort((a, b) => b.maxTime - a.maxTime)
const sortedPlugins: Authors = {}
for (const item of pluginArray) {
sortedPlugins[item.name] = item.arr
}
this.pluginAuthors = authors
this.pluginShowList = Common.deepCopy(authors)
this.pluginAuthors = sortedPlugins
this.pluginShowList = Common.deepCopy(sortedPlugins)
}
}
Expand Down

0 comments on commit 2421edc

Please sign in to comment.