fix: make content api

This commit is contained in:
zzc
2026-02-09 20:13:20 +08:00
parent 30d7a74fb5
commit 247f238377
2 changed files with 34 additions and 15 deletions

View File

@@ -71,15 +71,11 @@
<view v-if="activeTool === 'avatar'" class="section">
<view class="section-title">选择头像</view>
<view class="grid">
<view class="grid-item upload-card">
<button
class="wechat-avatar-btn"
open-type="chooseAvatar"
@chooseavatar="onChooseAvatar"
>
<view class="grid-item upload-card" @tap="onChooseAlbum">
<view class="wechat-avatar-btn">
<view class="upload-icon"></view>
<text class="upload-text">微信头像</text>
</button>
<text class="upload-text">上传头像</text>
</view>
</view>
<view
v-for="item in systemAvatars"
@@ -201,6 +197,7 @@ import {
uploadImage,
} from "@/utils/common.js";
import NavBar from "@/components/NavBar/NavBar.vue";
import LoginPopup from "@/components/LoginPopup/LoginPopup.vue";
const userStore = useUserStore();
const loginPopupRef = ref(null);
@@ -462,16 +459,38 @@ const handleLogind = async () => {
// Logic after successful login if needed
};
const onChooseAvatar = async (e) => {
const avatarUrl = e.detail.avatarUrl;
if (!avatarUrl) return;
const onChooseAlbum = () => {
uni.chooseImage({
count: 1,
sizeType: ["original", "compressed"],
sourceType: ["album"],
success: (res) => {
const path = res.tempFilePaths[0];
// 调用系统裁剪,强制 1:1
uni.cropImage({
src: path,
aspectRatio: "1:1",
success: (cropRes) => {
onAvatarSelect(cropRes.tempFilePath);
},
fail: (err) => {
console.warn("Crop failed or cancelled", err);
onAvatarSelect(path);
},
});
},
});
};
const onAvatarSelect = async (url) => {
if (!url) return;
uni.showLoading({ title: "上传中...", mask: true });
try {
const imageUrl = await uploadImage(avatarUrl);
const imageUrl = await uploadImage(url);
currentAvatar.value = {
id: "wechat_" + Date.now(),
id: "custom_" + Date.now(),
imageUrl: imageUrl,
};
uni.hideLoading();

View File

@@ -1,6 +1,6 @@
const BASE_URL = "https://api.ai-meng.com";
// const BASE_URL = "https://api.ai-meng.com";
// const BASE_URL = 'http://127.0.0.1:3999'
// const BASE_URL = "http://192.168.1.3:3999";
const BASE_URL = "http://192.168.1.3:3999";
// const BASE_URL = "http://192.168.31.253:3999";
import { useUserStore } from "@/stores/user";