Compare commits

...

2 Commits

Author SHA1 Message Date
491a9bb79e 手机端图片上传
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 3m7s
2025-03-24 09:45:57 +08:00
e55bdd2c16 手机端图片上传 2025-03-24 09:34:59 +08:00
5 changed files with 56 additions and 17 deletions

View File

@ -39,8 +39,8 @@ const router = createRouter({
component: () => import("@/views/plink/index.vue"), component: () => import("@/views/plink/index.vue"),
}, },
{ {
path: "/cookbook", path: "/appshare",
component: () => import("@/views/cookbook/index.vue"), component: () => import("@/views/appshare/index.vue"),
}, },
], ],
}, },

View File

@ -26,13 +26,13 @@ const menuInfo = {
}, },
{ {
key: "5", key: "5",
label: () => h(RouterLink, { to: "/cookbook", class: "menu-item font-[500] text-lg" }, { default: () => "菜谱" }), label: () => h(RouterLink, { to: "/appshare", class: "menu-item font-[500] text-lg" }, { default: () => "软件分享" }),
}, },
{ {
key: "6", key: "6",
label: () => h(RouterLink, { to: "/plink", class: "menu-item font-[500] text-lg" }, { default: () => "友链" }), label: () => h(RouterLink, { to: "/plink", class: "menu-item font-[500] text-lg" }, { default: () => "友链" }),
}, },
], ],
menuList: ["/home", "/gallery", "/article", "/widget","/cookbook","/plink"], menuList: ["/home", "/gallery", "/article", "/widget","/appshare","/plink"],
}; };
export default menuInfo; export default menuInfo;

View File

@ -0,0 +1,21 @@
<template>
<div>
</div>
</template>
<script setup>
//mark import
//mark data
//mark method
//mark
</script>
<style scoped>
</style>

View File

@ -19,7 +19,7 @@
<falls :fileList="list" :count="acount" :bot="bottomLen" pathname="filepath" v-slot="{ file }"> <falls :fileList="list" :count="acount" :bot="bottomLen" pathname="filepath" v-slot="{ file }">
<div class="img mb-1" @contextmenu="handdlemenu($event, file)" @longpress="handdlemenu($event, file)"> <div class="img mb-1" @contextmenu="handdlemenu($event, file)" @longpress="handdlemenu($event, file)">
<n-image height="200px" :src="file.filepath" object-fit="fill" :img-props="{ loading: 'lazy' }" /> <n-image height="200px" :src="file.filepath" object-fit="fill" />
</div> </div>
</falls> </falls>

View File

@ -33,8 +33,9 @@
</template> </template>
</n-modal> </n-modal>
</n-scrollbar> </n-scrollbar>
<n-upload multiple action="https://www.hxyouzi.com/api/file/upload" accept="image/*" <n-upload multiple action="https://www.hxyouzi.com/pic/upload" accept="image/*"
:headers="{ Authorization: token }" :show-file-list="false" :on-finish="fileFinish"> :data="{ strategy_id: 2 }"
:headers="{ Authorization: 'Bearer ' + '2|RKsuwoT7mbtuTW7Eguc566uwt7Wg4qgpGA6XTpM1' }" :show-file-list="false" :on-finish="fileFinish">
<n-button type="primary">上传图片</n-button> <n-button type="primary">上传图片</n-button>
</n-upload> </n-upload>
</div> </div>
@ -51,16 +52,16 @@ const bottomLen = ref(20)
// console.log(4444, size.conH); // console.log(4444, size.conH);
const list = ref([]); const list = ref([]);
const token = cookie.get("token"); const token = cookie.get("token");
function fileFinish(file) { // function fileFinish(file) {
const res = JSON.parse(file.event.currentTarget.response); // const res = JSON.parse(file.event.currentTarget.response);
// console.log(res); // // console.log(res);
if (res.code == 1) { // if (res.code == 1) {
$msg.success(res.msg); // $msg.success(res.msg);
getMyfile(); // getMyfile();
} else { // } else {
$msg.error(res.msg); // $msg.error(res.msg);
} // }
} // }
async function getMyfile() { async function getMyfile() {
list.value = []; list.value = [];
@ -252,6 +253,23 @@ function arrCount() {
acount.value = Math.floor(cw * 0.95 / (pw + 20)) acount.value = Math.floor(cw * 0.95 / (pw + 20))
} }
async function fileFinish(file) {
const res = JSON.parse(file.event.currentTarget.response);
console.log("返回文件", res);
const r = await $http.file.uploadImg({
url: res.data.links.url,
filename: res.data.origin_name,
});
console.log("上传服务器", r);
if (r.code == 1) {
$msg.success(r.msg);
getMyfile();
} else {
$msg.error(r.msg);
}
}
onMounted(() => { onMounted(() => {
arrCount() arrCount()
}) })