Skip to content

Commit

Permalink
feat(projects): merge remote project v1.3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
paynezhuang committed Oct 30, 2024
1 parent 8b95b33 commit e4a4e59
Show file tree
Hide file tree
Showing 39 changed files with 1,775 additions and 1,489 deletions.
3 changes: 0 additions & 3 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
"dbaeumer.vscode-eslint",
"editorconfig.editorconfig",
"esbenp.prettier-vscode",
"formulahendry.auto-close-tag",
"formulahendry.auto-complete-tag",
"formulahendry.auto-rename-tag",
"lokalise.i18n-ally",
"mhutchie.git-graph",
"mikestead.dotenv",
Expand Down
6 changes: 1 addition & 5 deletions build/plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@ import { setupHtmlPlugin } from './html';

export function setupVitePlugins(viteEnv: Env.ImportMeta, buildTime: string) {
const plugins: PluginOption = [
vue({
script: {
defineModel: true
}
}),
vue(),
vueJsx(),
VueDevtools(),
setupElegantRouter(),
Expand Down
10 changes: 2 additions & 8 deletions build/plugins/unplugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { PluginOption } from 'vite';
import Icons from 'unplugin-icons/vite';
import IconsResolver from 'unplugin-icons/resolver';
import Components from 'unplugin-vue-components/vite';
import { AntDesignVueResolver, NaiveUiResolver } from 'unplugin-vue-components/resolvers';
import { NaiveUiResolver } from 'unplugin-vue-components/resolvers';
import { FileSystemIconLoader } from 'unplugin-icons/loaders';
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons';

Expand All @@ -28,13 +28,7 @@ export function setupUnplugin(viteEnv: Env.ImportMeta) {
Components({
dts: 'src/typings/components.d.ts',
types: [{ from: 'vue-router', names: ['RouterLink', 'RouterView'] }],
resolvers: [
AntDesignVueResolver({
importStyle: false
}),
NaiveUiResolver(),
IconsResolver({ customCollections: [collectionName], componentPrefix: VITE_ICON_PREFIX })
]
resolvers: [NaiveUiResolver(), IconsResolver({ customCollections: [collectionName], componentPrefix: VITE_ICON_PREFIX })]
}),
createSvgIconsPlugin({
iconDirs: [localIconPath],
Expand Down
50 changes: 25 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,49 +45,49 @@
"@sa/hooks": "workspace:*",
"@sa/materials": "workspace:*",
"@sa/utils": "workspace:*",
"@vueuse/core": "11.0.3",
"@vueuse/core": "11.1.0",
"clipboard": "2.0.11",
"dayjs": "1.11.13",
"echarts": "5.5.1",
"json5": "2.2.3",
"naive-ui": "2.39.0",
"naive-ui": "2.40.1",
"nprogress": "0.2.0",
"pinia": "2.2.2",
"tailwind-merge": "2.5.2",
"vue": "3.5.3",
"vue-draggable-plus": "0.5.3",
"vue-i18n": "9.14.0",
"vue-router": "4.4.3"
"pinia": "2.2.4",
"tailwind-merge": "2.5.4",
"vue": "3.5.12",
"vue-draggable-plus": "0.5.4",
"vue-i18n": "10.0.4",
"vue-router": "4.4.5"
},
"devDependencies": {
"@elegant-router/vue": "0.3.8",
"@iconify/json": "2.2.245",
"@iconify/json": "2.2.263",
"@sa/scripts": "workspace:*",
"@sa/uno-preset": "workspace:*",
"@soybeanjs/eslint-config": "1.4.1",
"@types/node": "22.5.4",
"@soybeanjs/eslint-config": "1.4.2",
"@types/node": "22.7.9",
"@types/nprogress": "0.2.3",
"@unocss/eslint-config": "0.62.3",
"@unocss/preset-icons": "0.62.3",
"@unocss/preset-uno": "0.62.3",
"@unocss/transformer-directives": "0.62.3",
"@unocss/transformer-variant-group": "0.62.3",
"@unocss/vite": "0.62.3",
"@vitejs/plugin-vue": "5.1.3",
"@unocss/eslint-config": "0.63.6",
"@unocss/preset-icons": "0.63.6",
"@unocss/preset-uno": "0.63.6",
"@unocss/transformer-directives": "0.63.6",
"@unocss/transformer-variant-group": "0.63.6",
"@unocss/vite": "0.63.6",
"@vitejs/plugin-vue": "5.1.4",
"@vitejs/plugin-vue-jsx": "4.0.1",
"eslint": "9.10.0",
"eslint-plugin-vue": "9.28.0",
"eslint": "9.13.0",
"eslint-plugin-vue": "9.29.1",
"lint-staged": "15.2.10",
"sass": "1.78.0",
"sass": "1.80.4",
"simple-git-hooks": "2.11.1",
"tsx": "4.19.0",
"typescript": "5.5.4",
"tsx": "4.19.1",
"typescript": "5.6.3",
"unplugin-icons": "0.19.3",
"unplugin-vue-components": "0.27.4",
"vite": "5.4.3",
"vite": "5.4.10",
"vite-plugin-progress": "0.0.7",
"vite-plugin-svg-icons": "2.0.1",
"vite-plugin-vue-devtools": "7.4.4",
"vite-plugin-vue-devtools": "7.5.4",
"vue-eslint-parser": "9.4.3",
"vue-tsc": "2.1.6"
},
Expand Down
20 changes: 20 additions & 0 deletions packages/alova/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "@sa/alova",
"version": "1.3.8",
"exports": {
".": "./src/index.ts",
"./fetch": "./src/fetch.ts",
"./client": "./src/client.ts",
"./mock": "./src/mock.ts"
},
"typesVersions": {
"*": {
"*": ["./src/*"]
}
},
"dependencies": {
"@alova/mock": "2.0.8",
"@sa/utils": "workspace:*",
"alova": "3.1.1"
}
}
1 change: 1 addition & 0 deletions packages/alova/src/client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from 'alova/client';
2 changes: 2 additions & 0 deletions packages/alova/src/constant.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/** the backend error code key */
export const BACKEND_ERROR_CODE = 'BACKEND_ERROR';
2 changes: 2 additions & 0 deletions packages/alova/src/fetch.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import adapterFetch from 'alova/fetch';
export default adapterFetch;
75 changes: 75 additions & 0 deletions packages/alova/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import { createAlova } from 'alova';
import type { AlovaDefaultCacheAdapter, AlovaGenerics, AlovaGlobalCacheAdapter, AlovaRequestAdapter } from 'alova';
import VueHook from 'alova/vue';
import type { VueHookType } from 'alova/vue';
import adapterFetch from 'alova/fetch';
import { createServerTokenAuthentication } from 'alova/client';
import type { FetchRequestInit } from 'alova/fetch';
import { BACKEND_ERROR_CODE } from './constant';
import type { CustomAlovaConfig, RequestOptions } from './type';

export const createAlovaRequest = <
RequestConfig = FetchRequestInit,
ResponseType = Response,
ResponseHeader = Headers,
L1Cache extends AlovaGlobalCacheAdapter = AlovaDefaultCacheAdapter,
L2Cache extends AlovaGlobalCacheAdapter = AlovaDefaultCacheAdapter
>(
customConfig: CustomAlovaConfig<AlovaGenerics<any, any, RequestConfig, ResponseType, ResponseHeader, L1Cache, L2Cache, any>>,
options: RequestOptions<AlovaGenerics<any, any, RequestConfig, ResponseType, ResponseHeader, L1Cache, L2Cache, any>>
) => {
const { tokenRefresher } = options;
const { onAuthRequired, onResponseRefreshToken } = createServerTokenAuthentication<
VueHookType,
AlovaRequestAdapter<RequestConfig, ResponseType, ResponseHeader>
>({
refreshTokenOnSuccess: {
isExpired: (response, method) => tokenRefresher?.isExpired(response, method) || false,
handler: async (response, method) => tokenRefresher?.handler(response, method)
},
refreshTokenOnError: {
isExpired: (response, method) => tokenRefresher?.isExpired(response, method) || false,
handler: async (response, method) => tokenRefresher?.handler(response, method)
}
});

const instance = createAlova({
...customConfig,
timeout: customConfig.timeout ?? 10 * 1000,
requestAdapter: (customConfig.requestAdapter as any) ?? adapterFetch(),
statesHook: VueHook,
beforeRequest: onAuthRequired(options.onRequest as any),
responded: onResponseRefreshToken({
onSuccess: async (response, method) => {
// check if http status is success
let error: any = null;
let transformedData: any = null;
try {
if (await options.isBackendSuccess(response)) {
transformedData = await options.transformBackendResponse(response);
} else {
error = new Error('the backend request error');
error.code = BACKEND_ERROR_CODE;
}
} catch (err) {
error = err;
}

if (error) {
await options.onError?.(error, response, method);
throw error;
}

return transformedData;
},
onComplete: options.onComplete,
onError: (error, method) => options.onError?.(error, null, method)
})
});

return instance;
};

export { BACKEND_ERROR_CODE };
export type * from './type';
export type * from 'alova';
1 change: 1 addition & 0 deletions packages/alova/src/mock.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '@alova/mock';
49 changes: 49 additions & 0 deletions packages/alova/src/type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import type { AlovaGenerics, AlovaOptions, AlovaRequestAdapter, Method, ResponseCompleteHandler } from 'alova';

export type CustomAlovaConfig<AG extends AlovaGenerics> = Omit<AlovaOptions<AG>, 'statesHook' | 'beforeRequest' | 'responded' | 'requestAdapter'> & {
/** request adapter. all request of alova will be sent by it. */
requestAdapter?: AlovaRequestAdapter<AG['RequestConfig'], AG['Response'], AG['ResponseHeader']>;
};

export interface RequestOptions<AG extends AlovaGenerics> {
/**
* The hook before request
*
* For example: You can add header token in this hook
*
* @param method alova Method Instance
*/
onRequest?: AlovaOptions<AG>['beforeRequest'];
/**
* The hook to check backend response is success or not
*
* @param response alova response
*/
isBackendSuccess: (response: AG['Response']) => Promise<boolean>;

/** The config to refresh token */
tokenRefresher?: {
/** detect the token is expired */
isExpired(response: AG['Response'], Method: Method<AG>): Promise<boolean> | boolean;
/** refresh token handler */
handler(response: AG['Response'], Method: Method<AG>): Promise<void>;
};

/** The hook after backend request complete */
onComplete?: ResponseCompleteHandler<AG>;

/**
* The hook to handle error
*
* For example: You can show error message in this hook
*
* @param error
*/
onError?: (error: any, response: AG['Response'] | null, methodInstance: Method<AG>) => any | Promise<any>;
/**
* transform backend response when the responseType is json
*
* @param response alova response
*/
transformBackendResponse: (response: AG['Response']) => any;
}
20 changes: 20 additions & 0 deletions packages/alova/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"target": "ESNext",
"jsx": "preserve",
"lib": ["DOM", "ESNext"],
"baseUrl": ".",
"module": "ESNext",
"moduleResolution": "node",
"resolveJsonModule": true,
"types": ["node"],
"strict": true,
"strictNullChecks": true,
"noUnusedLocals": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist"]
}
2 changes: 1 addition & 1 deletion packages/axios/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
"qs": "6.13.0"
},
"devDependencies": {
"@types/qs": "6.9.15"
"@types/qs": "6.9.16"
}
}
3 changes: 2 additions & 1 deletion packages/axios/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ export function createFlatRequest<ResponseData = any, State = Record<string, unk

