-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
504 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
<script setup lang="tsx"> | ||
import { uploadPoliciesAssets } from '@/utils/github'; | ||
import { copy } from '@/utils/others'; | ||
import { useTask } from '@/utils/task'; | ||
import { useDebounceFn } from '@vueuse/core'; | ||
import JSON5 from 'json5'; | ||
import { NButton, NInput, NModal } from 'naive-ui'; | ||
import { shallowRef, watchEffect } from 'vue'; | ||
import { useRouter } from 'vue-router'; | ||
const router = useRouter(); | ||
const show = defineModel('show', { default: false }); | ||
const text = shallowRef(''); | ||
const disabled = shallowRef(false); | ||
const checkJson = useDebounceFn(() => { | ||
try { | ||
JSON5.parse(text.value); | ||
disabled.value = false; | ||
} catch { | ||
disabled.value = true; | ||
} | ||
}, 500); | ||
watchEffect(() => { | ||
if (text.value.trim()) { | ||
checkJson(); | ||
} else { | ||
disabled.value = true; | ||
} | ||
}); | ||
const linkDlgShow = shallowRef(false); | ||
const shareLink = shallowRef(''); | ||
const copyLink = () => { | ||
copy(shareLink.value); | ||
linkDlgShow.value = false; | ||
}; | ||
const buildShare = useTask(async () => { | ||
const data = JSON5.parse(text.value); | ||
const asset = await uploadPoliciesAssets( | ||
new TextEncoder().encode( | ||
JSON5.stringify({ | ||
data, | ||
ctime: Date.now(), | ||
type: 'share', | ||
}), | ||
), | ||
'file.txt', | ||
'text/plain', | ||
); | ||
const link = location.origin + router.resolve(`/s/${asset.id}`).href; | ||
shareLink.value = link; | ||
linkDlgShow.value = true; | ||
}); | ||
</script> | ||
<template> | ||
<NModal | ||
v-model:show="show" | ||
preset="dialog" | ||
title="分享规则" | ||
:positiveText="buildShare.loading ? '分享中...' : '分享'" | ||
@positiveClick="buildShare.invoke" | ||
:loading="buildShare.loading" | ||
:positiveButtonProps="{ disabled }" | ||
style="width: 800px" | ||
@afterLeave="text = ''" | ||
> | ||
<NInput | ||
class="gkd_code h-[calc(var(--gkd-height)*0.6)]" | ||
type="textarea" | ||
show-count | ||
:value="text" | ||
@update:value=" | ||
if (!buildShare.loading) { | ||
text = $event; | ||
} | ||
" | ||
placeholder="请输入需要分享的规则" | ||
/> | ||
</NModal> | ||
<NModal | ||
v-model:show="linkDlgShow" | ||
preset="dialog" | ||
title="分享成功" | ||
positiveText="复制并关闭" | ||
negativeText="重新分享" | ||
@positiveClick="copyLink" | ||
@negativeClick=" | ||
linkDlgShow = false; | ||
text = ''; | ||
show = true; | ||
" | ||
@afterLeave="shareLink = ''" | ||
> | ||
<NButton text tag="a" :href="shareLink" target="_blank" type="primary"> | ||
{{ shareLink }} | ||
</NButton> | ||
</NModal> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<script setup lang="ts"> | ||
import store from '@/utils/store'; | ||
import { NModal } from 'naive-ui'; | ||
</script> | ||
<template> | ||
<NModal | ||
v-model:show="store.githubErrorDlgVisible" | ||
preset="dialog" | ||
title="生成分享链接失败" | ||
> | ||
<div>生成分享链接需要以下条件</div> | ||
<div> | ||
在当前浏览器登录 | ||
<a href="https://github.com" target="_blank" rel="noopener noreferrer"> | ||
github.com | ||
</a> | ||
</div> | ||
</NModal> | ||
<NModal | ||
v-model:show="store.networkErrorDlgVisible" | ||
preset="dialog" | ||
title="访问其它域名资源失败" | ||
> | ||
<div>访问其它域名资源需要以下条件</div> | ||
<div> | ||
1. 安装脚本管理器, 如 | ||
<a | ||
href="https://violentmonkey.github.io/" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
Violentmonkey | ||
</a> | ||
</div> | ||
<div> | ||
2. 安装油猴脚本 | ||
<a | ||
href="https://github.com/gkd-kit/network-extension" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
network-extension | ||
</a> | ||
</div> | ||
<div>3. 在当前网站启用上述油猴脚本的API注入功能</div> | ||
<div> | ||
4. 如果是分享链接则需要在当前浏览器登录 | ||
<a href="https://github.com" target="_blank" rel="noopener noreferrer"> | ||
github.com | ||
</a> | ||
</div> | ||
</NModal> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.