forked from mxx1111/mdlook
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWechatImageConfigDialog.vue
More file actions
80 lines (70 loc) · 2.31 KB
/
Copy pathWechatImageConfigDialog.vue
File metadata and controls
80 lines (70 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<script setup lang="ts">
import { EyeOff, Trash2 } from '@lucide/vue'
import { PasswordInput } from '@/components/ui/password-input'
import {
clearWechatImageCredentials,
wechatImageAppId,
wechatImageAppSecret,
} from '@/services/wechat/config'
const props = defineProps<{
open: boolean
}>()
const emit = defineEmits<{
'update:open': [value: boolean]
}>()
const dialogOpen = computed({
get: () => props.open,
set: value => emit(`update:open`, value),
})
function saveConfig() {
if (!wechatImageAppId.value.trim() || !wechatImageAppSecret.value.trim()) {
toast.warning(`请填写 AppID 和 AppSecret`)
return
}
toast.success(`公众号图片转换配置已保存`)
dialogOpen.value = false
}
function clearConfig() {
clearWechatImageCredentials()
toast.success(`已清除公众号图片转换配置`)
}
</script>
<template>
<Dialog v-model:open="dialogOpen">
<DialogContent class="sm:max-w-lg">
<DialogHeader>
<DialogTitle>微信图片转换配置</DialogTitle>
<DialogDescription>
配置保存在本机,复制“微信图片”时临时发送给后端代调微信接口。
</DialogDescription>
</DialogHeader>
<div class="space-y-4">
<div>
<Label class="mb-1 block text-sm font-medium">公众号 AppID</Label>
<Input v-model="wechatImageAppId" placeholder="wx..." />
</div>
<div>
<Label class="mb-1 block text-sm font-medium">公众号 AppSecret</Label>
<PasswordInput v-model="wechatImageAppSecret" placeholder="AppSecret" />
</div>
<div class="rounded-md border bg-muted/30 p-3 text-xs text-muted-foreground">
<div class="flex gap-2">
<EyeOff class="mt-0.5 h-4 w-4 shrink-0" />
<p>
AppSecret 不会提交到仓库,也不会保存到 mdlook 服务器;但转换图片时会通过 HTTPS 临时发给 mdlook 后端,请确保使用可信后端。
</p>
</div>
</div>
</div>
<DialogFooter>
<Button variant="ghost" type="button" @click="clearConfig">
<Trash2 class="mr-2 h-4 w-4" />
清除
</Button>
<Button type="button" @click="saveConfig">
保存
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
</template>