1
0
mirror of https://github.com/ialley-workshop-open/uni-halo.git synced 2026-06-12 21:29:31 +08:00

fix: 修复海报保存问题

This commit is contained in:
小莫唐尼
2025-11-26 15:19:04 +08:00
parent 21fee2dc9a
commit 3643bdf6f6
+115 -4
View File
@@ -158,7 +158,10 @@
</view> </view>
<!-- 豆瓣 --> <!-- 豆瓣 -->
<view v-if="!calcAuditModeEnabled && result._doubanUrls.length !== 0 && doubanPluginConfig.position==='bottom'" class="vote-wrap copyright-wrap bg-white mt-24 pa-24 round-4"> <view
v-if="!calcAuditModeEnabled && result._doubanUrls.length !== 0 && doubanPluginConfig.position === 'bottom'"
class="vote-wrap copyright-wrap bg-white mt-24 pa-24 round-4"
>
<view class="copyright-title text-weight-b flex items-center justify-between"> <view class="copyright-title text-weight-b flex items-center justify-between">
<text>豆瓣资源</text> <text>豆瓣资源</text>
<text class="vote-opra" @click="doubanIsOpen = !doubanIsOpen"> <text class="vote-opra" @click="doubanIsOpen = !doubanIsOpen">
@@ -506,7 +509,11 @@ export default {
voteIsOpen: true, voteIsOpen: true,
reloadVote: false, reloadVote: false,
doubanIsOpen: true doubanIsOpen: true,
appAuthorize: {
writePhotosAlbum: ''
}
}; };
}, },
computed: { computed: {
@@ -549,7 +556,7 @@ export default {
return this.haloConfigs.pluginConfig; return this.haloConfigs.pluginConfig;
}, },
doubanPluginConfig() { doubanPluginConfig() {
return this.pluginsConfig.doubanPlugin return this.pluginsConfig.doubanPlugin;
} }
}, },
watch: { watch: {
@@ -1116,16 +1123,120 @@ export default {
this.poster.showCanvas = false; this.poster.showCanvas = false;
this.poster.loading = true; this.poster.loading = true;
}, },
fnSavePoster() { fnGetAlbumAuthorize() {
return new Promise((resolve) => {
uni.showModal({
title: '提示',
content: '保存到相册未授权,是否去授权?',
success: (res) => {
if (res.confirm) {
// uni.authorize({
// scope: 'scope.writePhotosAlbum',
// success() {
// uni.showToast({
// icon: 'none',
// title: '授权成功,请重新保存'
// });
// resolve(true);
// },
// fail: (err) => {
// uni.showToast({
// icon: 'none',
// title: '授权失败,请手动授权'
// });
// resolve(false);
// }
// });
uni.openSetting({
success: (res) => {
if (res.authSetting['scope.writePhotosAlbum'] === true) {
uni.showToast({
icon: 'none',
title: '授权成功,请重新保存'
});
resolve(true);
} else {
uni.showToast({
icon: 'none',
title: '未进行授权操作'
});
resolve(false);
}
},
fail: (err) => {
uni.showToast({
icon: 'none',
title: '授权失败'
});
resolve(false);
}
});
}
},
fail: () => {
resolve(false);
}
});
});
},
fnCheckAlbumAppAuthorize() {
return new Promise((resolve) => {
// #ifdef MP-WEIXIN
uni.getSetting({
success: async (res) => {
if (res.authSetting['scope.writePhotosAlbum'] === false) {
const authorize = await this.fnGetAlbumAuthorize();
console.log('authorize1', authorize);
if (!authorize) {
uni.openSetting({
success: (res) => {
console.log('授权1', res);
}
});
console.log('打开授权页面1');
}
resolve(false);
} else {
resolve(true);
}
},
fail: async () => {
const authorize = await this.fnGetAlbumAuthorize();
console.log('authorize2', authorize);
if (!authorize) {
uni.openSetting({
success: (res) => {
console.log('授权2', res);
}
});
console.log('打开授权页面2');
}
resolve(false);
}
});
// #endif
// #ifndef MP-WEIXIN
resolve(true);
// #endif
});
},
async fnSavePoster() {
// this.$refs.rCanvas.saveImage(this.poster.res.tempFilePath); // this.$refs.rCanvas.saveImage(this.poster.res.tempFilePath);
// 检查授权
const authorize = await this.fnCheckAlbumAppAuthorize();
if (!authorize) return;
uni.saveImageToPhotosAlbum({ uni.saveImageToPhotosAlbum({
filePath: this.poster.url, filePath: this.poster.url,
success: () => { success: () => {
uni.$tm.toast('保存成功'); uni.$tm.toast('保存成功');
}, },
fail: (e) => { fail: (e) => {
if(!e?.errMsg.includes('cancel')){
uni.$tm.toast('保存失败,请重试'); uni.$tm.toast('保存失败,请重试');
} }
}
}); });
}, },
fnShareTo() { fnShareTo() {