Skip to content

Commit 1b92f20

Browse files
committed
✨ Feature: support "tips" option for uploader
1 parent a2320c3 commit 1b92f20

File tree

7 files changed

+72
-23
lines changed

7 files changed

+72
-23
lines changed

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@
3232
"keycode": "^2.2.0",
3333
"lodash-id": "^0.14.0",
3434
"lowdb": "^1.0.0",
35+
"marked": "^7.0.4",
3536
"mitt": "^3.0.0",
36-
"picgo": "^1.5.4",
37+
"picgo": "^1.5.5",
3738
"qrcode.vue": "^3.3.3",
3839
"shell-path": "2.1.0",
3940
"uuid": "^9.0.0",

src/renderer/App.vue

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ import { getConfig } from './utils/dataSender'
1111
import type { IConfig } from 'picgo'
1212
import bus from './utils/bus'
1313
import { FORCE_UPDATE } from '~/universal/events/constants'
14+
import { useATagClick } from './hooks/useATagClick'
15+
16+
useATagClick()
1417
1518
const store = useStore()
1619
onBeforeMount(async () => {

src/renderer/components/ConfigForm.vue

+36-17
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,31 @@
2525
<el-form-item
2626
v-for="(item, index) in configList"
2727
:key="item.name + index"
28-
:label="item.alias || item.name"
2928
:required="item.required"
3029
:prop="item.name"
3130
>
31+
<template #label>
32+
<el-row align="middle">
33+
{{ item.alias || item.name }}
34+
<template v-if="item.tips">
35+
<el-tooltip
36+
class="item"
37+
effect="dark"
38+
placement="right"
39+
>
40+
<template #content>
41+
<span
42+
class="config-form-common-tips"
43+
v-html="transformMarkdownToHTML(item.tips)"
44+
/>
45+
</template>
46+
<el-icon class="ml-[4px] cursor-pointer hover:text-blue">
47+
<QuestionFilled />
48+
</el-icon>
49+
</el-tooltip>
50+
</template>
51+
</el-row>
52+
</template>
3253
<el-input
3354
v-if="item.type === 'input' || item.type === 'password'"
3455
v-model="ruleForm[item.name]"
@@ -67,17 +88,6 @@
6788
:active-text="item.confirmText || 'yes'"
6889
:inactive-text="item.cancelText || 'no'"
6990
/>
70-
<div v-if="item.tips" class="common-tips" @mouseenter="() => isHoverTips = true" @mouseleave="() => isHoverTips = false">
71-
<el-tooltip
72-
:content="item.tips"
73-
placement="top"
74-
raw-content
75-
effect="light"
76-
>
77-
<el-button v-if="isHoverTips" type="primary" :icon="Warning" circle />
78-
<el-button v-if="!isHoverTips" type="info" :icon="Warning" circle />
79-
</el-tooltip>
80-
</div>
8191
</el-form-item>
8292
<slot />
8393
</el-form>
@@ -89,7 +99,8 @@ import { cloneDeep, union } from 'lodash'
8999
import { getConfig } from '@/utils/dataSender'
90100
import { useRoute } from 'vue-router'
91101
import type { FormInstance } from 'element-plus'
92-
import { Warning } from '@element-plus/icons-vue'
102+
import { QuestionFilled } from '@element-plus/icons-vue'
103+
import { marked } from 'marked'
93104
94105
interface IProps {
95106
config: any[]
@@ -101,7 +112,6 @@ interface IProps {
101112
const props = defineProps<IProps>()
102113
const $route = useRoute()
103114
const $form = ref<FormInstance>()
104-
const isHoverTips = ref(false)
105115
const configList = ref<IPicGoPluginConfig[]>([])
106116
const ruleForm = reactive<IStringKeyMap>({})
107117
@@ -145,6 +155,14 @@ function getConfigType () {
145155
}
146156
}
147157
158+
function transformMarkdownToHTML (markdown: string) {
159+
try {
160+
return marked.parse(markdown)
161+
} catch (e) {
162+
return markdown
163+
}
164+
}
165+
148166
async function handleConfig (val: IPicGoPluginConfig[]) {
149167
const config = await getCurConfigFormData()
150168
const configId = $route.params.configId
@@ -184,6 +202,10 @@ defineExpose({
184202
})
185203
</script>
186204
<style lang='stylus'>
205+
.config-form-common-tips
206+
a
207+
color #409EFF
208+
text-decoration none
187209
#config-form
188210
.el-form
189211
label
@@ -210,7 +232,4 @@ defineExpose({
210232
&.white
211233
.el-form-item
212234
border-bottom 1px solid #ddd
213-
.common-tips
214-
margin-left 10px
215-
display inline-block
216235
</style>

src/renderer/hooks/useATagClick.ts

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { openURL } from '@/utils/common'
2+
import { onMounted, onUnmounted } from 'vue'
3+
4+
export function useATagClick () {
5+
const handleATagClick = (e: MouseEvent) => {
6+
if (e.target instanceof HTMLAnchorElement) {
7+
if (e.target.href) {
8+
e.preventDefault()
9+
openURL(e.target.href)
10+
}
11+
}
12+
}
13+
onMounted(() => {
14+
document.addEventListener('click', handleATagClick)
15+
})
16+
onUnmounted(() => {
17+
document.removeEventListener('click', handleATagClick)
18+
})
19+
}

src/universal/types/extra-vue.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ declare module 'vue/types/vue' {
1515
}
1616
}
1717

18-
declare module '@vue/runtime-core' {
18+
declare module 'vue' {
1919
interface ComponentCustomProperties {
2020
$http: typeof axios
2121
$builtInPicBed: string[]

src/universal/types/types.d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ interface IPicGoPluginConfig {
165165
name?: string
166166
value?: any
167167
}[]
168+
/** support markdown */
169+
tips?: string
168170
[propName: string]: any
169171
}
170172

yarn.lock

+9-4
Original file line numberDiff line numberDiff line change
@@ -8980,6 +8980,11 @@ map-obj@^4.0.0:
89808980
resolved "https://registry.npmjs.org/map-obj/-/map-obj-4.3.0.tgz#9304f906e93faae70880da102a9f1df0ea8bb05a"
89818981
integrity sha512-hdN1wVrZbb29eBGiGjJbeP8JbKjq1urkHJ/LIP/NY48MZ1QVXUsQBV1G1zvYFHn1XE06cwjBsOI2K3Ulnj1YXQ==
89828982

8983+
marked@^7.0.4:
8984+
version "7.0.4"
8985+
resolved "https://registry.npmmirror.com/marked/-/marked-7.0.4.tgz#e2558ee2d535b9df6a27c6e282dc603a18388a6d"
8986+
integrity sha512-t8eP0dXRJMtMvBojtkcsA7n48BkauktUKzfkPSCq85ZMTJ0v76Rke4DYz01omYpPTUh4p/f7HePgRo3ebG8+QQ==
8987+
89838988
matcher@^3.0.0:
89848989
version "3.0.0"
89858990
resolved "https://registry.npmjs.org/matcher/-/matcher-3.0.0.tgz#bd9060f4c5b70aa8041ccc6f80368760994f30ca"
@@ -9965,10 +9970,10 @@ pend@~1.2.0:
99659970
resolved "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz#7a57eb550a6783f9115331fcf4663d5c8e007a50"
99669971
integrity sha1-elfrVQpng/kRUzH89GY9XI4AelA=
99679972

9968-
picgo@^1.5.4:
9969-
version "1.5.4"
9970-
resolved "https://registry.yarnpkg.com/picgo/-/picgo-1.5.4.tgz#3c15b8a82b7941db2aa9535d7acf8384be4c47d5"
9971-
integrity sha512-lU4WmYsqyhIiXvSlROv+iPxgGzupbMJENYhsHNtnScMogH4DHnmiqCWTylVsW2EqW7qQANDv9G9vgnuUkNShYA==
9973+
picgo@^1.5.5:
9974+
version "1.5.5"
9975+
resolved "https://registry.npmmirror.com/picgo/-/picgo-1.5.5.tgz#fa9a5d07d3552036c2cc8b1455bec1c3a2086183"
9976+
integrity sha512-GSfDVR+b6SgibYDQ0eqNKmhmiMWDyNVppq+qKNKyf38VATX/U0ompSS2XgoPAn8Lr7pTddbXgqxfmFiLLXN7LA==
99729977
dependencies:
99739978
"@picgo/i18n" "^1.0.0"
99749979
"@picgo/store" "^2.0.2"

0 commit comments

Comments
 (0)