mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-09-07 16:56:40 +08:00
feat(plugin): 添加插件市场设置窗口
该提交添加了一个新的组件PluginMarketSettingDialog.vue,用于插件市场的设置窗口。该窗口可以通过点击插件市场设置图标打开,并提供了保存设置的功能。 该提交还在PluginCardListView.vue中引入了PluginMarketSettingDialog组件,并在点击插件市场设置图标时打开该窗口。 该提交的目的是为了提供一个方便的界面,让用户可以设置插件市场的仓库地址。
This commit is contained in:
@@ -0,0 +1,68 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
import api from '@/api'
|
||||||
|
import { useToast } from 'vue-toast-notification'
|
||||||
|
|
||||||
|
// 输入参数
|
||||||
|
const props = defineProps({
|
||||||
|
title: String,
|
||||||
|
})
|
||||||
|
|
||||||
|
const $toast = useToast()
|
||||||
|
|
||||||
|
// 插件仓库设置字符串
|
||||||
|
const repoString = ref('')
|
||||||
|
|
||||||
|
// 定义事件
|
||||||
|
const emit = defineEmits(['save', 'close'])
|
||||||
|
|
||||||
|
// 查询已设置的插件仓库
|
||||||
|
async function queryMarketRepoSetting() {
|
||||||
|
try {
|
||||||
|
const result: { [key: string]: any } = await api.get('system/setting/PLUGIN_MARKET')
|
||||||
|
if (result && result.data && result.data.value) repoString.value = result.data.value
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 保存设置
|
||||||
|
async function saveHandle() {
|
||||||
|
try {
|
||||||
|
// 用户名密码
|
||||||
|
const result: { [key: string]: any } = await api.post('system/setting/PLUGIN_MARKET', repoString.value)
|
||||||
|
|
||||||
|
if (result.success) {
|
||||||
|
$toast.success('插件仓库保存成功')
|
||||||
|
emit('save')
|
||||||
|
} else $toast.error('插件仓库保存失败!')
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
queryMarketRepoSetting()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<VDialog width="50rem" scrollable max-height="85vh">
|
||||||
|
<VCard title="插件仓库设置" class="rounded-t">
|
||||||
|
<DialogCloseBtn @click="emit('close')" />
|
||||||
|
<VCardText class="pt-2">
|
||||||
|
<VTextarea
|
||||||
|
v-model="repoString"
|
||||||
|
placeholder="格式:https://github.com/jxxghp/MoviePilot-Plugins/,https://github.com/xxxx/xxxxxx/"
|
||||||
|
hint="多个地址使用逗号分隔,仅支持Github仓库"
|
||||||
|
persistent-hint
|
||||||
|
/>
|
||||||
|
</VCardText>
|
||||||
|
<VCardActions>
|
||||||
|
<VSpacer />
|
||||||
|
<VBtn variant="elevated" @click="saveHandle" prepend-icon="mdi-content-save-check" class="px-5 me-3">
|
||||||
|
保存
|
||||||
|
</VBtn>
|
||||||
|
</VCardActions>
|
||||||
|
</VCard>
|
||||||
|
</VDialog>
|
||||||
|
</template>
|
||||||
@@ -9,6 +9,7 @@ import noImage from '@images/logos/plugin.png'
|
|||||||
import { useDisplay } from 'vuetify'
|
import { useDisplay } from 'vuetify'
|
||||||
import { isNullOrEmptyObject } from '@/@core/utils'
|
import { isNullOrEmptyObject } from '@/@core/utils'
|
||||||
import { PluginTabs } from '@/router/menu'
|
import { PluginTabs } from '@/router/menu'
|
||||||
|
import PluginMarketSettingDialog from '@/components/dialog/PluginMarketSettingDialog.vue'
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
|
|
||||||
@@ -63,6 +64,9 @@ const PluginStatistics = ref<{ [key: string]: number }>({})
|
|||||||
// 搜索窗口
|
// 搜索窗口
|
||||||
const SearchDialog = ref(false)
|
const SearchDialog = ref(false)
|
||||||
|
|
||||||
|
// 插件市场设置窗口
|
||||||
|
const MarketSettingDialog = ref(false)
|
||||||
|
|
||||||
// 搜索关键字
|
// 搜索关键字
|
||||||
const keyword = ref('')
|
const keyword = ref('')
|
||||||
|
|
||||||
@@ -311,6 +315,13 @@ function pluginInstalled() {
|
|||||||
refreshData()
|
refreshData()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 插件市场设置完成
|
||||||
|
function marketSettingDone() {
|
||||||
|
MarketSettingDialog.value = false
|
||||||
|
// 重新加载数据
|
||||||
|
refreshData()
|
||||||
|
}
|
||||||
|
|
||||||
// 处理掉github地址的前缀
|
// 处理掉github地址的前缀
|
||||||
function handleRepoUrl(url: string | undefined) {
|
function handleRepoUrl(url: string | undefined) {
|
||||||
if (!url) return ''
|
if (!url) return ''
|
||||||
@@ -435,19 +446,40 @@ onBeforeMount(async () => {
|
|||||||
</VWindow>
|
</VWindow>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 插件搜索 -->
|
<!-- 插件搜索图标 -->
|
||||||
<VFab
|
<VFab
|
||||||
icon="mdi-magnify"
|
icon="mdi-magnify"
|
||||||
color="info"
|
color="info"
|
||||||
location="bottom"
|
location="bottom"
|
||||||
class="mb-2"
|
|
||||||
size="x-large"
|
size="x-large"
|
||||||
fixed
|
fixed
|
||||||
app
|
app
|
||||||
appear
|
appear
|
||||||
@click="SearchDialog = true"
|
@click="SearchDialog = true"
|
||||||
|
:class="appMode ? 'mb-28' : 'mb-16'"
|
||||||
|
/>
|
||||||
|
<!-- 插件市场设置图标 -->
|
||||||
|
<VFab
|
||||||
|
icon="mdi-store-cog"
|
||||||
|
color="warning"
|
||||||
|
location="bottom"
|
||||||
|
size="x-large"
|
||||||
|
fixed
|
||||||
|
app
|
||||||
|
appear
|
||||||
|
@click="MarketSettingDialog = true"
|
||||||
:class="{ 'mb-12': appMode }"
|
:class="{ 'mb-12': appMode }"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<!-- 插件市场设置窗口 -->
|
||||||
|
<PluginMarketSettingDialog
|
||||||
|
v-if="MarketSettingDialog"
|
||||||
|
v-model="MarketSettingDialog"
|
||||||
|
@close="MarketSettingDialog = false"
|
||||||
|
@save="marketSettingDone"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<!-- 插件搜索窗口 -->
|
||||||
<VDialog
|
<VDialog
|
||||||
v-if="SearchDialog"
|
v-if="SearchDialog"
|
||||||
v-model="SearchDialog"
|
v-model="SearchDialog"
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ const SystemSettings = ref<any>({
|
|||||||
APP_DOMAIN: '',
|
APP_DOMAIN: '',
|
||||||
API_TOKEN: '',
|
API_TOKEN: '',
|
||||||
WALLPAPER: 'tmdb',
|
WALLPAPER: 'tmdb',
|
||||||
PLUGIN_MARKET: '',
|
|
||||||
},
|
},
|
||||||
// 高级系统设置
|
// 高级系统设置
|
||||||
Advanced: {
|
Advanced: {
|
||||||
@@ -80,8 +79,10 @@ async function loadSystemSettings() {
|
|||||||
if (result.data.hasOwnProperty(key)) {
|
if (result.data.hasOwnProperty(key)) {
|
||||||
v = result.data[key]
|
v = result.data[key]
|
||||||
// 空字符串转为null,避免空字符串导致前端显示问题
|
// 空字符串转为null,避免空字符串导致前端显示问题
|
||||||
if (v === '') { v = null }
|
if (v === '') {
|
||||||
(SystemSettings.value[sectionKey] as any)[key] = v
|
v = null
|
||||||
|
}
|
||||||
|
;(SystemSettings.value[sectionKey] as any)[key] = v
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -129,7 +130,7 @@ function saveAdvancedSettings(Settings: any, key: string) {
|
|||||||
// 检查Settings中的键是否在SystemSettings的[key]中存在,有则使用Settings的值替换SystemSettings中的值
|
// 检查Settings中的键是否在SystemSettings的[key]中存在,有则使用Settings的值替换SystemSettings中的值
|
||||||
for (const settingKey in Settings) {
|
for (const settingKey in Settings) {
|
||||||
if (SystemSettings.value[key].hasOwnProperty(settingKey)) {
|
if (SystemSettings.value[key].hasOwnProperty(settingKey)) {
|
||||||
(SystemSettings.value[key] as any)[settingKey] = Settings[settingKey]
|
;(SystemSettings.value[key] as any)[settingKey] = Settings[settingKey]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$toast.info('高级设置已更改,待保存后生效')
|
$toast.info('高级设置已更改,待保存后生效')
|
||||||
@@ -256,16 +257,6 @@ onMounted(() => {
|
|||||||
:rules="[(v: string) => !!v || '必填项;请输入API Token', (v: string) => v.length >= 16 || 'API Token不得低于16位']"
|
:rules="[(v: string) => !!v || '必填项;请输入API Token', (v: string) => v.length >= 16 || 'API Token不得低于16位']"
|
||||||
/>
|
/>
|
||||||
</VCol>
|
</VCol>
|
||||||
<VCol cols="12">
|
|
||||||
<VTextarea
|
|
||||||
v-model="SystemSettings.Basis.PLUGIN_MARKET"
|
|
||||||
label="插件市场"
|
|
||||||
placeholder="格式:https://github.com/jxxghp/MoviePilot-Plugins/,https://github.com/xxxx/xxxxxx/"
|
|
||||||
hint="插件市场仓库地址,多个地址使用逗号分隔,确保每个地址以/结尾,仅支持Github仓库"
|
|
||||||
persistent-hint
|
|
||||||
clearable
|
|
||||||
/>
|
|
||||||
</VCol>
|
|
||||||
</VRow>
|
</VRow>
|
||||||
</VForm>
|
</VForm>
|
||||||
</VCardText>
|
</VCardText>
|
||||||
|
|||||||
Reference in New Issue
Block a user