存档
This commit is contained in:
parent
25ea5f2781
commit
4213c2c9e0
9
.env.development
Normal file
9
.env.development
Normal file
@ -0,0 +1,9 @@
|
||||
#mode 环境
|
||||
VITE_MODE = dev
|
||||
|
||||
#服务器域名
|
||||
VITE_HOST = http://192.168.1.249:8084/
|
||||
|
||||
# 请求域名
|
||||
VITE_APP_BASE_URL='http://192.168.1.249:8084/ai-agent-server/'
|
||||
|
||||
11
.env.production
Normal file
11
.env.production
Normal file
@ -0,0 +1,11 @@
|
||||
#mode 环境
|
||||
VITE_MODE = production
|
||||
|
||||
#服务器域名
|
||||
VITE_HOST = https://test.szxgl.cn/
|
||||
|
||||
# 请求域名
|
||||
VITE_APP_BASE_URL='https://test.szxgl.cn/ai-agent-server/'
|
||||
|
||||
#静态资源目录
|
||||
VITE_CDN_DIR = 'https://cdn.xglpa.com/ai-agent-m/'
|
||||
@ -8,4 +8,4 @@ VITE_HOST = https://test.szxgl.cn/
|
||||
VITE_APP_BASE_URL='https://test.szxgl.cn/ai-agent-admin-server'
|
||||
|
||||
#静态资源目录
|
||||
VITE_CDN_DIR = 'https://agent-admin-test.szxgl.cn/'
|
||||
VITE_CDN_DIR = './'
|
||||
12
.gitignore
vendored
12
.gitignore
vendored
@ -15,17 +15,5 @@ coverage
|
||||
*.local
|
||||
|
||||
|
||||
/cypress/videos/
|
||||
/cypress/screenshots/
|
||||
|
||||
# Editor directories and files
|
||||
.idea
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
.hbuilderx
|
||||
# .env
|
||||
.env.development
|
||||
.env.production
|
||||
|
||||
@ -33,6 +33,7 @@
|
||||
"build:quickapp-webview": "uni build -p quickapp-webview",
|
||||
"build:quickapp-webview-huawei": "uni build -p quickapp-webview-huawei",
|
||||
"build:quickapp-webview-union": "uni build -p quickapp-webview-union",
|
||||
"build:prod": "uni build h5 mobile --mode production",
|
||||
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore"
|
||||
},
|
||||
"dependencies": {
|
||||
|
||||
@ -9,6 +9,7 @@ import { SHARE_ID, USER_SN } from './enums/constantEnums'
|
||||
import { strToParams } from './utils/util'
|
||||
import cache from './utils/cache'
|
||||
import Cookies from 'js-cookie'
|
||||
import { client } from '@/utils/client'
|
||||
|
||||
const appStore = useAppStore()
|
||||
const { getUser } = useUserStore()
|
||||
@ -73,13 +74,11 @@ const setLocalStorage = async () => {
|
||||
// 写入cookie
|
||||
const redirect = location.href
|
||||
Cookies.set('redirect', redirect)
|
||||
location.href = `${import.meta.env.VITE_APP_BASE_URL}/qywx/getWxUserByInside?terminal=3`
|
||||
location.href = `${import.meta.env.VITE_APP_BASE_URL}/qywx/getWxUserByInside?terminal=${client}`
|
||||
return
|
||||
}
|
||||
} else {
|
||||
const obj = { expire: "", value: cookiesToken }
|
||||
console.log('obj', obj);
|
||||
console.log('写入前 token', token);
|
||||
localStorage.setItem("app_token", JSON.stringify(obj));
|
||||
}
|
||||
|
||||
|
||||
@ -1,58 +1,66 @@
|
||||
import request from '@/utils/request'
|
||||
import request from "@/utils/request";
|
||||
|
||||
export function getUserCenter(header?: any) {
|
||||
return request.get({ url: '/user/center', header })
|
||||
return request.get({ url: "/user/center", header });
|
||||
}
|
||||
|
||||
// 个人信息
|
||||
export function getUserInfo() {
|
||||
return request.get({ url: '/user/info' }, { isAuth: true })
|
||||
return request.get({ url: "/user/info" }, { isAuth: true });
|
||||
}
|
||||
|
||||
// 个人编辑
|
||||
export function userEdit(data: any) {
|
||||
return request.post({ url: '/user/edit', data }, { isAuth: true })
|
||||
return request.post({ url: "/user/edit", data }, { isAuth: true });
|
||||
}
|
||||
|
||||
// 绑定手机
|
||||
export function userBindMobile(data: any, header?: any) {
|
||||
return request.post({ url: '/login/bindMobile', data, header }, { isAuth: true })
|
||||
return request.post(
|
||||
{ url: "/login/bindMobile", data, header },
|
||||
{ isAuth: true }
|
||||
);
|
||||
}
|
||||
|
||||
// 微信电话
|
||||
export function userMnpMobile(data: any, header?: any) {
|
||||
return request.post({ url: '/user/mnpMobile', data, header }, { isAuth: true })
|
||||
return request.post(
|
||||
{ url: "/user/mnpMobile", data, header },
|
||||
{ isAuth: true }
|
||||
);
|
||||
}
|
||||
export function userChangePwd(data: any) {
|
||||
return request.post({ url: '/user/changePwd', data }, { isAuth: true })
|
||||
console.log("data", data);
|
||||
|
||||
return request.post({ url: "/user/changePwd", data }, { isAuth: true });
|
||||
}
|
||||
|
||||
// 绑定小程序
|
||||
export function mnpAuthBind(data: any) {
|
||||
return request.post({ url: '/user/bindMnp', data })
|
||||
return request.post({ url: "/user/bindMnp", data });
|
||||
}
|
||||
|
||||
// 绑定公众号
|
||||
export function oaAuthBind(data: any) {
|
||||
return request.post({ url: '/user/bindOa', data })
|
||||
return request.post({ url: "/user/bindOa", data });
|
||||
}
|
||||
|
||||
//更新微信小程序头像昵称
|
||||
export function updateUser(data: Record<string, any>, header: any) {
|
||||
return request.post({ url: '/user/updateUser', data, header })
|
||||
return request.post({ url: "/user/updateUser", data, header });
|
||||
}
|
||||
|
||||
//余额明细
|
||||
export function accountLog(data: any) {
|
||||
return request.get({ url: '/logs/userMoney', data })
|
||||
return request.get({ url: "/logs/userMoney", data });
|
||||
}
|
||||
|
||||
//一键反馈
|
||||
export function feedbackPost(data: any) {
|
||||
return request.post({ url: '/feedback/add', data })
|
||||
return request.post({ url: "/feedback/add", data });
|
||||
}
|
||||
|
||||
//注销账号
|
||||
export function cancelled(data?: any) {
|
||||
return request.post({ url: '/login/cancelled', data })
|
||||
return request.post({ url: "/login/cancelled", data });
|
||||
}
|
||||
@ -1,47 +1,26 @@
|
||||
<template>
|
||||
<!-- #ifndef MP-WEIXIN -->
|
||||
<view class="floating-menu" @touchstart.stop @touchend.stop @touchmove.stop>
|
||||
<!-- #endif -->
|
||||
<!-- #ifdef MP-WEIXIN -->
|
||||
<view class="floating-menu">
|
||||
<!-- #endif -->
|
||||
<movable-area class="movable-area" :scale-area="false">
|
||||
<movable-view
|
||||
class="movable-view"
|
||||
:class="!menuData.isRemove ? 'animation-info' : ''"
|
||||
style="pointer-events: auto"
|
||||
@touchstart="touchstart"
|
||||
@touchend="touchend"
|
||||
@change="onChange"
|
||||
direction="all"
|
||||
inertia="true"
|
||||
:x="menuData.x"
|
||||
:y="menuData.y"
|
||||
:disabled="disabled"
|
||||
:out-of-bounds="true"
|
||||
:damping="200"
|
||||
:friction="100"
|
||||
>
|
||||
<view class="item-main" @click="openMenu">
|
||||
<u-icon :name="UnfoldIcon" size="36" />
|
||||
</view>
|
||||
<view
|
||||
v-if="menuData.showBtn"
|
||||
class="menu-box"
|
||||
:class="menuData.isLeft ? 'leftOut1' : 'rightOut1'"
|
||||
>
|
||||
<view
|
||||
v-for="(item, index) in list"
|
||||
:key="index"
|
||||
@click="onJump(item)"
|
||||
class="item-main"
|
||||
>
|
||||
<u-icon :name="item.icon" size="36" />
|
||||
<!-- #endif -->
|
||||
<!-- #ifdef MP-WEIXIN -->
|
||||
<view class="floating-menu">
|
||||
<!-- #endif -->
|
||||
<movable-area class="movable-area" :scale-area="false">
|
||||
<movable-view class="movable-view" :class="!menuData.isRemove ? 'animation-info' : ''"
|
||||
style="pointer-events: auto" @touchstart="touchstart" @touchend="touchend" @change="onChange"
|
||||
direction="all" inertia="true" :x="menuData.x" :y="menuData.y" :disabled="disabled"
|
||||
:out-of-bounds="true" :damping="200" :friction="100">
|
||||
<view class="item-main" @click="openMenu">
|
||||
<u-icon :name="UnfoldIcon" size="36" />
|
||||
</view>
|
||||
</view>
|
||||
</movable-view>
|
||||
</movable-area>
|
||||
</view>
|
||||
<view v-if="menuData.showBtn" class="menu-box" :class="menuData.isLeft ? 'leftOut1' : 'rightOut1'">
|
||||
<view v-for="(item, index) in list" :key="index" @click="onJump(item)" class="item-main">
|
||||
<u-icon :name="item.icon" size="36" />
|
||||
</view>
|
||||
</view>
|
||||
</movable-view>
|
||||
</movable-area>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
@ -63,7 +42,7 @@ const props = withDefaults(
|
||||
list: [
|
||||
{
|
||||
icon: HomeIcon,
|
||||
pages: '/pages/index/index'
|
||||
pages: '/pages/ai_creation/ai_creation'
|
||||
},
|
||||
{
|
||||
icon: UserIcon,
|
||||
@ -201,10 +180,12 @@ const onJump = (item: any) => {
|
||||
box-shadow: 0 4rpx 12rpx 0 rgba(0, 0, 0, 0.3);
|
||||
border-radius: 50rpx;
|
||||
}
|
||||
|
||||
.leftOut1 {
|
||||
left: 110rpx;
|
||||
animation: leftOut 0.4s;
|
||||
}
|
||||
|
||||
.rightOut1 {
|
||||
right: 110rpx;
|
||||
animation: rightOut 0.4s;
|
||||
|
||||
@ -1,21 +1,21 @@
|
||||
import { ref } from 'vue'
|
||||
import { ref } from "vue";
|
||||
|
||||
export function useLockFn(fn: (...args: any[]) => Promise<any>) {
|
||||
const isLock = ref(false)
|
||||
const lockFn = async (...args: any[]) => {
|
||||
if (isLock.value) return
|
||||
isLock.value = true
|
||||
try {
|
||||
const res = await fn(...args)
|
||||
isLock.value = false
|
||||
return res
|
||||
} catch (e) {
|
||||
isLock.value = false
|
||||
throw e
|
||||
}
|
||||
}
|
||||
return {
|
||||
isLock,
|
||||
lockFn
|
||||
const isLock = ref(false);
|
||||
const lockFn = async (...args: any[]) => {
|
||||
if (isLock.value) return;
|
||||
isLock.value = true;
|
||||
try {
|
||||
const res = await fn(...args);
|
||||
isLock.value = false;
|
||||
return res;
|
||||
} catch (e) {
|
||||
isLock.value = false;
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
return {
|
||||
isLock,
|
||||
lockFn,
|
||||
};
|
||||
}
|
||||
|
||||
@ -1,176 +1,172 @@
|
||||
import router from '@/router'
|
||||
import appConfig from '@/config'
|
||||
import { getShareId, shareClick } from '@/api/task'
|
||||
import { paramsToStr } from '@/utils/util'
|
||||
import { useNavigationBarTitleStore } from '@/stores/navigationBarTitle'
|
||||
import { useAppStore } from '@/stores/app'
|
||||
import shareMixin from '@/mixins/share'
|
||||
import router from "@/router";
|
||||
import appConfig from "@/config";
|
||||
import { getShareId, shareClick } from "@/api/task";
|
||||
import { paramsToStr } from "@/utils/util";
|
||||
import { useNavigationBarTitleStore } from "@/stores/navigationBarTitle";
|
||||
import { useAppStore } from "@/stores/app";
|
||||
import shareMixin from "@/mixins/share";
|
||||
export interface ShareOptions {
|
||||
desc: string
|
||||
title: string
|
||||
imageUrl: string
|
||||
path: string
|
||||
desc: string;
|
||||
title: string;
|
||||
imageUrl: string;
|
||||
path: string;
|
||||
}
|
||||
|
||||
export type UserShareOptions = Partial<ShareOptions>
|
||||
export type UserShareOptions = Partial<ShareOptions>;
|
||||
|
||||
//生成分享路径,首页和当前页面两种
|
||||
export async function generateSharePath(isHome = false) {
|
||||
const route = router.currentRoute.value
|
||||
let origin = ''
|
||||
//#ifdef H5
|
||||
origin = `${window.location.origin}/mobile`
|
||||
//#endif
|
||||
//#ifdef APP-PLUS
|
||||
origin = `${appConfig.baseUrl}mobile`
|
||||
//#endif
|
||||
const route = router.currentRoute.value;
|
||||
let origin = "";
|
||||
//#ifdef H5
|
||||
origin = `${window.location.origin}/mobile`;
|
||||
//#endif
|
||||
//#ifdef APP-PLUS
|
||||
origin = `${appConfig.baseUrl}mobile`;
|
||||
//#endif
|
||||
|
||||
const config = {
|
||||
path: isHome ? '/pages/index/index' : route.path,
|
||||
query: isHome ? {} : route.query
|
||||
const config = {
|
||||
path: isHome ? "/" : route.path,
|
||||
query: isHome ? {} : route.query,
|
||||
};
|
||||
const path = `${origin}${config.path}`;
|
||||
const options: any = config.query;
|
||||
try {
|
||||
const { shareId } = await getShareId();
|
||||
if (shareId) {
|
||||
options.share_id = shareId;
|
||||
}
|
||||
const path = `${origin}${config.path}`
|
||||
const options: any = config.query
|
||||
try {
|
||||
const { shareId } = await getShareId()
|
||||
if (shareId) {
|
||||
options.share_id = shareId
|
||||
}
|
||||
} catch (error) {}
|
||||
return `${path}${paramsToStr(options)}`
|
||||
} catch (error) {}
|
||||
return `${path}${paramsToStr(options)}`;
|
||||
}
|
||||
|
||||
export function useShareMessage() {
|
||||
const resolvedH5Options = (options: ShareOptions) => {
|
||||
return {
|
||||
desc: options.desc,
|
||||
image_url: options.imageUrl,
|
||||
link: options.path,
|
||||
title: options.title
|
||||
}
|
||||
}
|
||||
|
||||
const resolvedMpOptions = (options: ShareOptions) => {
|
||||
return {
|
||||
imageUrl: options.imageUrl,
|
||||
path: options.path,
|
||||
title: options.title
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @description 解析分享参数,将外部参数与默认参数合并
|
||||
* @param options
|
||||
* @returns
|
||||
*/
|
||||
const resolveOptions = async (
|
||||
options: UserShareOptions = {}
|
||||
): Promise<ShareOptions> => {
|
||||
const navigationBarTitleStore = useNavigationBarTitleStore()
|
||||
const route = router.currentRoute.value
|
||||
const appStore = useAppStore()
|
||||
const { style } =
|
||||
(router.routeMatcher.getRouteByPath(route.path) as any) || {}
|
||||
uni.showLoading({
|
||||
title: '请稍后...'
|
||||
})
|
||||
|
||||
const { shareTitle, shareImage, shareContent, sharePage } =
|
||||
appStore.getShareConfig
|
||||
const { name, logo } = appStore.getWebsiteConfig
|
||||
|
||||
// 分享为首页
|
||||
const isShareWithHome = sharePage == 2
|
||||
const link = await generateSharePath(isShareWithHome)
|
||||
let resolved = {
|
||||
title: shareTitle,
|
||||
path: link,
|
||||
desc: shareContent,
|
||||
image_url: shareImage
|
||||
}
|
||||
|
||||
// 非首页可以合并外部参数
|
||||
if (!isShareWithHome) {
|
||||
resolved = {
|
||||
...resolved,
|
||||
...options
|
||||
}
|
||||
}
|
||||
if (!resolved.title) {
|
||||
if (isShareWithHome) {
|
||||
resolved.title = name
|
||||
} else {
|
||||
// 1. 用户点击进入页面的后台配置标题
|
||||
// 2. 页面内pagesjson组册的页面标题
|
||||
// 3. 网站名称
|
||||
resolved.title =
|
||||
navigationBarTitleStore.getTitle ||
|
||||
style?.navigationBarTitleText ||
|
||||
name
|
||||
}
|
||||
}
|
||||
|
||||
if (!resolved.imageUrl) {
|
||||
resolved.imageUrl = logo
|
||||
}
|
||||
console.log(resolved)
|
||||
// #ifdef H5
|
||||
resolved = resolvedH5Options(resolved) as any
|
||||
// #endif
|
||||
// #ifdef MP-WEIXIN
|
||||
resolved = resolvedMpOptions(resolved) as any
|
||||
// #endif
|
||||
uni.hideLoading()
|
||||
return resolved as ShareOptions
|
||||
}
|
||||
|
||||
// 使用分享,可以单独在页面中使用
|
||||
const useShare = (options: UserShareOptions = {}) => {
|
||||
// #ifdef H5
|
||||
const registerEvent = () => {
|
||||
//@ts-ignore
|
||||
WeixinJSBridge.on('menu:share:appmessage', async function () {
|
||||
const resolved = await resolveOptions(options)
|
||||
//@ts-ignore
|
||||
WeixinJSBridge.invoke('sendAppMessage', resolved)
|
||||
})
|
||||
//@ts-ignore
|
||||
WeixinJSBridge.on('menu:share:timeline', async function () {
|
||||
const resolved = await resolveOptions(options)
|
||||
//@ts-ignore
|
||||
WeixinJSBridge.invoke('shareTimeline', resolved)
|
||||
})
|
||||
}
|
||||
//@ts-ignore
|
||||
if (typeof WeixinJSBridge === 'object') {
|
||||
registerEvent()
|
||||
} else {
|
||||
document.addEventListener(
|
||||
'WeixinJSBridgeReady',
|
||||
registerEvent,
|
||||
false
|
||||
)
|
||||
}
|
||||
// #endif
|
||||
}
|
||||
|
||||
const removeMixinShare = () => {
|
||||
;(shareMixin as any).onShareAppMessage = undefined
|
||||
}
|
||||
|
||||
const resolvedH5Options = (options: ShareOptions) => {
|
||||
return {
|
||||
resolveOptions,
|
||||
useShare,
|
||||
removeMixinShare
|
||||
desc: options.desc,
|
||||
image_url: options.imageUrl,
|
||||
link: options.path,
|
||||
title: options.title,
|
||||
};
|
||||
};
|
||||
|
||||
const resolvedMpOptions = (options: ShareOptions) => {
|
||||
return {
|
||||
imageUrl: options.imageUrl,
|
||||
path: options.path,
|
||||
title: options.title,
|
||||
};
|
||||
};
|
||||
/**
|
||||
* @description 解析分享参数,将外部参数与默认参数合并
|
||||
* @param options
|
||||
* @returns
|
||||
*/
|
||||
const resolveOptions = async (
|
||||
options: UserShareOptions = {}
|
||||
): Promise<ShareOptions> => {
|
||||
const navigationBarTitleStore = useNavigationBarTitleStore();
|
||||
const route = router.currentRoute.value;
|
||||
const appStore = useAppStore();
|
||||
const { style } =
|
||||
(router.routeMatcher.getRouteByPath(route.path) as any) || {};
|
||||
uni.showLoading({
|
||||
title: "请稍后...",
|
||||
});
|
||||
|
||||
const { shareTitle, shareImage, shareContent, sharePage } =
|
||||
appStore.getShareConfig;
|
||||
const { name, logo } = appStore.getWebsiteConfig;
|
||||
|
||||
// 分享为首页
|
||||
const isShareWithHome = sharePage == 2;
|
||||
const link = await generateSharePath(isShareWithHome);
|
||||
let resolved = {
|
||||
title: shareTitle,
|
||||
path: link,
|
||||
desc: shareContent,
|
||||
image_url: shareImage,
|
||||
};
|
||||
|
||||
// 非首页可以合并外部参数
|
||||
if (!isShareWithHome) {
|
||||
resolved = {
|
||||
...resolved,
|
||||
...options,
|
||||
};
|
||||
}
|
||||
if (!resolved.title) {
|
||||
if (isShareWithHome) {
|
||||
resolved.title = name;
|
||||
} else {
|
||||
// 1. 用户点击进入页面的后台配置标题
|
||||
// 2. 页面内pagesjson组册的页面标题
|
||||
// 3. 网站名称
|
||||
resolved.title =
|
||||
navigationBarTitleStore.getTitle ||
|
||||
style?.navigationBarTitleText ||
|
||||
name;
|
||||
}
|
||||
}
|
||||
|
||||
if (!resolved.imageUrl) {
|
||||
resolved.imageUrl = logo;
|
||||
}
|
||||
console.log(resolved);
|
||||
// #ifdef H5
|
||||
resolved = resolvedH5Options(resolved) as any;
|
||||
// #endif
|
||||
// #ifdef MP-WEIXIN
|
||||
resolved = resolvedMpOptions(resolved) as any;
|
||||
// #endif
|
||||
uni.hideLoading();
|
||||
return resolved as ShareOptions;
|
||||
};
|
||||
|
||||
// 使用分享,可以单独在页面中使用
|
||||
const useShare = (options: UserShareOptions = {}) => {
|
||||
// #ifdef H5
|
||||
const registerEvent = () => {
|
||||
//@ts-ignore
|
||||
WeixinJSBridge.on("menu:share:appmessage", async function () {
|
||||
const resolved = await resolveOptions(options);
|
||||
//@ts-ignore
|
||||
WeixinJSBridge.invoke("sendAppMessage", resolved);
|
||||
});
|
||||
//@ts-ignore
|
||||
WeixinJSBridge.on("menu:share:timeline", async function () {
|
||||
const resolved = await resolveOptions(options);
|
||||
//@ts-ignore
|
||||
WeixinJSBridge.invoke("shareTimeline", resolved);
|
||||
});
|
||||
};
|
||||
//@ts-ignore
|
||||
if (typeof WeixinJSBridge === "object") {
|
||||
registerEvent();
|
||||
} else {
|
||||
document.addEventListener("WeixinJSBridgeReady", registerEvent, false);
|
||||
}
|
||||
// #endif
|
||||
};
|
||||
|
||||
const removeMixinShare = () => {
|
||||
(shareMixin as any).onShareAppMessage = undefined;
|
||||
};
|
||||
|
||||
return {
|
||||
resolveOptions,
|
||||
useShare,
|
||||
removeMixinShare,
|
||||
};
|
||||
}
|
||||
|
||||
export async function useSharedId() {
|
||||
const options = uni.getEnterOptionsSync()
|
||||
const share_id = options.query.share_id
|
||||
const options = uni.getEnterOptionsSync();
|
||||
const share_id = options.query.share_id;
|
||||
|
||||
if (share_id) {
|
||||
await shareClick({
|
||||
share_id
|
||||
})
|
||||
}
|
||||
if (share_id) {
|
||||
await shareClick({
|
||||
share_id,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,10 +6,7 @@
|
||||
</page-meta>
|
||||
<view class="p-[40rpx]">
|
||||
<view class="flex flex-col bg-white w-full p-[40rpx] rounded-lg">
|
||||
<image
|
||||
src="@/packages/static/images/cancel.png"
|
||||
class="w-[60rpx] h-[60rpx] mx-[auto]"
|
||||
></image>
|
||||
<image src="@/packages/static/images/cancel.png" class="w-[60rpx] h-[60rpx] mx-[auto]"></image>
|
||||
<view class="font-medium text-[32rpx] text-center mt-[30rpx]">
|
||||
注销账号将永久失效且不可恢复,并且放弃以下权益资产和服务
|
||||
</view>
|
||||
@ -25,16 +22,12 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<u-button
|
||||
type="primary"
|
||||
:custom-style="{
|
||||
width: '700rpx',
|
||||
height: '100rpx',
|
||||
borderRadius: '200rpx',
|
||||
color: 'black'
|
||||
}"
|
||||
@click="handlecancel"
|
||||
>
|
||||
<u-button type="primary" :custom-style="{
|
||||
width: '700rpx',
|
||||
height: '100rpx',
|
||||
borderRadius: '200rpx',
|
||||
color: 'black'
|
||||
}" @click="handlecancel">
|
||||
确认注销
|
||||
</u-button>
|
||||
|
||||
@ -61,7 +54,7 @@ const handlecancel = async () => {
|
||||
await cancelled({
|
||||
remark: cancelledRemark.value
|
||||
})
|
||||
router.reLaunch('/pages/index/index')
|
||||
router.reLaunch('/')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -1,38 +1,21 @@
|
||||
<template>
|
||||
<view
|
||||
class="register bg-white min-h-full flex flex-col items-center px-[40rpx] pt-[100rpx] box-border"
|
||||
>
|
||||
<view class="register bg-white min-h-full flex flex-col items-center px-[40rpx] pt-[100rpx] box-border">
|
||||
<view class="w-full">
|
||||
<view class="text-2xl font-medium mb-[60rpx]">
|
||||
{{ type == 'set' ? '设置登录密码' : '修改登录密码' }}
|
||||
</view>
|
||||
<u-form borderBottom :label-width="150">
|
||||
<u-form-item label="原密码" borderBottom v-if="type != 'set'">
|
||||
<u-input
|
||||
class="flex-1"
|
||||
type="password"
|
||||
v-model="formData.oldPassword"
|
||||
:border="false"
|
||||
placeholder="请输入原来的密码"
|
||||
/>
|
||||
<u-input class="flex-1" type="password" v-model="formData.oldPassword" :border="false"
|
||||
placeholder="请输入原来的密码" />
|
||||
</u-form-item>
|
||||
<u-form-item label="新密码" borderBottom>
|
||||
<u-input
|
||||
class="flex-1"
|
||||
type="password"
|
||||
v-model="formData.password"
|
||||
placeholder="6-20位数字+字母或符号组合"
|
||||
:border="false"
|
||||
/>
|
||||
<u-input class="flex-1" type="password" v-model="formData.password" placeholder="6-20位数字+字母或符号组合"
|
||||
:border="false" />
|
||||
</u-form-item>
|
||||
<u-form-item label="确认密码" borderBottom>
|
||||
<u-input
|
||||
class="flex-1"
|
||||
type="password"
|
||||
v-model="formData.password2"
|
||||
placeholder="再次输入新密码"
|
||||
:border="false"
|
||||
/>
|
||||
<u-input class="flex-1" type="password" v-model="formData.password2" placeholder="再次输入新密码"
|
||||
:border="false" />
|
||||
</u-form-item>
|
||||
</u-form>
|
||||
<view class="mt-[100rpx]">
|
||||
@ -66,7 +49,7 @@ const handleConfirm = async () => {
|
||||
await userChangePwd(formData)
|
||||
uni.$u.toast('操作成功')
|
||||
setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
uni.navigateBack()
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
|
||||
@ -148,15 +148,17 @@ const sendSms = async () => {
|
||||
|
||||
const handleConfirm = async () => {
|
||||
if (!formData.mobile && isMobile.value) return uni.$u.toast('请输入手机号码')
|
||||
if (!formData.email && isMailbox.value) return uni.$u.toast('请输入邮箱')
|
||||
if (!formData.email) return uni.$u.toast('请输入邮箱')
|
||||
if (!formData.password) return uni.$u.toast('请输入密码')
|
||||
if (!formData.password2) return uni.$u.toast('请输入确认密码')
|
||||
if (formData.password != formData.password2) return uni.$u.toast('两次输入的密码不一致')
|
||||
if (formData.scene === ForgotPwdSceneEnum.MOBILE) {
|
||||
await forgotPassword(formData)
|
||||
} else if (formData.scene === ForgotPwdSceneEnum.MAILBOX) {
|
||||
await emailForgotPassword(formData)
|
||||
}
|
||||
|
||||
await emailForgotPassword(formData)
|
||||
// if (formData.scene === ForgotPwdSceneEnum.MOBILE) {
|
||||
// await forgotPassword(formData)
|
||||
// } else if (formData.scene === ForgotPwdSceneEnum.MAILBOX) {
|
||||
// await emailForgotPassword(formData)
|
||||
// }
|
||||
uni.$u.toast('操作成功')
|
||||
setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
|
||||
@ -22,55 +22,33 @@
|
||||
</template>
|
||||
</view>
|
||||
</view>
|
||||
<view
|
||||
class="p-[40rpx]"
|
||||
:class="{
|
||||
'mt-[140rpx]': isWeixinLogin
|
||||
}"
|
||||
v-if="showOtherWayBtn"
|
||||
>
|
||||
<view class="p-[40rpx]" :class="{
|
||||
'mt-[140rpx]': isWeixinLogin
|
||||
}" v-if="showOtherWayBtn">
|
||||
<u-divider>其他登录方式</u-divider>
|
||||
<div class="flex justify-around mt-[40rpx] px-[80rpx]">
|
||||
<div
|
||||
class="flex flex-col items-center"
|
||||
v-if="hasWeixinLogin && !isWeixinLogin"
|
||||
@click="changeLoginWay(LoginWayEnum.WEIXIN)"
|
||||
>
|
||||
<div class="flex flex-col items-center" v-if="hasWeixinLogin && !isWeixinLogin"
|
||||
@click="changeLoginWay(LoginWayEnum.WEIXIN)">
|
||||
<u-icon name="/static/images/icon/icon_wx.png" :size="80" />
|
||||
<div class="text-sm mt-[10px]">微信登录</div>
|
||||
</div>
|
||||
<div
|
||||
class="flex flex-col items-center"
|
||||
v-if="hasMobileLogin && !isMobileLogin"
|
||||
@click="changeLoginWay(LoginWayEnum.MOBILE)"
|
||||
>
|
||||
<div class="flex flex-col items-center" v-if="hasMobileLogin && !isMobileLogin"
|
||||
@click="changeLoginWay(LoginWayEnum.MOBILE)">
|
||||
<u-icon name="/static/images/icon/icon_phone.png" :size="80" />
|
||||
<div class="text-sm mt-[10px]">手机号登录</div>
|
||||
</div>
|
||||
<div
|
||||
class="flex flex-col items-center"
|
||||
v-if="hasMailboxLogin && !isMailboxLogin"
|
||||
@click="changeLoginWay(LoginWayEnum.MAILBOX)"
|
||||
>
|
||||
<div class="flex flex-col items-center" v-if="hasMailboxLogin && !isMailboxLogin"
|
||||
@click="changeLoginWay(LoginWayEnum.MAILBOX)">
|
||||
<u-icon name="/static/images/icon/icon_email.png" :size="80" />
|
||||
<div class="text-sm mt-[10px]">邮箱登录</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- <agreement /> -->
|
||||
</view>
|
||||
<update-user-info
|
||||
v-model:show="showLoginPopup"
|
||||
:logo="websiteConfig?.logo"
|
||||
:title="websiteConfig?.name"
|
||||
:userInfo="loginData"
|
||||
@update="handleUpdateUser"
|
||||
/>
|
||||
<bind-mobile
|
||||
v-model:show="showBindMobilePopup"
|
||||
:userInfo="loginData"
|
||||
@success="bindMobileSuccess"
|
||||
@close="removeWxQuery"
|
||||
/>
|
||||
<update-user-info v-model:show="showLoginPopup" :logo="websiteConfig?.logo" :title="websiteConfig?.name"
|
||||
:userInfo="loginData" @update="handleUpdateUser" />
|
||||
<bind-mobile v-model:show="showBindMobilePopup" :userInfo="loginData" @success="bindMobileSuccess"
|
||||
@close="removeWxQuery" />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@ -88,7 +66,7 @@ import {
|
||||
mobileLogin,
|
||||
accountLogin,
|
||||
emailLogin,
|
||||
uninAppLogin,
|
||||
uninAppLogin,
|
||||
mnpLogin as mnpLoginApi
|
||||
} from '@/api/account'
|
||||
import { updateUser } from '@/api/user'
|
||||
@ -201,7 +179,7 @@ const loginHandle = async () => {
|
||||
router.switchTab(cache.get(BACK_URL))
|
||||
}
|
||||
} else {
|
||||
router.reLaunch('/pages/index/index')
|
||||
router.reLaunch('/')
|
||||
}
|
||||
cache.remove(BACK_URL)
|
||||
}
|
||||
@ -230,7 +208,7 @@ const loginAfter = (() => {
|
||||
cache.remove(SHARE_ID)
|
||||
cache.remove(USER_SN)
|
||||
}
|
||||
} catch (error) {}
|
||||
} catch (error) { }
|
||||
}
|
||||
const updateUsers = async () => {
|
||||
if (loginData.value.isNew && !showLoginPopup.value) {
|
||||
@ -242,7 +220,7 @@ const loginAfter = (() => {
|
||||
},
|
||||
{ token: loginData.value.token }
|
||||
)
|
||||
} catch (error) {}
|
||||
} catch (error) { }
|
||||
} else if (showLoginPopup.value) {
|
||||
return Promise.reject()
|
||||
}
|
||||
@ -267,9 +245,9 @@ const { lockFn: wxLoginLock, isLock } = useLockFn(async () => {
|
||||
data = await mnpLogin()
|
||||
// #endif
|
||||
|
||||
// #ifdef APP-PLUS
|
||||
data = await appLogin()
|
||||
// #endif
|
||||
// #ifdef APP-PLUS
|
||||
data = await appLogin()
|
||||
// #endif
|
||||
|
||||
if (data) {
|
||||
loginData.value = data
|
||||
|
||||
@ -1,43 +1,43 @@
|
||||
import { getUserCenter } from '@/api/user'
|
||||
import { TOKEN_KEY } from '@/enums/constantEnums'
|
||||
import { useSharedId } from '@/hooks/useShareMessage'
|
||||
import { getToken } from '@/utils/auth'
|
||||
import cache from '@/utils/cache'
|
||||
import { defineStore } from 'pinia'
|
||||
import { getUserCenter } from "@/api/user";
|
||||
import { TOKEN_KEY } from "@/enums/constantEnums";
|
||||
import { useSharedId } from "@/hooks/useShareMessage";
|
||||
import { getToken } from "@/utils/auth";
|
||||
import cache from "@/utils/cache";
|
||||
import { defineStore } from "pinia";
|
||||
|
||||
interface UserSate {
|
||||
userInfo: Record<string, any>
|
||||
token: string | null
|
||||
client: string | null
|
||||
temToken: string | null
|
||||
userInfo: Record<string, any>;
|
||||
token: string | null;
|
||||
client: string | null;
|
||||
temToken: string | null;
|
||||
}
|
||||
export const useUserStore = defineStore({
|
||||
id: 'userStore',
|
||||
state: (): UserSate => ({
|
||||
userInfo: {},
|
||||
token: getToken() || null,
|
||||
client: null,
|
||||
temToken: null
|
||||
}),
|
||||
getters: {
|
||||
isLogin: (state) => !!state.token
|
||||
id: "userStore",
|
||||
state: (): UserSate => ({
|
||||
userInfo: {},
|
||||
token: getToken() || null,
|
||||
client: null,
|
||||
temToken: null,
|
||||
}),
|
||||
getters: {
|
||||
isLogin: (state) => !!state.token,
|
||||
},
|
||||
actions: {
|
||||
async getUser() {
|
||||
const data = await getUserCenter({
|
||||
token: this.token,
|
||||
});
|
||||
this.userInfo = data;
|
||||
},
|
||||
actions: {
|
||||
async getUser() {
|
||||
const data = await getUserCenter({
|
||||
token: this.token
|
||||
})
|
||||
this.userInfo = data
|
||||
},
|
||||
login(token: string) {
|
||||
cache.set(TOKEN_KEY, token)
|
||||
this.token = token
|
||||
useSharedId()
|
||||
},
|
||||
logout() {
|
||||
this.token = ''
|
||||
this.userInfo = {}
|
||||
cache.remove(TOKEN_KEY)
|
||||
}
|
||||
}
|
||||
})
|
||||
login(token: string) {
|
||||
cache.set(TOKEN_KEY, token);
|
||||
this.token = token;
|
||||
useSharedId();
|
||||
},
|
||||
logout() {
|
||||
this.token = "";
|
||||
this.userInfo = {};
|
||||
cache.remove(TOKEN_KEY);
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@ -1,6 +1,20 @@
|
||||
import { TOKEN_KEY } from '@/enums/cacheEnums'
|
||||
import cache from './cache'
|
||||
import { TOKEN_KEY } from "@/enums/cacheEnums";
|
||||
import cache from "./cache";
|
||||
import Cookies from "js-cookie";
|
||||
|
||||
// 判断是否为企微环境
|
||||
const isWechatWork = () => {
|
||||
const ua = navigator.userAgent.toLowerCase();
|
||||
return ua.includes("micromessenger") && ua.includes("wxwork");
|
||||
};
|
||||
|
||||
export function getToken() {
|
||||
return cache.get(TOKEN_KEY) || ''
|
||||
if (isWechatWork()) {
|
||||
const token = Cookies.get("token");
|
||||
const obj = { expire: "", value: token };
|
||||
localStorage.setItem("app_token", JSON.stringify(obj));
|
||||
return token || "";
|
||||
} else {
|
||||
return cache.get(TOKEN_KEY) || "";
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,137 +1,138 @@
|
||||
import HttpRequest from './http'
|
||||
import { merge } from 'lodash-es'
|
||||
import HttpRequest from "./http";
|
||||
import { merge } from "lodash-es";
|
||||
import {
|
||||
HttpRequestOptions,
|
||||
RequestHooks,
|
||||
RequestConfig,
|
||||
RequestEventStreamConfig,
|
||||
RequestOptions,
|
||||
UploadFileOption
|
||||
} from './type'
|
||||
import { getToken } from '../auth'
|
||||
import { RequestCodeEnum, RequestMethodsEnum } from '@/enums/requestEnums'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import { client } from '../client'
|
||||
import router from '@/router'
|
||||
import appConfig from '@/config'
|
||||
HttpRequestOptions,
|
||||
RequestHooks,
|
||||
RequestConfig,
|
||||
RequestEventStreamConfig,
|
||||
RequestOptions,
|
||||
UploadFileOption,
|
||||
} from "./type";
|
||||
import { getToken } from "../auth";
|
||||
import { RequestCodeEnum, RequestMethodsEnum } from "@/enums/requestEnums";
|
||||
import { useUserStore } from "@/stores/user";
|
||||
import { client } from "../client";
|
||||
import router from "@/router";
|
||||
import appConfig from "@/config";
|
||||
import Cookies from "js-cookie";
|
||||
|
||||
export type {
|
||||
RequestConfig,
|
||||
RequestEventStreamConfig,
|
||||
RequestOptions,
|
||||
UploadFileOption
|
||||
}
|
||||
RequestConfig,
|
||||
RequestEventStreamConfig,
|
||||
RequestOptions,
|
||||
UploadFileOption,
|
||||
};
|
||||
|
||||
const requestHooks: RequestHooks = {
|
||||
requestInterceptorsHook(options, config) {
|
||||
const { urlPrefix, baseUrl, withToken } = config
|
||||
options.header = options.header ?? {}
|
||||
if (urlPrefix) {
|
||||
options.url = `${urlPrefix}${options.url}`
|
||||
}
|
||||
if (baseUrl) {
|
||||
options.url = `${baseUrl}${options.url}`
|
||||
}
|
||||
//#ifndef APP-PLUS
|
||||
const token = useUserStore().token || null
|
||||
//#endif
|
||||
//#ifdef APP-PLUS
|
||||
const token = useUserStore().token || 'null'
|
||||
//#endif
|
||||
// 添加token
|
||||
if (withToken) {
|
||||
options.header['ai-token'] = options.header.token || token
|
||||
}
|
||||
// 添加终端类型
|
||||
options.header['terminal'] = useUserStore().client || client
|
||||
delete options.header.token
|
||||
options.header.version = appConfig.version
|
||||
return options
|
||||
},
|
||||
async responseInterceptorsHook(response, config, options) {
|
||||
const { isTransformResponse, isReturnDefaultResponse, isAuth } = config
|
||||
|
||||
//返回默认响应,当需要获取响应头及其他数据时可使用
|
||||
if (isReturnDefaultResponse) {
|
||||
return response
|
||||
}
|
||||
// 是否需要对数据进行处理
|
||||
if (!isTransformResponse) {
|
||||
return response.data
|
||||
}
|
||||
const { logout } = useUserStore()
|
||||
const { code, data, msg, show } = response.data as any
|
||||
switch (code) {
|
||||
case RequestCodeEnum.SUCCESS:
|
||||
return data
|
||||
case RequestCodeEnum.PARAMS_TYPE_ERROR:
|
||||
case RequestCodeEnum.PARAMS_VALID_ERROR:
|
||||
case RequestCodeEnum.REQUEST_METHOD_ERROR:
|
||||
case RequestCodeEnum.ASSERT_ARGUMENT_ERROR:
|
||||
case RequestCodeEnum.ASSERT_MYBATIS_ERROR:
|
||||
case RequestCodeEnum.LOGIN_ACCOUNT_ERROR:
|
||||
case RequestCodeEnum.LOGIN_DISABLE_ERROR:
|
||||
case RequestCodeEnum.NO_PERMISSTION:
|
||||
case RequestCodeEnum.FAILED:
|
||||
case RequestCodeEnum.SYSTEM_ERROR:
|
||||
case RequestCodeEnum.DRAW_ERROR:
|
||||
uni.$u.toast(msg)
|
||||
return Promise.reject(msg)
|
||||
case RequestCodeEnum.REQUEST_404_ERROR:
|
||||
uni.$u.toast(msg)
|
||||
return Promise.reject(msg)
|
||||
|
||||
case RequestCodeEnum.TOKEN_INVALID:
|
||||
logout()
|
||||
if (isAuth && options.method?.toUpperCase() !== 'GET') {
|
||||
router.navigateTo({ path: '/pages/login/login' })
|
||||
}
|
||||
return Promise.reject(msg)
|
||||
case RequestCodeEnum.TOKEN_EMPTY:
|
||||
logout()
|
||||
if (isAuth && !getToken()) {
|
||||
router.navigateTo('/pages/login/login')
|
||||
}
|
||||
return Promise.reject()
|
||||
|
||||
default:
|
||||
return data
|
||||
}
|
||||
},
|
||||
async responseInterceptorsCatchHook(options, error) {
|
||||
if (options.method?.toUpperCase() == RequestMethodsEnum.POST) {
|
||||
uni.$u.toast('请求失败,请重试')
|
||||
}
|
||||
return Promise.reject(error)
|
||||
requestInterceptorsHook(options, config) {
|
||||
const { urlPrefix, baseUrl, withToken } = config;
|
||||
options.header = options.header ?? {};
|
||||
if (urlPrefix) {
|
||||
options.url = `${urlPrefix}${options.url}`;
|
||||
}
|
||||
}
|
||||
if (baseUrl) {
|
||||
options.url = `${baseUrl}${options.url}`;
|
||||
}
|
||||
//#ifndef APP-PLUS
|
||||
const token = useUserStore().token || null;
|
||||
//#endif
|
||||
//#ifdef APP-PLUS
|
||||
const token = useUserStore().token || "null";
|
||||
//#endif
|
||||
// 添加token
|
||||
if (withToken) {
|
||||
options.header["ai-token"] = options.header.token || token;
|
||||
}
|
||||
// 添加终端类型
|
||||
options.header["terminal"] = useUserStore().client || client;
|
||||
delete options.header.token;
|
||||
options.header.version = appConfig.version;
|
||||
return options;
|
||||
},
|
||||
async responseInterceptorsHook(response, config, options) {
|
||||
const { isTransformResponse, isReturnDefaultResponse, isAuth } = config;
|
||||
|
||||
//返回默认响应,当需要获取响应头及其他数据时可使用
|
||||
if (isReturnDefaultResponse) {
|
||||
return response;
|
||||
}
|
||||
// 是否需要对数据进行处理
|
||||
if (!isTransformResponse) {
|
||||
return response.data;
|
||||
}
|
||||
const { logout } = useUserStore();
|
||||
const { code, data, msg, show } = response.data as any;
|
||||
switch (code) {
|
||||
case RequestCodeEnum.SUCCESS:
|
||||
return data;
|
||||
case RequestCodeEnum.PARAMS_TYPE_ERROR:
|
||||
case RequestCodeEnum.PARAMS_VALID_ERROR:
|
||||
case RequestCodeEnum.REQUEST_METHOD_ERROR:
|
||||
case RequestCodeEnum.ASSERT_ARGUMENT_ERROR:
|
||||
case RequestCodeEnum.ASSERT_MYBATIS_ERROR:
|
||||
case RequestCodeEnum.LOGIN_ACCOUNT_ERROR:
|
||||
case RequestCodeEnum.LOGIN_DISABLE_ERROR:
|
||||
case RequestCodeEnum.NO_PERMISSTION:
|
||||
case RequestCodeEnum.FAILED:
|
||||
case RequestCodeEnum.SYSTEM_ERROR:
|
||||
case RequestCodeEnum.DRAW_ERROR:
|
||||
uni.$u.toast(msg);
|
||||
return Promise.reject(msg);
|
||||
case RequestCodeEnum.REQUEST_404_ERROR:
|
||||
uni.$u.toast(msg);
|
||||
return Promise.reject(msg);
|
||||
|
||||
case RequestCodeEnum.TOKEN_INVALID:
|
||||
logout();
|
||||
if (isAuth && options.method?.toUpperCase() !== "GET") {
|
||||
router.navigateTo({ path: "/pages/login/login" });
|
||||
}
|
||||
return Promise.reject(msg);
|
||||
case RequestCodeEnum.TOKEN_EMPTY:
|
||||
logout();
|
||||
if (isAuth && !getToken()) {
|
||||
router.navigateTo("/pages/login/login");
|
||||
}
|
||||
return Promise.reject();
|
||||
|
||||
default:
|
||||
return data;
|
||||
}
|
||||
},
|
||||
async responseInterceptorsCatchHook(options, error) {
|
||||
if (options.method?.toUpperCase() == RequestMethodsEnum.POST) {
|
||||
uni.$u.toast("请求失败,请重试");
|
||||
}
|
||||
return Promise.reject(error);
|
||||
},
|
||||
};
|
||||
|
||||
const defaultOptions: HttpRequestOptions = {
|
||||
requestOptions: {
|
||||
timeout: appConfig.timeout
|
||||
},
|
||||
baseUrl: appConfig.baseUrl,
|
||||
//是否返回默认的响应
|
||||
isReturnDefaultResponse: false,
|
||||
// 需要对返回数据进行处理
|
||||
isTransformResponse: true,
|
||||
// 接口拼接地址
|
||||
urlPrefix: appConfig.urlPrefix,
|
||||
// 忽略重复请求
|
||||
ignoreCancel: false,
|
||||
// 是否携带token
|
||||
withToken: true,
|
||||
isAuth: false,
|
||||
retryCount: 2,
|
||||
retryTimeout: 1000,
|
||||
requestHooks: requestHooks
|
||||
}
|
||||
requestOptions: {
|
||||
timeout: appConfig.timeout,
|
||||
},
|
||||
baseUrl: appConfig.baseUrl,
|
||||
//是否返回默认的响应
|
||||
isReturnDefaultResponse: false,
|
||||
// 需要对返回数据进行处理
|
||||
isTransformResponse: true,
|
||||
// 接口拼接地址
|
||||
urlPrefix: appConfig.urlPrefix,
|
||||
// 忽略重复请求
|
||||
ignoreCancel: false,
|
||||
// 是否携带token
|
||||
withToken: true,
|
||||
isAuth: false,
|
||||
retryCount: 2,
|
||||
retryTimeout: 1000,
|
||||
requestHooks: requestHooks,
|
||||
};
|
||||
|
||||
function createRequest(opt?: HttpRequestOptions) {
|
||||
return new HttpRequest(
|
||||
// 深度合并
|
||||
merge(defaultOptions, opt || {})
|
||||
)
|
||||
return new HttpRequest(
|
||||
// 深度合并
|
||||
merge(defaultOptions, opt || {})
|
||||
);
|
||||
}
|
||||
const request = createRequest()
|
||||
export default request
|
||||
const request = createRequest();
|
||||
export default request;
|
||||
|
||||
63
src/utils/request/type.d.ts
vendored
63
src/utils/request/type.d.ts
vendored
@ -1,42 +1,45 @@
|
||||
export type RequestOptions = UniApp.RequestOptions
|
||||
export type RequestOptions = UniApp.RequestOptions;
|
||||
export type ResponseResult =
|
||||
| UniApp.RequestSuccessCallbackResult
|
||||
| UniApp.UploadFileSuccessCallbackResult
|
||||
export type RequestOptionsResponseError = UniApp.GeneralCallbackResult
|
||||
export type RequestTask = UniApp.RequestTask
|
||||
export type UploadFileOption = UniApp.UploadFileOption
|
||||
| UniApp.RequestSuccessCallbackResult
|
||||
| UniApp.UploadFileSuccessCallbackResult;
|
||||
export type RequestOptionsResponseError = UniApp.GeneralCallbackResult;
|
||||
export type RequestTask = UniApp.RequestTask;
|
||||
export type UploadFileOption = UniApp.UploadFileOption;
|
||||
export interface HttpRequestOptions extends RequestConfig {
|
||||
requestOptions: Partial<RequestOptions>
|
||||
requestOptions: Partial<RequestOptions>;
|
||||
}
|
||||
|
||||
export interface RequestConfig {
|
||||
baseUrl: string
|
||||
requestHooks: RequestHooks
|
||||
isReturnDefaultResponse: boolean
|
||||
isTransformResponse: boolean
|
||||
urlPrefix: string
|
||||
ignoreCancel: boolean
|
||||
withToken: boolean
|
||||
isAuth: boolean
|
||||
retryCount: number
|
||||
retryTimeout: number
|
||||
hasRetryCount?: number
|
||||
//上传文件独有
|
||||
onProgress?: (progress: number) => void
|
||||
baseUrl: string;
|
||||
requestHooks: RequestHooks;
|
||||
isReturnDefaultResponse: boolean;
|
||||
isTransformResponse: boolean;
|
||||
urlPrefix: string;
|
||||
ignoreCancel: boolean;
|
||||
withToken: boolean;
|
||||
isAuth: boolean;
|
||||
retryCount: number;
|
||||
retryTimeout: number;
|
||||
hasRetryCount?: number;
|
||||
//上传文件独有
|
||||
onProgress?: (progress: number) => void;
|
||||
}
|
||||
|
||||
export interface RequestEventStreamConfig extends Partial<RequestConfig> {
|
||||
onstart?: (event: AbortController | UniApp.RequestTask) => void
|
||||
onmessage?: (value: string) => void
|
||||
onclose?: () => void
|
||||
onstart?: (event: AbortController | UniApp.RequestTask) => void;
|
||||
onmessage?: (value: string) => void;
|
||||
onclose?: () => void;
|
||||
}
|
||||
|
||||
export interface RequestHooks {
|
||||
requestInterceptorsHook?(options: RequestOptions, config: RequestConfig): RequestOptions
|
||||
responseInterceptorsHook?(
|
||||
response: ResponseResult,
|
||||
config: RequestConfig,
|
||||
options: RequestOptions
|
||||
): any
|
||||
responseInterceptorsCatchHook?(options: RequestOptions, error: any): any
|
||||
requestInterceptorsHook?(
|
||||
options: RequestOptions,
|
||||
config: RequestConfig
|
||||
): RequestOptions;
|
||||
responseInterceptorsHook?(
|
||||
response: ResponseResult,
|
||||
config: RequestConfig,
|
||||
options: RequestOptions
|
||||
): any;
|
||||
responseInterceptorsCatchHook?(options: RequestOptions, error: any): any;
|
||||
}
|
||||
|
||||
@ -1,43 +1,61 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import uni from '@dcloudio/vite-plugin-uni'
|
||||
import tailwindcss from 'tailwindcss'
|
||||
import autoprefixer from 'autoprefixer'
|
||||
import postcssRemToResponsivePixel from 'postcss-rem-to-responsive-pixel'
|
||||
import postcssWeappTailwindcssRename from 'weapp-tailwindcss-webpack-plugin/postcss'
|
||||
import vwt from 'weapp-tailwindcss-webpack-plugin/vite'
|
||||
import uniRouter from 'unplugin-uni-router/vite'
|
||||
import { defineConfig, loadEnv } from "vite";
|
||||
import uni from "@dcloudio/vite-plugin-uni";
|
||||
import tailwindcss from "tailwindcss";
|
||||
import autoprefixer from "autoprefixer";
|
||||
import postcssRemToResponsivePixel from "postcss-rem-to-responsive-pixel";
|
||||
import postcssWeappTailwindcssRename from "weapp-tailwindcss-webpack-plugin/postcss";
|
||||
import vwt from "weapp-tailwindcss-webpack-plugin/vite";
|
||||
import uniRouter from "unplugin-uni-router/vite";
|
||||
|
||||
const isH5 = process.env.UNI_PLATFORM === 'h5'
|
||||
const isApp = process.env.UNI_PLATFORM === 'app'
|
||||
const weappTailwindcssDisabled = isH5 || isApp
|
||||
const isH5 = process.env.UNI_PLATFORM === "h5";
|
||||
const isApp = process.env.UNI_PLATFORM === "app";
|
||||
const weappTailwindcssDisabled = isH5 || isApp;
|
||||
|
||||
const postcssPlugin = [autoprefixer(), tailwindcss()]
|
||||
const postcssPlugin = [autoprefixer(), tailwindcss()];
|
||||
if (!weappTailwindcssDisabled) {
|
||||
postcssPlugin.push(
|
||||
postcssRemToResponsivePixel({
|
||||
rootValue: 32,
|
||||
propList: ['*'],
|
||||
transformUnit: 'rpx'
|
||||
})
|
||||
)
|
||||
postcssPlugin.push(postcssWeappTailwindcssRename())
|
||||
postcssPlugin.push(
|
||||
postcssRemToResponsivePixel({
|
||||
rootValue: 32,
|
||||
propList: ["*"],
|
||||
transformUnit: "rpx",
|
||||
})
|
||||
);
|
||||
postcssPlugin.push(postcssWeappTailwindcssRename());
|
||||
}
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
export default defineConfig(({ command, mode }) => {
|
||||
console.log("mode:", mode);
|
||||
const env = loadEnv(mode, process.cwd(), "");
|
||||
return {
|
||||
plugins: [
|
||||
uni(),
|
||||
uniRouter({
|
||||
includes: ['style']
|
||||
}),
|
||||
weappTailwindcssDisabled ? undefined : vwt()
|
||||
uni(),
|
||||
uniRouter({
|
||||
includes: ["style"],
|
||||
}),
|
||||
weappTailwindcssDisabled ? undefined : vwt(),
|
||||
],
|
||||
css: {
|
||||
postcss: {
|
||||
plugins: postcssPlugin
|
||||
}
|
||||
postcss: {
|
||||
plugins: postcssPlugin,
|
||||
},
|
||||
},
|
||||
server: {
|
||||
port: 8991
|
||||
}
|
||||
})
|
||||
port: 8991,
|
||||
},
|
||||
base: mode != "dev" ? env.VITE_CDN_DIR : "./",
|
||||
build: {
|
||||
assetsDir: "static", // 静态资源存放目录(默认是 assets)
|
||||
rollupOptions: {
|
||||
output: {
|
||||
// 代码分割配置
|
||||
manualChunks: (id) => {
|
||||
if (id.includes("node_modules")) {
|
||||
return "vendor";
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user