2018-09-17 04:52:01 -04:00
|
|
|
<template>
|
|
|
|
<div id="plugin-view">
|
|
|
|
<div class="view-title">
|
2022-01-18 03:05:22 -05:00
|
|
|
{{ $T('PLUGIN_SETTINGS') }} -
|
2021-04-04 05:52:50 -04:00
|
|
|
<el-tooltip :content="pluginListToolTip" placement="right">
|
|
|
|
<i class="el-icon-goods" @click="goAwesomeList"></i>
|
|
|
|
</el-tooltip>
|
|
|
|
<el-tooltip :content="importLocalPluginToolTip" placement="left">
|
|
|
|
<i class="el-icon-download" @click="handleImportLocalPlugin"/>
|
|
|
|
</el-tooltip>
|
2018-09-17 04:52:01 -04:00
|
|
|
</div>
|
2018-09-28 05:31:22 -04:00
|
|
|
<el-row class="handle-bar" :class="{ 'cut-width': pluginList.length > 6 }">
|
2018-09-17 04:52:01 -04:00
|
|
|
<el-input
|
|
|
|
v-model="searchText"
|
2022-01-18 03:05:22 -05:00
|
|
|
:placeholder="$T('PLUGIN_SEARCH_PLACEHOLDER')"
|
2018-09-17 04:52:01 -04:00
|
|
|
size="small"
|
2018-09-28 05:31:22 -04:00
|
|
|
>
|
|
|
|
<i slot="suffix" class="el-input__icon el-icon-close" v-if="searchText" @click="cleanSearch" style="cursor: pointer"></i>
|
|
|
|
</el-input>
|
2018-09-17 04:52:01 -04:00
|
|
|
</el-row>
|
2018-09-28 05:31:22 -04:00
|
|
|
<el-row :gutter="10" class="plugin-list" v-loading="loading">
|
2020-12-26 10:39:48 -05:00
|
|
|
<el-col :span="12" v-for="item in pluginList" :key="item.fullName">
|
2018-12-28 07:30:47 -05:00
|
|
|
<div class="plugin-item" :class="{ 'darwin': os === 'darwin' }">
|
2019-01-11 04:22:33 -05:00
|
|
|
<div class="cli-only-badge" v-if="!item.gui" title="CLI only">CLI</div>
|
2018-09-28 05:31:22 -04:00
|
|
|
<img class="plugin-item__logo" :src="item.logo"
|
2019-12-20 10:41:38 -05:00
|
|
|
:onerror="defaultLogo"
|
2018-09-28 05:31:22 -04:00
|
|
|
>
|
2018-12-18 05:58:31 -05:00
|
|
|
<div
|
|
|
|
class="plugin-item__content"
|
|
|
|
:class="{ disabled: !item.enabled }"
|
|
|
|
>
|
2018-12-19 02:45:46 -05:00
|
|
|
<div class="plugin-item__name" @click="openHomepage(item.homepage)">
|
2018-10-10 05:25:44 -04:00
|
|
|
{{ item.name }} <small>{{ ' ' + item.version }}</small>
|
2018-09-17 04:52:01 -04:00
|
|
|
</div>
|
2018-12-19 02:45:46 -05:00
|
|
|
<div class="plugin-item__desc" :title="item.description">
|
2018-09-18 06:48:55 -04:00
|
|
|
{{ item.description }}
|
2018-09-17 04:52:01 -04:00
|
|
|
</div>
|
|
|
|
<div class="plugin-item__info-bar">
|
|
|
|
<span class="plugin-item__author">
|
2018-09-18 06:48:55 -04:00
|
|
|
{{ item.author }}
|
2018-09-17 04:52:01 -04:00
|
|
|
</span>
|
2018-09-18 06:48:55 -04:00
|
|
|
<span class="plugin-item__config" >
|
2018-09-28 05:31:22 -04:00
|
|
|
<template v-if="searchText">
|
2018-10-09 05:01:33 -04:00
|
|
|
<template v-if="!item.hasInstall">
|
2018-12-18 05:58:31 -05:00
|
|
|
<span class="config-button install" v-if="!item.ing" @click="installPlugin(item)">
|
2022-01-18 10:10:49 -05:00
|
|
|
{{ $T('PLUGIN_INSTALL') }}
|
2018-10-09 05:01:33 -04:00
|
|
|
</span>
|
2018-12-18 05:58:31 -05:00
|
|
|
<span v-else-if="item.ing" class="config-button ing">
|
2022-01-18 10:10:49 -05:00
|
|
|
{{ $T('PLUGIN_INSTALLING') }}
|
2018-10-09 05:01:33 -04:00
|
|
|
</span>
|
|
|
|
</template>
|
2018-12-18 05:58:31 -05:00
|
|
|
<span v-else class="config-button ing">
|
2022-01-18 10:10:49 -05:00
|
|
|
{{ $T('PLUGIN_INSTALLED') }}
|
2018-12-18 05:58:31 -05:00
|
|
|
</span>
|
2018-10-09 05:01:33 -04:00
|
|
|
</template>
|
|
|
|
<template v-else>
|
2018-12-18 05:58:31 -05:00
|
|
|
<span v-if="item.ing" class="config-button ing">
|
2022-01-18 10:10:49 -05:00
|
|
|
{{ $T('PLUGIN_DOING_SOMETHING') }}
|
2018-09-28 05:31:22 -04:00
|
|
|
</span>
|
2018-12-18 05:58:31 -05:00
|
|
|
<template v-else>
|
|
|
|
<i
|
|
|
|
v-if="item.enabled"
|
|
|
|
class="el-icon-setting"
|
|
|
|
@click="buildContextMenu(item)"
|
|
|
|
></i>
|
|
|
|
<i
|
2018-12-28 07:30:47 -05:00
|
|
|
v-else
|
2018-12-18 05:58:31 -05:00
|
|
|
class="el-icon-remove-outline"
|
|
|
|
@click="buildContextMenu(item)"
|
|
|
|
></i>
|
|
|
|
</template>
|
2018-09-28 05:31:22 -04:00
|
|
|
</template>
|
2018-09-17 04:52:01 -04:00
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</el-col>
|
|
|
|
</el-row>
|
2018-12-24 03:05:30 -05:00
|
|
|
<el-row v-show="needReload" class="reload-mask" :class="{ 'cut-width': pluginList.length > 6 }">
|
2022-01-18 10:10:49 -05:00
|
|
|
<el-button type="primary" @click="reloadApp" size="mini" round>{{ $T('TIPS_NEED_RELOAD') }}</el-button>
|
2018-12-24 03:05:30 -05:00
|
|
|
</el-row>
|
2018-09-19 05:27:09 -04:00
|
|
|
<el-dialog
|
|
|
|
:visible.sync="dialogVisible"
|
|
|
|
:modal-append-to-body="false"
|
2022-01-18 10:10:49 -05:00
|
|
|
:title="$T('CONFIG_THING', {
|
|
|
|
c: configName
|
|
|
|
})"
|
2018-09-19 05:27:09 -04:00
|
|
|
width="70%"
|
|
|
|
>
|
|
|
|
<config-form
|
|
|
|
:config="config"
|
|
|
|
:type="currentType"
|
2018-12-25 02:24:32 -05:00
|
|
|
:id="configName"
|
2018-09-19 05:27:09 -04:00
|
|
|
ref="configForm"
|
|
|
|
>
|
|
|
|
</config-form>
|
|
|
|
<span slot="footer">
|
2022-01-18 10:10:49 -05:00
|
|
|
<el-button @click="dialogVisible = false" round>{{ $T('CANCEL') }}</el-button>
|
|
|
|
<el-button type="primary" @click="handleConfirmConfig" round>{{ $T('CONFIRM') }}</el-button>
|
2018-09-19 05:27:09 -04:00
|
|
|
</span>
|
|
|
|
</el-dialog>
|
2018-09-17 04:52:01 -04:00
|
|
|
</div>
|
|
|
|
</template>
|
2019-12-19 06:17:21 -05:00
|
|
|
<script lang="ts">
|
|
|
|
import {
|
|
|
|
Component,
|
|
|
|
Vue,
|
|
|
|
Watch
|
|
|
|
} from 'vue-property-decorator'
|
|
|
|
import ConfigForm from '@/components/ConfigForm.vue'
|
2018-09-28 05:31:22 -04:00
|
|
|
import { debounce } from 'lodash'
|
2019-12-19 06:17:21 -05:00
|
|
|
import {
|
|
|
|
ipcRenderer,
|
|
|
|
IpcRendererEvent
|
|
|
|
} from 'electron'
|
2020-12-26 10:39:48 -05:00
|
|
|
import { handleStreamlinePluginName } from '~/universal/utils/common'
|
2022-01-04 10:40:28 -05:00
|
|
|
import {
|
|
|
|
OPEN_URL,
|
|
|
|
RELOAD_APP,
|
|
|
|
PICGO_CONFIG_PLUGIN,
|
|
|
|
PICGO_HANDLE_PLUGIN_ING,
|
|
|
|
PICGO_TOGGLE_PLUGIN,
|
|
|
|
SHOW_PLUGIN_PAGE_MENU
|
|
|
|
} from '#/events/constants'
|
2019-12-19 06:17:21 -05:00
|
|
|
|
|
|
|
@Component({
|
2018-09-17 04:52:01 -04:00
|
|
|
name: 'plugin',
|
2018-09-19 05:27:09 -04:00
|
|
|
components: {
|
|
|
|
ConfigForm
|
2019-12-19 06:17:21 -05:00
|
|
|
}
|
|
|
|
})
|
|
|
|
export default class extends Vue {
|
|
|
|
searchText = ''
|
|
|
|
pluginList: IPicGoPlugin[] = []
|
|
|
|
menu: Electron.Menu | null = null
|
|
|
|
config: any[] = []
|
|
|
|
currentType = ''
|
|
|
|
configName = ''
|
|
|
|
dialogVisible = false
|
|
|
|
pluginNameList: string[] = []
|
|
|
|
loading = true
|
|
|
|
needReload = false
|
2022-07-15 22:36:00 -04:00
|
|
|
pluginListToolTip = this.$T('PLUGIN_LIST')
|
|
|
|
importLocalPluginToolTip = this.$T('PLUGIN_IMPORT_LOCAL')
|
2019-12-19 06:17:21 -05:00
|
|
|
id = ''
|
|
|
|
os = ''
|
2019-12-20 10:41:38 -05:00
|
|
|
defaultLogo: string = 'this.src="https://cdn.jsdelivr.net/gh/Molunerfinn/PicGo@dev/public/roundLogo.png"'
|
2019-12-19 06:17:21 -05:00
|
|
|
get npmSearchText () {
|
|
|
|
return this.searchText.match('picgo-plugin-')
|
|
|
|
? this.searchText
|
|
|
|
: this.searchText !== ''
|
|
|
|
? `picgo-plugin-${this.searchText}`
|
|
|
|
: this.searchText
|
|
|
|
}
|
2022-01-04 10:40:28 -05:00
|
|
|
|
2019-12-19 06:17:21 -05:00
|
|
|
@Watch('npmSearchText')
|
|
|
|
onNpmSearchTextChange (val: string) {
|
|
|
|
if (val) {
|
|
|
|
this.loading = true
|
|
|
|
this.pluginList = []
|
|
|
|
this.getSearchResult(val)
|
|
|
|
} else {
|
|
|
|
this.getPluginList()
|
2018-09-18 06:48:55 -04:00
|
|
|
}
|
2019-12-19 06:17:21 -05:00
|
|
|
}
|
2022-01-04 10:40:28 -05:00
|
|
|
|
2019-12-28 03:50:29 -05:00
|
|
|
@Watch('dialogVisible')
|
|
|
|
onDialogVisible (val: boolean) {
|
|
|
|
if (val) {
|
|
|
|
// @ts-ignore
|
|
|
|
document.querySelector('.main-content.el-row').style.zIndex = 101
|
|
|
|
} else {
|
|
|
|
// @ts-ignore
|
|
|
|
document.querySelector('.main-content.el-row').style.zIndex = 10
|
|
|
|
}
|
|
|
|
}
|
2022-01-04 10:40:28 -05:00
|
|
|
|
2021-07-25 11:25:36 -04:00
|
|
|
async created () {
|
2018-12-28 07:30:47 -05:00
|
|
|
this.os = process.platform
|
2021-04-04 05:52:50 -04:00
|
|
|
ipcRenderer.on('hideLoading', () => {
|
|
|
|
this.loading = false
|
|
|
|
})
|
2019-12-19 06:17:21 -05:00
|
|
|
ipcRenderer.on('pluginList', (evt: IpcRendererEvent, list: IPicGoPlugin[]) => {
|
2018-12-18 05:58:31 -05:00
|
|
|
this.pluginList = list
|
2020-12-26 10:39:48 -05:00
|
|
|
this.pluginNameList = list.map(item => item.fullName)
|
2018-09-28 05:31:22 -04:00
|
|
|
this.loading = false
|
2018-09-18 06:48:55 -04:00
|
|
|
})
|
2021-04-10 23:11:22 -04:00
|
|
|
ipcRenderer.on('installPlugin', (evt: IpcRendererEvent, { success, body }: {
|
|
|
|
success: boolean,
|
|
|
|
body: string
|
|
|
|
}) => {
|
2018-10-09 05:01:33 -04:00
|
|
|
this.loading = false
|
|
|
|
this.pluginList.forEach(item => {
|
2021-04-10 23:11:22 -04:00
|
|
|
if (item.fullName === body) {
|
2018-12-18 05:58:31 -05:00
|
|
|
item.ing = false
|
2021-04-10 23:11:22 -04:00
|
|
|
item.hasInstall = success
|
2018-10-09 05:01:33 -04:00
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
2019-12-19 06:17:21 -05:00
|
|
|
ipcRenderer.on('updateSuccess', (evt: IpcRendererEvent, plugin: string) => {
|
2018-12-20 09:30:08 -05:00
|
|
|
this.loading = false
|
|
|
|
this.pluginList.forEach(item => {
|
2020-12-26 10:39:48 -05:00
|
|
|
if (item.fullName === plugin) {
|
2018-12-20 09:30:08 -05:00
|
|
|
item.ing = false
|
|
|
|
item.hasInstall = true
|
|
|
|
}
|
2018-12-24 03:05:30 -05:00
|
|
|
this.getPicBeds()
|
2018-12-20 09:30:08 -05:00
|
|
|
})
|
2018-12-24 03:05:30 -05:00
|
|
|
this.handleReload()
|
2018-12-20 09:30:08 -05:00
|
|
|
this.getPluginList()
|
|
|
|
})
|
2019-12-19 06:17:21 -05:00
|
|
|
ipcRenderer.on('uninstallSuccess', (evt: IpcRendererEvent, plugin: string) => {
|
2018-10-09 05:01:33 -04:00
|
|
|
this.loading = false
|
2018-12-18 05:58:31 -05:00
|
|
|
this.pluginList = this.pluginList.filter(item => {
|
2020-12-26 10:39:48 -05:00
|
|
|
if (item.fullName === plugin) { // restore Uploader & Transformer after uninstalling
|
2018-12-18 05:58:31 -05:00
|
|
|
if (item.config.transformer.name) {
|
2018-12-24 03:05:30 -05:00
|
|
|
this.handleRestoreState('transformer', item.config.transformer.name)
|
2018-12-18 05:58:31 -05:00
|
|
|
}
|
|
|
|
if (item.config.uploader.name) {
|
2018-12-24 03:05:30 -05:00
|
|
|
this.handleRestoreState('uploader', item.config.uploader.name)
|
2018-12-18 05:58:31 -05:00
|
|
|
}
|
2018-12-24 03:05:30 -05:00
|
|
|
this.getPicBeds()
|
2018-10-09 05:01:33 -04:00
|
|
|
}
|
2020-12-26 10:39:48 -05:00
|
|
|
return item.fullName !== plugin
|
2018-10-09 05:01:33 -04:00
|
|
|
})
|
2018-12-18 05:58:31 -05:00
|
|
|
this.pluginNameList = this.pluginNameList.filter(item => item !== plugin)
|
2018-10-09 05:01:33 -04:00
|
|
|
})
|
2022-01-04 10:40:28 -05:00
|
|
|
ipcRenderer.on(PICGO_CONFIG_PLUGIN, (evt: IpcRendererEvent, currentType: string, configName: string, config: any) => {
|
|
|
|
this.currentType = currentType
|
|
|
|
this.configName = configName
|
|
|
|
this.dialogVisible = true
|
|
|
|
this.config = config
|
|
|
|
})
|
|
|
|
ipcRenderer.on(PICGO_HANDLE_PLUGIN_ING, (evt: IpcRendererEvent, fullName: string) => {
|
|
|
|
this.pluginList.forEach(item => {
|
|
|
|
if (item.fullName === fullName || (item.name === fullName)) {
|
|
|
|
item.ing = true
|
|
|
|
}
|
|
|
|
})
|
|
|
|
this.loading = true
|
|
|
|
})
|
|
|
|
ipcRenderer.on(PICGO_TOGGLE_PLUGIN, (evt: IpcRendererEvent, fullName: string, enabled: boolean) => {
|
|
|
|
const plugin = this.pluginList.find(item => item.fullName === fullName)
|
|
|
|
if (plugin) {
|
|
|
|
plugin.enabled = enabled
|
|
|
|
this.getPicBeds()
|
|
|
|
this.needReload = true
|
|
|
|
}
|
|
|
|
})
|
2018-09-18 06:48:55 -04:00
|
|
|
this.getPluginList()
|
2018-12-18 05:58:31 -05:00
|
|
|
this.getSearchResult = debounce(this.getSearchResult, 50)
|
2021-07-25 11:25:36 -04:00
|
|
|
this.needReload = await this.getConfig<boolean>('needReload') || false
|
2019-12-19 06:17:21 -05:00
|
|
|
}
|
2019-01-11 04:22:33 -05:00
|
|
|
|
2022-01-04 10:40:28 -05:00
|
|
|
async buildContextMenu (plugin: IPicGoPlugin) {
|
|
|
|
ipcRenderer.send(SHOW_PLUGIN_PAGE_MENU, plugin)
|
2019-12-19 06:17:21 -05:00
|
|
|
}
|
2022-01-04 10:40:28 -05:00
|
|
|
|
2019-12-19 06:17:21 -05:00
|
|
|
getPluginList () {
|
|
|
|
ipcRenderer.send('getPluginList')
|
|
|
|
}
|
2022-01-04 10:40:28 -05:00
|
|
|
|
2019-12-19 06:17:21 -05:00
|
|
|
getPicBeds () {
|
|
|
|
ipcRenderer.send('getPicBeds')
|
|
|
|
}
|
2022-01-04 10:40:28 -05:00
|
|
|
|
2019-12-19 06:17:21 -05:00
|
|
|
installPlugin (item: IPicGoPlugin) {
|
|
|
|
if (!item.gui) {
|
2022-01-18 10:10:49 -05:00
|
|
|
this.$confirm(this.$T('TIPS_PLUGIN_NOT_GUI_IMPLEMENT'), this.$T('TIPS_NOTICE'), {
|
|
|
|
confirmButtonText: this.$T('CONFIRM'),
|
|
|
|
cancelButtonText: this.$T('CANCEL'),
|
2019-12-19 06:17:21 -05:00
|
|
|
type: 'warning'
|
|
|
|
}).then(() => {
|
|
|
|
item.ing = true
|
2021-04-10 23:11:22 -04:00
|
|
|
ipcRenderer.send('installPlugin', item.fullName)
|
2019-12-19 06:17:21 -05:00
|
|
|
}).catch(() => {
|
|
|
|
console.log('Install canceled')
|
2018-12-24 03:05:30 -05:00
|
|
|
})
|
2019-12-19 06:17:21 -05:00
|
|
|
} else {
|
|
|
|
item.ing = true
|
2021-04-10 23:11:22 -04:00
|
|
|
ipcRenderer.send('installPlugin', item.fullName)
|
2019-12-19 06:17:21 -05:00
|
|
|
}
|
|
|
|
}
|
2022-01-04 10:40:28 -05:00
|
|
|
|
2019-12-19 06:17:21 -05:00
|
|
|
uninstallPlugin (val: string) {
|
|
|
|
this.pluginList.forEach(item => {
|
|
|
|
if (item.name === val) {
|
|
|
|
item.ing = true
|
2019-01-01 10:44:00 -05:00
|
|
|
}
|
2019-12-19 06:17:21 -05:00
|
|
|
})
|
2021-04-04 05:52:50 -04:00
|
|
|
this.loading = true
|
2019-12-19 06:17:21 -05:00
|
|
|
ipcRenderer.send('uninstallPlugin', val)
|
|
|
|
}
|
2022-01-04 10:40:28 -05:00
|
|
|
|
2019-12-19 06:17:21 -05:00
|
|
|
updatePlugin (val: string) {
|
|
|
|
this.pluginList.forEach(item => {
|
2020-12-26 10:39:48 -05:00
|
|
|
if (item.fullName === val) {
|
2019-12-19 06:17:21 -05:00
|
|
|
item.ing = true
|
2018-09-20 02:49:20 -04:00
|
|
|
}
|
2019-12-19 06:17:21 -05:00
|
|
|
})
|
2021-04-04 05:52:50 -04:00
|
|
|
this.loading = true
|
2019-12-19 06:17:21 -05:00
|
|
|
ipcRenderer.send('updatePlugin', val)
|
|
|
|
}
|
2022-01-04 10:40:28 -05:00
|
|
|
|
2019-12-19 06:17:21 -05:00
|
|
|
reloadApp () {
|
2022-01-04 10:40:28 -05:00
|
|
|
ipcRenderer.send(RELOAD_APP)
|
2019-12-19 06:17:21 -05:00
|
|
|
}
|
2022-01-04 10:40:28 -05:00
|
|
|
|
2021-07-25 11:25:36 -04:00
|
|
|
async handleReload () {
|
|
|
|
this.saveConfig({
|
|
|
|
needReload: true
|
|
|
|
})
|
2019-12-19 06:17:21 -05:00
|
|
|
this.needReload = true
|
2022-01-18 10:10:49 -05:00
|
|
|
const successNotification = new Notification(this.$T('PLUGIN_UPDATE_SUCCEED'), {
|
|
|
|
body: this.$T('TIPS_NEED_RELOAD')
|
2019-12-19 06:17:21 -05:00
|
|
|
})
|
|
|
|
successNotification.onclick = () => {
|
|
|
|
this.reloadApp()
|
|
|
|
}
|
|
|
|
}
|
2022-01-04 10:40:28 -05:00
|
|
|
|
2019-12-19 06:17:21 -05:00
|
|
|
cleanSearch () {
|
|
|
|
this.searchText = ''
|
|
|
|
}
|
2022-01-04 10:40:28 -05:00
|
|
|
|
2019-12-19 06:17:21 -05:00
|
|
|
async handleConfirmConfig () {
|
|
|
|
// @ts-ignore
|
|
|
|
const result = await this.$refs.configForm.validate()
|
|
|
|
if (result !== false) {
|
|
|
|
switch (this.currentType) {
|
|
|
|
case 'plugin':
|
2021-07-25 11:25:36 -04:00
|
|
|
this.saveConfig({
|
2020-12-26 10:39:48 -05:00
|
|
|
[`${this.configName}`]: result
|
2019-12-26 07:15:41 -05:00
|
|
|
})
|
2019-12-19 06:17:21 -05:00
|
|
|
break
|
|
|
|
case 'uploader':
|
2021-07-25 11:25:36 -04:00
|
|
|
this.saveConfig({
|
2019-12-26 07:15:41 -05:00
|
|
|
[`picBed.${this.configName}`]: result
|
|
|
|
})
|
2019-12-19 06:17:21 -05:00
|
|
|
break
|
|
|
|
case 'transformer':
|
2021-07-25 11:25:36 -04:00
|
|
|
this.saveConfig({
|
2019-12-26 07:15:41 -05:00
|
|
|
[`transformer.${this.configName}`]: result
|
|
|
|
})
|
2019-12-19 06:17:21 -05:00
|
|
|
break
|
2019-01-15 04:28:50 -05:00
|
|
|
}
|
2022-01-18 10:10:49 -05:00
|
|
|
const successNotification = new Notification(this.$T('SETTINGS_RESULT'), {
|
|
|
|
body: this.$T('TIPS_SET_SUCCEED')
|
2019-12-19 06:17:21 -05:00
|
|
|
})
|
|
|
|
successNotification.onclick = () => {
|
|
|
|
return true
|
2018-09-28 05:31:22 -04:00
|
|
|
}
|
2019-12-19 06:17:21 -05:00
|
|
|
this.dialogVisible = false
|
|
|
|
this.getPluginList()
|
|
|
|
}
|
|
|
|
}
|
2022-01-04 10:40:28 -05:00
|
|
|
|
2019-12-19 06:17:21 -05:00
|
|
|
getSearchResult (val: string) {
|
|
|
|
// this.$http.get(`https://api.npms.io/v2/search?q=${val}`)
|
|
|
|
this.$http.get(`https://registry.npmjs.com/-/v1/search?text=${val}`)
|
|
|
|
.then((res: INPMSearchResult) => {
|
2019-12-26 07:15:41 -05:00
|
|
|
this.pluginList = res.data.objects
|
|
|
|
.filter((item:INPMSearchResultObject) => {
|
|
|
|
return item.package.name.includes('picgo-plugin-')
|
|
|
|
})
|
|
|
|
.map((item: INPMSearchResultObject) => {
|
|
|
|
return this.handleSearchResult(item)
|
|
|
|
})
|
2019-12-19 06:17:21 -05:00
|
|
|
this.loading = false
|
|
|
|
})
|
|
|
|
.catch(err => {
|
|
|
|
console.log(err)
|
|
|
|
this.loading = false
|
|
|
|
})
|
|
|
|
}
|
2022-01-04 10:40:28 -05:00
|
|
|
|
2019-12-19 06:17:21 -05:00
|
|
|
handleSearchResult (item: INPMSearchResultObject) {
|
2020-12-26 10:39:48 -05:00
|
|
|
const name = handleStreamlinePluginName(item.package.name)
|
2019-12-19 06:17:21 -05:00
|
|
|
let gui = false
|
|
|
|
if (item.package.keywords && item.package.keywords.length > 0) {
|
|
|
|
if (item.package.keywords.includes('picgo-gui-plugin')) {
|
|
|
|
gui = true
|
2018-12-18 05:58:31 -05:00
|
|
|
}
|
2019-12-19 06:17:21 -05:00
|
|
|
}
|
|
|
|
return {
|
|
|
|
name: name,
|
2020-12-26 10:39:48 -05:00
|
|
|
fullName: item.package.name,
|
2019-12-19 06:17:21 -05:00
|
|
|
author: item.package.author.name,
|
|
|
|
description: item.package.description,
|
|
|
|
logo: `https://cdn.jsdelivr.net/npm/${item.package.name}/logo.png`,
|
|
|
|
config: {},
|
|
|
|
homepage: item.package.links ? item.package.links.homepage : '',
|
2020-12-26 10:39:48 -05:00
|
|
|
hasInstall: this.pluginNameList.some(plugin => plugin === item.package.name),
|
2019-12-19 06:17:21 -05:00
|
|
|
version: item.package.version,
|
|
|
|
gui,
|
|
|
|
ing: false // installing or uninstalling
|
|
|
|
}
|
|
|
|
}
|
2022-01-04 10:40:28 -05:00
|
|
|
|
2019-12-19 06:17:21 -05:00
|
|
|
// restore Uploader & Transformer
|
2021-07-25 11:25:36 -04:00
|
|
|
async handleRestoreState (item: string, name: string) {
|
2019-12-19 06:17:21 -05:00
|
|
|
if (item === 'uploader') {
|
2021-07-25 11:25:36 -04:00
|
|
|
const current = await this.getConfig('picBed.current')
|
2019-12-19 06:17:21 -05:00
|
|
|
if (current === name) {
|
2021-07-25 11:25:36 -04:00
|
|
|
this.saveConfig({
|
2020-07-12 10:01:00 -04:00
|
|
|
'picBed.current': 'smms',
|
|
|
|
'picBed.uploader': 'smms'
|
2019-12-26 07:15:41 -05:00
|
|
|
})
|
2018-12-18 05:58:31 -05:00
|
|
|
}
|
2019-12-19 06:17:21 -05:00
|
|
|
}
|
|
|
|
if (item === 'transformer') {
|
2021-07-25 11:25:36 -04:00
|
|
|
const current = await this.getConfig('picBed.transformer')
|
2019-12-19 06:17:21 -05:00
|
|
|
if (current === name) {
|
2021-07-25 11:25:36 -04:00
|
|
|
this.saveConfig({
|
2019-12-26 07:15:41 -05:00
|
|
|
'picBed.transformer': 'path'
|
|
|
|
})
|
2018-12-19 02:45:46 -05:00
|
|
|
}
|
2018-09-17 04:52:01 -04:00
|
|
|
}
|
2019-12-19 06:17:21 -05:00
|
|
|
}
|
2022-01-04 10:40:28 -05:00
|
|
|
|
2019-12-19 06:17:21 -05:00
|
|
|
openHomepage (url: string) {
|
|
|
|
if (url) {
|
2022-01-04 10:40:28 -05:00
|
|
|
ipcRenderer.send(OPEN_URL, url)
|
2019-12-19 06:17:21 -05:00
|
|
|
}
|
|
|
|
}
|
2022-01-04 10:40:28 -05:00
|
|
|
|
2019-12-19 06:17:21 -05:00
|
|
|
goAwesomeList () {
|
2022-01-04 10:40:28 -05:00
|
|
|
ipcRenderer.send(OPEN_URL, 'https://github.com/PicGo/Awesome-PicGo')
|
2019-12-19 06:17:21 -05:00
|
|
|
}
|
2022-01-04 10:40:28 -05:00
|
|
|
|
|
|
|
saveConfig (data: IObj) {
|
|
|
|
ipcRenderer.send('picgoSaveData', data)
|
|
|
|
}
|
|
|
|
|
2021-04-04 05:52:50 -04:00
|
|
|
handleImportLocalPlugin () {
|
|
|
|
ipcRenderer.send('importLocalPlugin')
|
|
|
|
this.loading = true
|
|
|
|
}
|
2022-01-04 10:40:28 -05:00
|
|
|
|
2018-10-09 05:11:24 -04:00
|
|
|
beforeDestroy () {
|
2019-12-19 06:17:21 -05:00
|
|
|
ipcRenderer.removeAllListeners('pluginList')
|
2021-04-10 23:11:22 -04:00
|
|
|
ipcRenderer.removeAllListeners('installPlugin')
|
2019-12-19 06:17:21 -05:00
|
|
|
ipcRenderer.removeAllListeners('uninstallSuccess')
|
|
|
|
ipcRenderer.removeAllListeners('updateSuccess')
|
2021-04-04 05:52:50 -04:00
|
|
|
ipcRenderer.removeAllListeners('hideLoading')
|
2018-09-17 04:52:01 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
<style lang='stylus'>
|
2018-12-28 07:30:47 -05:00
|
|
|
$darwinBg = #172426
|
2018-09-17 04:52:01 -04:00
|
|
|
#plugin-view
|
2018-09-28 05:31:22 -04:00
|
|
|
position relative
|
2018-09-17 04:52:01 -04:00
|
|
|
padding 0 20px 0
|
2018-12-18 05:58:31 -05:00
|
|
|
.el-loading-mask
|
|
|
|
background-color rgba(0, 0, 0, 0.8)
|
2018-09-28 05:31:22 -04:00
|
|
|
.plugin-list
|
|
|
|
height: 339px;
|
|
|
|
box-sizing: border-box;
|
|
|
|
padding: 8px 15px;
|
|
|
|
overflow-y: auto;
|
|
|
|
overflow-x: hidden;
|
|
|
|
position: absolute;
|
|
|
|
top: 70px;
|
|
|
|
left: 5px;
|
|
|
|
transition: all 0.2s ease-in-out 0.1s;
|
|
|
|
width: 100%
|
|
|
|
.el-loading-mask
|
|
|
|
left: 20px
|
|
|
|
width: calc(100% - 40px)
|
|
|
|
.view-title
|
|
|
|
color #eee
|
|
|
|
font-size 20px
|
|
|
|
text-align center
|
|
|
|
margin 10px auto
|
2021-04-04 05:52:50 -04:00
|
|
|
position relative
|
2019-01-31 03:40:08 -05:00
|
|
|
i.el-icon-goods
|
|
|
|
font-size 20px
|
|
|
|
vertical-align middle
|
|
|
|
cursor pointer
|
2019-04-18 23:00:51 -04:00
|
|
|
transition color .2s ease-in-out
|
|
|
|
&:hover
|
|
|
|
color #49B1F5
|
2021-04-04 05:52:50 -04:00
|
|
|
i.el-icon-download
|
|
|
|
position absolute
|
|
|
|
right 0
|
|
|
|
top 8px
|
|
|
|
font-size 20px
|
|
|
|
vertical-align middle
|
|
|
|
cursor pointer
|
|
|
|
transition color .2s ease-in-out
|
|
|
|
&:hover
|
|
|
|
color #49B1F5
|
2018-09-17 04:52:01 -04:00
|
|
|
.handle-bar
|
|
|
|
margin-bottom 20px
|
2018-09-28 05:31:22 -04:00
|
|
|
&.cut-width
|
|
|
|
padding-right: 8px
|
2018-09-17 04:52:01 -04:00
|
|
|
.el-input__inner
|
|
|
|
border-radius 0
|
|
|
|
.plugin-item
|
|
|
|
box-sizing border-box
|
|
|
|
height 80px
|
|
|
|
background #444
|
|
|
|
padding 8px
|
|
|
|
user-select text
|
|
|
|
transition all .2s ease-in-out
|
2018-09-18 06:48:55 -04:00
|
|
|
margin-bottom 10px
|
2019-01-11 04:22:33 -05:00
|
|
|
position relative
|
|
|
|
.cli-only-badge
|
|
|
|
position absolute
|
|
|
|
right 0px
|
|
|
|
top 0
|
|
|
|
font-size 12px
|
|
|
|
padding 3px 8px
|
|
|
|
background #49B1F5
|
|
|
|
color #eee
|
2018-12-28 07:30:47 -05:00
|
|
|
&.darwin
|
|
|
|
background transparentify($darwinBg, #000, 0.75)
|
|
|
|
&:hover
|
|
|
|
background transparentify($darwinBg, #000, 0.85)
|
2018-09-17 04:52:01 -04:00
|
|
|
&:hover
|
|
|
|
background #333
|
|
|
|
&__logo
|
|
|
|
width 64px
|
|
|
|
height 64px
|
|
|
|
float left
|
|
|
|
&__content
|
|
|
|
float left
|
2018-09-18 06:48:55 -04:00
|
|
|
width calc(100% - 72px)
|
2018-09-17 04:52:01 -04:00
|
|
|
height 64px
|
2018-12-18 05:58:31 -05:00
|
|
|
color #ddd
|
2018-09-17 04:52:01 -04:00
|
|
|
margin-left 8px
|
|
|
|
display flex
|
|
|
|
flex-direction column
|
|
|
|
justify-content space-between
|
2018-12-18 05:58:31 -05:00
|
|
|
&.disabled
|
|
|
|
color #aaa
|
2018-09-17 04:52:01 -04:00
|
|
|
&__name
|
|
|
|
font-size 16px
|
|
|
|
height 22px
|
|
|
|
line-height 22px
|
2018-09-19 05:27:09 -04:00
|
|
|
// font-weight 600
|
|
|
|
font-weight 600
|
2018-12-19 02:45:46 -05:00
|
|
|
cursor pointer
|
|
|
|
transition all .2s ease-in-out
|
|
|
|
&:hover
|
|
|
|
color: #1B9EF3
|
2018-09-17 04:52:01 -04:00
|
|
|
&__desc
|
|
|
|
font-size 14px
|
|
|
|
height 21px
|
|
|
|
line-height 21px
|
|
|
|
overflow hidden
|
|
|
|
text-overflow ellipsis
|
|
|
|
white-space nowrap
|
|
|
|
&__info-bar
|
|
|
|
font-size 14px
|
|
|
|
height 21px
|
|
|
|
line-height 28px
|
2018-09-18 06:48:55 -04:00
|
|
|
position relative
|
2018-09-17 04:52:01 -04:00
|
|
|
&__author
|
|
|
|
overflow hidden
|
|
|
|
text-overflow ellipsis
|
|
|
|
white-space nowrap
|
|
|
|
&__config
|
|
|
|
float right
|
|
|
|
font-size 16px
|
2018-12-19 02:45:46 -05:00
|
|
|
cursor pointer
|
|
|
|
transition all .2s ease-in-out
|
|
|
|
&:hover
|
|
|
|
color: #1B9EF3
|
2018-09-28 05:31:22 -04:00
|
|
|
.config-button
|
2018-09-18 06:48:55 -04:00
|
|
|
font-size 12px
|
|
|
|
color #ddd
|
|
|
|
background #222
|
|
|
|
padding 1px 8px
|
|
|
|
height 18px
|
|
|
|
line-height 18px
|
|
|
|
text-align center
|
|
|
|
position absolute
|
|
|
|
top 4px
|
|
|
|
right 20px
|
2018-09-28 05:31:22 -04:00
|
|
|
transition all .2s ease-in-out
|
2018-10-09 05:01:33 -04:00
|
|
|
&.reload
|
|
|
|
right 0px
|
2018-12-18 05:58:31 -05:00
|
|
|
&.ing
|
2018-10-09 05:01:33 -04:00
|
|
|
right 0px
|
2018-09-28 05:31:22 -04:00
|
|
|
&.install
|
|
|
|
right 0px
|
2018-10-09 05:01:33 -04:00
|
|
|
&:hover
|
|
|
|
background: #1B9EF3
|
|
|
|
color #fff
|
2018-12-24 03:05:30 -05:00
|
|
|
.reload-mask
|
|
|
|
position absolute
|
|
|
|
width calc(100% - 40px)
|
|
|
|
bottom -320px
|
|
|
|
text-align center
|
|
|
|
background rgba(0,0,0,0.4)
|
|
|
|
padding 10px 0
|
|
|
|
&.cut-width
|
|
|
|
width calc(100% - 48px)
|
2019-12-19 06:17:21 -05:00
|
|
|
</style>
|