build(desktop): 升级 electron-shell 版本至 1.6.3 并调整插件执行超时配置
- 插件执行超时默认延长至 6 小时,支持插件单独配置超时时间 - 新增插件根目录迁移逻辑,解决旧版权限问题 - 新增多个服务端实体、DTO、配置模块等基础代码 - 新增插件 UI 模板及相关静态资源
This commit is contained in:
@@ -0,0 +1,107 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* 权限授权(37du 控制台)
|
||||
* 账号 × 插件授权(can_download / can_run)+ 平台白名单(对接 /api/admin/grant_data、account_grants、account_plugins、account_platforms)
|
||||
*/
|
||||
import { onMounted, reactive, ref } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { fetchGrantData, fetchAccountGrants, grantPlugin, grantPlatform } from '@/api/business'
|
||||
|
||||
const loading = ref(false)
|
||||
const plugins = ref<any[]>([])
|
||||
const accounts = ref<any[]>([])
|
||||
const account = ref('')
|
||||
const grants = reactive<Record<string, { canRun: boolean; canDownload: boolean }>>({})
|
||||
const platforms = ref<string[]>([])
|
||||
const platformOptions = ['hr', 'oa']
|
||||
|
||||
async function loadData() {
|
||||
loading.value = true
|
||||
try {
|
||||
const d = await fetchGrantData()
|
||||
plugins.value = d.plugins || []
|
||||
accounts.value = d.accounts || []
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function selectAccount(acc: string) {
|
||||
account.value = acc
|
||||
if (!acc) return
|
||||
const g = await fetchAccountGrants(acc)
|
||||
const map: Record<string, { canRun: boolean; canDownload: boolean }> = {}
|
||||
for (const p of g.plugins || []) {
|
||||
map[p.plugin_id] = { canRun: !!p.canRun, canDownload: !!p.canDownload }
|
||||
}
|
||||
for (const p of plugins.value) {
|
||||
if (!map[p.id]) map[p.id] = { canRun: false, canDownload: false }
|
||||
}
|
||||
Object.assign(grants, map)
|
||||
platforms.value = g.platforms || []
|
||||
}
|
||||
|
||||
async function toggleGrant(pid: string, field: 'canRun' | 'canDownload', val: boolean) {
|
||||
if (!account.value) return
|
||||
await grantPlugin({
|
||||
account: account.value, plugin_id: pid, granted: true,
|
||||
can_download: field === 'canDownload' ? val : grants[pid]?.canDownload,
|
||||
can_run: field === 'canRun' ? val : grants[pid]?.canRun
|
||||
})
|
||||
ElMessage.success('已保存')
|
||||
}
|
||||
|
||||
async function togglePlatform(pid: string, val: boolean) {
|
||||
if (!account.value) return
|
||||
await grantPlatform({ account: account.value, platform_id: pid, granted: val })
|
||||
ElMessage.success(val ? '已授权平台' : '已撤销平台')
|
||||
}
|
||||
|
||||
onMounted(loadData)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="p-5 space-y-4">
|
||||
<div class="flex items-center justify-between">
|
||||
<h2 class="text-lg font-bold">权限授权</h2>
|
||||
</div>
|
||||
|
||||
<el-card shadow="never" class="rounded-xl">
|
||||
<el-form inline>
|
||||
<el-form-item label="选择账号">
|
||||
<el-select v-model="account" filterable placeholder="选择账号" style="width: 240px" @change="selectAccount">
|
||||
<el-option v-for="a in accounts" :key="a.account" :label="`${a.nickname || a.account} (${a.account})`" :value="a.account" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-table v-if="account" :data="plugins" border stripe>
|
||||
<el-table-column prop="id" label="插件ID" min-width="140" />
|
||||
<el-table-column prop="name" label="名称" min-width="150" />
|
||||
<el-table-column label="允许运行" width="120">
|
||||
<template #default="{ row }">
|
||||
<el-switch :model-value="grants[row.id]?.canRun" @change="(v: any) => toggleGrant(row.id, 'canRun', !!v)" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="允许下载" width="120">
|
||||
<template #default="{ row }">
|
||||
<el-switch :model-value="grants[row.id]?.canDownload" @change="(v: any) => toggleGrant(row.id, 'canDownload', !!v)" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-empty v-else description="请先选择账号" :image-size="80" />
|
||||
|
||||
<template v-if="account">
|
||||
<div class="mt-4 font-semibold text-sm mb-2">平台白名单</div>
|
||||
<div class="flex gap-4">
|
||||
<el-checkbox
|
||||
v-for="p in platformOptions"
|
||||
:key="p"
|
||||
:model-value="platforms.includes(p)"
|
||||
@change="(v: any) => togglePlatform(p, !!v)"
|
||||
>{{ p.toUpperCase() }}</el-checkbox>
|
||||
</div>
|
||||
</template>
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
||||
Reference in New Issue
Block a user