Skip to content

Commit

Permalink
chore: 一些代码结构调整
Browse files Browse the repository at this point in the history
  • Loading branch information
oyjt committed Nov 23, 2024
1 parent d0af03c commit 2fc1477
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 46 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "uniapp-vue3-project",
"type": "module",
"version": "1.1.3",
"version": "1.1.5",
"description": "uniapp 团队协作开发实践模板(Vue3)",
"author": {
"name": "江阳小道",
Expand Down
7 changes: 1 addition & 6 deletions src/hooks/use-clipboard/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
interface SetClipboardDataOptions {
data: string;
showToast?: boolean;
}

/**
* 剪切板
* @example
Expand All @@ -13,7 +8,7 @@ interface SetClipboardDataOptions {
* const data = await getClipboardData()
*/
export default function useClipboard() {
const setClipboardData = ({ data, showToast = true }: SetClipboardDataOptions) => {
const setClipboardData = ({ data, showToast = true }: UniApp.SetClipboardDataOptions) => {
return new Promise<string>((resolve, reject) => {
uni.setClipboardData({
data,
Expand Down
13 changes: 4 additions & 9 deletions src/hooks/use-share/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
interface UseShareOptions {
title?: string;
path?: string;
query?: string;
imageUrl?: string;
}
import type { ShareOptions } from './types';

/**
* 小程序分享
Expand All @@ -17,14 +12,14 @@ interface UseShareOptions {
* onShareAppMessage()
* onShareTimeline()
*/
export default function useShare(options?: UseShareOptions) {
export default function useShare(options?: ShareOptions) {
// #ifdef MP-WEIXIN
const title = options?.title ?? '';
const path = options?.path ?? '';
const query = options?.query ?? '';
const imageUrl = options?.imageUrl ?? '';

const shareApp = (params: UseShareOptions = {}) => {
const shareApp = (params: ShareOptions = {}) => {
onShareAppMessage(() => {
return {
title,
Expand All @@ -35,7 +30,7 @@ export default function useShare(options?: UseShareOptions) {
});
};

const shareTime = (params: UseShareOptions = {}) => {
const shareTime = (params: ShareOptions = {}) => {
onShareTimeline(() => {
return {
title,
Expand Down
6 changes: 6 additions & 0 deletions src/hooks/use-share/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export interface ShareOptions {
title?: string;
path?: string;
query?: string;
imageUrl?: string;
}
5 changes: 2 additions & 3 deletions src/store/modules/user/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { LoginParams } from '@/api/user/types';

import type { LoginReq } from '@/api/user/types';
import type { providerType, UserState } from './types';
import { UserApi } from '@/api';
import { clearToken, setToken } from '@/utils/auth';
Expand Down Expand Up @@ -33,7 +32,7 @@ const useUserStore = defineStore('user', {
this.setInfo(result);
},
// 异步登录并存储token
login(loginForm: LoginParams) {
login(loginForm: LoginReq) {
return new Promise((resolve, reject) => {
UserApi.login(loginForm).then((res) => {
const token = res.token;
Expand Down
26 changes: 1 addition & 25 deletions src/utils/modals/index.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,4 @@
interface IShowToastOptions {
title?: string;
icon?: 'success' | 'loading' | 'error' | 'none';
image?: string;
duration?: number;
position?: 'top' | 'center' | 'bottom';
mask?: boolean;
}

interface ILoadingOptions {
show?: (content?: string) => void;
hide?: () => void;
}

interface IShowModalOptions {
title?: string;
content?: string;
showCancel?: boolean;
cancelText?: string;
cancelColor?: string;
confirmText?: string;
confirmColor?: string;
editable?: boolean;
placeholderText?: string;
}
import type { ILoadingOptions, IShowModalOptions, IShowToastOptions } from './types';

/**
* 轻提示
Expand Down
25 changes: 25 additions & 0 deletions src/utils/modals/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
export interface IShowToastOptions {
title?: string;
icon?: 'success' | 'loading' | 'error' | 'none';
image?: string;
duration?: number;
position?: 'top' | 'center' | 'bottom';
mask?: boolean;
}

export interface ILoadingOptions {
show?: (content?: string) => void;
hide?: () => void;
}

export interface IShowModalOptions {
title?: string;
content?: string;
showCancel?: boolean;
cancelText?: string;
cancelColor?: string;
confirmText?: string;
confirmColor?: string;
editable?: boolean;
placeholderText?: string;
}
2 changes: 1 addition & 1 deletion src/utils/request/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// 引入配置
import type { HttpRequestConfig, HttpResponse } from 'uview-plus/libs/luch-request/index';
import type { IResponse } from './type';
import type { IResponse } from './types';
import Request from 'uview-plus/libs/luch-request/index';
import { requestInterceptors, responseInterceptors } from './interceptors';

Expand Down
2 changes: 1 addition & 1 deletion src/utils/request/interceptors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type {
HttpRequestConfig,
HttpResponse,
} from 'uview-plus/libs/luch-request/index';
import useUserStore from '@/store';
import { useUserStore } from '@/store';
import { getToken } from '@/utils/auth';
import storage from '@/utils/storage';
import { showMessage } from './status';
Expand Down
File renamed without changes.

0 comments on commit 2fc1477

Please sign in to comment.