return { data, error: null, response };
}
return { data: response.data as MappedType<R, T>, error: null, response };

return { data: response.data as MappedType<R, T>, error: null };
} catch (error) {
return { data: null, error, response: (error as AxiosError<ResponseData>).response };
}
Expand Down
9 changes: 1 addition & 8 deletions packages/materials/src/libs/page-tab/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,10 @@ const bindProps = computed(() => {
function handleClose() {
emit('close');
}
function handleMouseup(e: MouseEvent) {
// close tab by mouse wheel button click
if (e.button === 1) {
handleClose();
}
}
</script>

<template>
<component :is="activeTabComponent.component" :class="activeTabComponent.class" :style="cssVars" v-bind="bindProps" @mouseup="handleMouseup">
<component :is="activeTabComponent.component" :class="activeTabComponent.class" :style="cssVars" v-bind="bindProps">
<template #prefix>
<slot name="prefix"></slot>
</template>
Expand Down
2 changes: 1 addition & 1 deletion packages/ofetch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
}
},
"dependencies": {
"ofetch": "1.3.4"
"ofetch": "1.4.1"
}
}
8 changes: 4 additions & 4 deletions packages/scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
},
"devDependencies": {
"@soybeanjs/changelog": "0.3.24",
"bumpp": "9.5.2",
"c12": "1.11.2",
"bumpp": "9.7.1",
"c12": "2.0.1",
"cac": "6.7.14",
"consola": "3.2.3",
"enquirer": "2.4.1",
"execa": "9.3.1",
"execa": "9.4.1",
"kolorist": "1.8.0",
"npm-check-updates": "17.1.1",
"npm-check-updates": "17.1.4",
"rimraf": "6.0.1"
}
}
Loading

0 comments on commit e4a4e59

Please sign in to comment.