Skip to content

Commit

Permalink
feat: 预备分享管理API和页面逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
hsingyin committed Nov 4, 2024
1 parent 56eda1f commit fd645b3
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 2 deletions.
15 changes: 14 additions & 1 deletion src/api/subs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,25 @@ export function useSubsApi() {
data,
});
},
shareSub: (data: ShareToken): AxiosPromise<MyAxiosRes> => {
shareCreate: (data: ShareToken): AxiosPromise<MyAxiosRes> => {
return request({
url: `/api/token`,
method: 'post',
data,
});
},
shareDelete: (token: string): AxiosPromise<MyAxiosRes> => {
return request({
url: `/api/token/${encodeURIComponent(token)}`,
method: 'delete',
});
},
shareQuery: (type: string, name: string): AxiosPromise<MyAxiosRes> => {
return request({
url: `/api/tokens`,
method: 'get',
params: { type, name },
});
},
};
}
Empty file.
11 changes: 11 additions & 0 deletions src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import FileEditor from '@/views/FileEditor.vue';
// import editScript from '@/views/editCode/editScript.vue';
import IconCollection from '@/views/icon/IconCollection.vue';

import Share from '@/views/share/Share.vue';

import Sub from '@/views/Sub.vue';
import SubEditor from '@/views/SubEditor.vue';

Expand Down Expand Up @@ -158,6 +160,15 @@ const router = createRouter({
needNavBack: true,
},
},
{
path: '/share',
component: Share,
meta: {
title: 'share',
needTabBar: true,
needNavBack: true,
},
},
{
path: '/settings/more',
component: moreSetting,
Expand Down
38 changes: 38 additions & 0 deletions src/views/share/Share.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!-- 分享管理 -->
<template>
<!-- 滚动内容 -->
<nut-swipe
ref="swipe"
class="share-item-swipe"
:disabled="props.disabled"
@close="setIsMoveClose()"
@open="setIsMoveOpen()"
@click="onClickPreviews()"
>
<div class="share-wrapper"></div>
</nut-swipe>
</template>

<script setup lang="ts">
import { onMounted, ref } from "vue";

import { useSubsApi } from "@/api/subs";

const subsApi = useSubsApi();
const swipe = ref();
const type = ref("sub");
const name = ref("SurgePro");
const getShareList = async () => {
const res = await subsApi.shareQuery(type.value, name.value);
console.log("res", res);
};
onMounted(() => {
getShareList();
});
</script>

<style lang="scss" scoped>
.share-wrapper {
min-height: 100%;
}
</style>
2 changes: 1 addition & 1 deletion src/views/share/SharePopup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ const handleCreateShare = async () => {
if (form.token) {
params.payload.token = form.token;
}
const res = await subsApi.shareSub(params);
const res = await subsApi.shareCreate(params);
if (res?.data?.status === "success") {
isCreateShareLinkSuccess.value = true;
const { secret, token } = res.data.data;
Expand Down

0 comments on commit fd645b3

Please sign in to comment.