Skip to content
This repository was archived by the owner on Oct 23, 2024. It is now read-only.

Commit 36b0cb5

Browse files
committed
chore: monrepo 改造
1 parent 6150199 commit 36b0cb5

File tree

136 files changed

+5020
-1919
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+5020
-1919
lines changed

.browserslistrc

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
> 1%
2+
last 2 versions
3+
not dead
4+
not ie 11

README.md

+46-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# sable
2+
23
[![code style](https://antfu.me/badge-code-style.svg)](https://github.com/antfu/eslint-config)
34

45
![cover](./public/sable_cover.png)
@@ -17,7 +18,7 @@
1718
- 工具函数:`lodash` & `vueuse`
1819
-
1920

20-
> 详细文档查看 https://www.whbbit.cn/wiki/sable/index.html 【正在编写中】
21+
> 详细文档查看 <https://www.whbbit.cn/wiki/sable/index.html> 【正在编写中】
2122
2223
## 项目配置文件
2324

@@ -73,7 +74,51 @@ export default {
7374
```
7475

7576
## TODO
77+
78+
灰色
79+
80+
- #363433
81+
- #393733
82+
7683
主题
7784
鹤 红、白、黑
85+
86+
- #4a4035 #d42517
87+
7888
虎 橙、白、黑
89+
90+
- #eaad1a
91+
7992
竹 绿、白、黑
93+
94+
- #1ba784
95+
96+
97+
- #f1939c
98+
99+
100+
101+
- #c08eaf
102+
103+
104+
- #e9ddb6
105+
106+
---
107+
108+
## 待办
109+
110+
1. 自动引入本地svg图标
111+
2. 表格API优化
112+
3. tab栏实现
113+
4. keep-alive
114+
5. 全局菜单搜索
115+
6. 富文本编辑器集成
116+
7. 下载文件组件
117+
8. 上传文件组件
118+
9. 网络请求封装
119+
10. 地图API集成
120+
11. 页面切换动画 『可配置』
121+
12. 外链路由可配置为跳转至新窗口或iframe打开
122+
13. 权限控制
123+
14. 菜单icon
124+
15. 主题配置

package.json

+26-27
Original file line numberDiff line numberDiff line change
@@ -14,65 +14,64 @@
1414
"preview": "pnpm run build && vite preview",
1515
"test": "vitest",
1616
"test:ui": "vitest --ui",
17-
"release": "release-it"
17+
"release": "release-it",
18+
"start": "cross-env type=start node start.config.js"
1819
},
1920
"dependencies": {
20-
"@sable/axios": "workspace:^",
21-
"@sable/utils": "workspace:^",
22-
"@vueuse/core": "^10.11.1",
23-
"artplayer": "^5.1.6",
21+
"@sable/api": "workspace:*",
22+
"@sable/axios": "workspace:*",
23+
"@sable/components": "workspace:*",
24+
"@sable/enum": "workspace:*",
25+
"@sable/store": "workspace:*",
26+
"@sable/types": "workspace:*",
27+
"@sable/utils": "workspace:*",
28+
"@vueuse/core": "^11.0.0",
2429
"dayjs": "^1.11.12",
2530
"echarts": "^5.5.1",
2631
"lodash-es": "^4.17.21",
27-
"md-editor-v3": "^4.18.0",
2832
"nprogress": "^0.2.0",
29-
"pinia": "^2.2.1",
33+
"pinia": "^2.2.2",
3034
"pinia-plugin-persistedstate": "^3.2.1",
31-
"vue": "^3.4.37",
35+
"vue": "^3.4.38",
3236
"vue-draggable-plus": "^0.5.3",
3337
"vue-router": "^4.4.3"
3438
},
3539
"devDependencies": {
36-
"@antfu/eslint-config": "^2.25.0",
37-
"@commitlint/cli": "^19.4.0",
38-
"@commitlint/config-conventional": "^19.2.2",
40+
"@antfu/eslint-config": "^2.25.2",
3941
"@iconify-json/carbon": "^1.1.37",
4042
"@iconify-json/svg-spinners": "^1.1.3",
4143
"@purge-icons/generated": "^0.10.0",
4244
"@release-it/conventional-changelog": "^8.0.1",
4345
"@types/lodash-es": "^4.17.12",
44-
"@types/marked": "^6.0.0",
4546
"@types/mockjs": "^1.0.10",
46-
"@types/node": "^20.14.14",
47-
"@unocss/preset-attributify": "^0.61.9",
48-
"@unocss/preset-icons": "^0.61.9",
49-
"@unocss/preset-rem-to-px": "^0.61.9",
50-
"@unocss/reset": "^0.61.9",
51-
"@unocss/transformer-directives": "^0.61.9",
47+
"@types/node": "^22.3.0",
48+
"@unocss/preset-attributify": "^0.62.2",
49+
"@unocss/preset-icons": "^0.62.2",
50+
"@unocss/preset-rem-to-px": "^0.62.2",
51+
"@unocss/reset": "^0.62.2",
52+
"@unocss/transformer-directives": "^0.62.2",
5253
"@vicons/ionicons5": "^0.12.0",
5354
"@vicons/utils": "^0.1.4",
5455
"@vitejs/plugin-vue": "^5.1.2",
55-
"@vitejs/plugin-vue-jsx": "^4.0.0",
56-
"@vitest/coverage-c8": "^0.33.0",
56+
"@vitejs/plugin-vue-jsx": "^4.0.1",
5757
"@vitest/ui": "^2.0.5",
5858
"autoprefixer": "^10.4.20",
59-
"eslint": "^9.8.0",
60-
"lint-staged": "^15.2.8",
59+
"eslint": "^9.9.0",
60+
"lint-staged": "^15.2.9",
6161
"mockjs": "^1.1.0",
6262
"naive-ui": "^2.39.0",
63-
"path": "^0.12.7",
6463
"release-it": "^17.6.0",
6564
"rollup-plugin-visualizer": "^5.12.0",
6665
"sass": "^1.77.8",
6766
"simple-git-hooks": "^2.11.1",
6867
"typescript": "^5.5.4",
69-
"unocss": "^0.61.9",
68+
"unocss": "^0.62.2",
7069
"unplugin-auto-import": "^0.18.2",
7170
"unplugin-icons": "^0.19.2",
72-
"unplugin-vue-components": "^0.27.3",
73-
"vite": "^5.4.0",
71+
"unplugin-vue-components": "^0.27.4",
72+
"vite": "^5.4.1",
7473
"vite-plugin-mock": "^3.0.2",
75-
"vite-plugin-vue-devtools": "7.3.5",
74+
"vite-plugin-vue-devtools": "7.3.8",
7675
"vitest": "^2.0.5",
7776
"vue-tsc": "^2.0.29"
7877
},

packages/api/package.json

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "@sable/api",
3+
"version": "1.0.0",
4+
"description": "",
5+
"author": "",
6+
"license": "ISC",
7+
"keywords": [],
8+
"main": "./src/index.ts",
9+
"dependencies": {
10+
"@sable/axios": "workspace:^",
11+
"@sable/enum": "workspace:^"
12+
}
13+
}

packages/api/src/http.ts

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import Axios from '@sable/axios'
2+
import { CacheEnum } from '@sable/enum'
3+
4+
const http = new Axios({
5+
baseURL: '/api',
6+
timeout: 10000,
7+
headers: {},
8+
}, {
9+
authorizationPrefix: 'Bearer',
10+
tokenKey: CacheEnum.TOKEN,
11+
})
12+
13+
export default http

packages/api/src/index.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export * from './notifyApi'
2+
export * from './uploadApi'
3+
export * from './userApi'

src/api/notifyApi.ts packages/api/src/notifyApi.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import http from '@/plugins/axios'
1+
import http from './http'
22

33
export async function getNotifies() {
44
return http.post({ url: 'notify' })

src/api/uploadApi.ts packages/api/src/uploadApi.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import http from '@/plugins/axios'
1+
import http from './http'
22

33
// upload image
44
export function uploadImage(data: FormData) {

src/api/userApi.ts packages/api/src/userApi.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import http from '../plugins/axios'
1+
import http from './http'
22

33
export async function getUserInfoApi() {
44
return http.request<IUserModel>({

packages/axios/package.json

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
"author": "",
77
"main": "./src/index.ts",
88
"dependencies": {
9+
"@sable/enum": "workspace:^",
10+
"@sable/types": "workspace:^",
911
"axios": "^1.7.2",
1012
"axios-retry": "^4.4.2",
1113
"qs": "^6.12.3"

packages/axios/src/index.ts

+16-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import axios from 'axios'
22
import axiosRetry from 'axios-retry'
33
import { stringify as qsStringify } from 'qs'
4-
4+
import { HttpCodeEnum, RouteNameEnum } from '@sable/enum'
55
import type { AxiosInstance, AxiosRequestConfig } from 'axios'
66
import type { IAxiosRetryConfig } from 'axios-retry'
7-
import type { ErrorMessageMode, ResponseResult } from './type'
7+
import { useRouter } from 'vue-router'
8+
import type { ResponseResult } from '@sable/types'
89

910
interface CustomConfig {
1011
axiosRetryConfig?: IAxiosRetryConfig
@@ -20,10 +21,7 @@ const defaultConfig: CustomConfig = {
2021

2122
class Axios {
2223
private instance: AxiosInstance
23-
constructor(
24-
config: AxiosRequestConfig,
25-
public customConfig: CustomConfig = defaultConfig,
26-
) {
24+
constructor(config: AxiosRequestConfig, public customConfig: CustomConfig = defaultConfig) {
2725
this.instance = axios.create(config)
2826
this.setupAxiosRetry(this.customConfig?.axiosRetryConfig || defaultConfig.axiosRetryConfig)
2927
this.interceptors()
@@ -59,6 +57,18 @@ class Axios {
5957
return response
6058
},
6159
(error) => {
60+
const {
61+
response: { status },
62+
} = error
63+
64+
const router = useRouter()
65+
66+
switch (status) {
67+
case HttpCodeEnum.UNAUTHORIZED:
68+
localStorage.removeItem(this.customConfig.tokenKey)
69+
router.push({ name: RouteNameEnum.LOGIN })
70+
return
71+
}
6272
return Promise.reject(error)
6373
},
6474
)

packages/axios/src/type.ts

-12
Original file line numberDiff line numberDiff line change
@@ -1,13 +1 @@
1-
export interface ResponseResult<T> {
2-
code: number
3-
message: string
4-
type: 'success' | 'error'
5-
data: T
6-
meta: {
7-
current_page: number // 当前页
8-
page_size: number //
9-
total: number // 总页数
10-
}
11-
}
12-
131
export type ErrorMessageMode = 'none' | 'modal' | 'message' | undefined

packages/components/ECharts/Chart.vue

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<script lang="ts" setup>
2+
import ResizeObserver from 'resize-observer-polyfill'
3+
import { onBeforeUnmount, onMounted, shallowRef, toRefs, unref, watch } from 'vue'
4+
import type { ECharts, EChartsInitOpts, EChartsOption } from 'echarts'
5+
import { useDebounceFn } from '@vueuse/core'
6+
import echarts from './echarts'
7+
8+
interface Props {
9+
option: EChartsOption
10+
theme?: 'dark' | null
11+
renderer?: EChartsInitOpts['renderer']
12+
}
13+
14+
const props = withDefaults(
15+
defineProps<Props>(),
16+
{
17+
theme: null,
18+
option: undefined,
19+
renderer: 'canvas',
20+
},
21+
)
22+
23+
const { option, theme, renderer } = toRefs(props)
24+
25+
const container = shallowRef(null)
26+
let chart: ECharts | null = null
27+
const resizeObserver = new ResizeObserver(useDebounceFn(() => {
28+
chart?.resize()
29+
}, 150))
30+
31+
onMounted(() => {
32+
chart = echarts.init(container.value, theme.value, {
33+
locale: 'ZH',
34+
renderer: unref(renderer),
35+
ssr: false,
36+
}) as any
37+
chart?.setOption(unref(option))
38+
resizeObserver.observe(container.value!)
39+
})
40+
41+
onBeforeUnmount(() => {
42+
if (chart)
43+
chart?.dispose()
44+
45+
resizeObserver.unobserve(container.value!)
46+
})
47+
48+
watch(
49+
option,
50+
(newOption) => {
51+
chart?.setOption(newOption)
52+
},
53+
{ deep: true },
54+
)
55+
</script>
56+
57+
<template>
58+
<div ref="container" h-full w-full />
59+
</template>
60+
61+
<style scoped lang="scss"></style>
File renamed without changes.

packages/components/ECharts/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as Chart } from './Chart.vue'

0 commit comments

Comments
 (0)