Skip to content

Commit 7783fb5

Browse files
committed
优化
1 parent 091f09e commit 7783fb5

File tree

17 files changed

+374
-203
lines changed

17 files changed

+374
-203
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "front-next",
3-
"version": "5.12.0",
3+
"version": "5.12.1",
44
"scripts": {
55
"dev": "vite --host",
66
"build": "vite build",

src/cool/module/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// @ts-nocheck
21
import { Module } from "../types";
32
import { Data } from "../utils";
43

@@ -10,6 +9,7 @@ const module = {
109
list,
1110
req: Promise.resolve(),
1211
get(name: string): Module {
12+
// @ts-ignore
1313
return this.list.find((e) => e.name == name);
1414
},
1515
add(data: Module) {

src/cool/utils/data.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// @ts-nocheck
21
const d: any = window;
32

43
// window 数据临时存储,解决热更新后失效问题

src/modules/base/components/codemirror/index.vue

+18-19
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
ref="Editor"
55
v-model="content"
66
:placeholder="placeholder"
7-
:style="{ height, fontSize }"
7+
:style="style"
88
autofocus
99
:disabled="disabled"
1010
indent-with-tab
@@ -21,16 +21,17 @@ import { javascript } from "@codemirror/lang-javascript";
2121
import { oneDark } from "@codemirror/theme-one-dark";
2222
import { ref, watch, computed, defineComponent } from "vue";
2323
import { useDark } from "@vueuse/core";
24-
import { isNumber } from "lodash-es";
24+
import { useComm } from "/@/cool";
2525
2626
export default defineComponent({
2727
name: "cl-codemirror",
2828
29+
components: {
30+
Codemirror
31+
},
32+
2933
props: {
30-
modelValue: {
31-
type: String,
32-
required: true
33-
},
34+
modelValue: String,
3435
placeholder: {
3536
type: String,
3637
default: "请输入"
@@ -40,29 +41,22 @@ export default defineComponent({
4041
default: 400
4142
},
4243
fontSize: {
43-
type: String,
44-
default: "14px"
44+
type: [String, Number],
45+
default: 14
4546
},
4647
disabled: Boolean
4748
},
4849
4950
emits: ["update:modelValue", "change"],
5051
51-
components: {
52-
Codemirror
53-
},
54-
5552
setup(props, { emit }) {
53+
const { px } = useComm();
54+
5655
const Editor = ref();
5756
5857
// 是否暗黑模式
5958
const isDark = ref(useDark());
6059
61-
// 高度
62-
const height = computed(() =>
63-
isNumber(props.height) ? `${props.height}px` : props.height
64-
);
65-
6660
// 插件
6761
const extensions: any[] = [javascript()];
6862
@@ -73,6 +67,11 @@ export default defineComponent({
7367
// 内容
7468
const content = ref("");
7569
70+
// 样式
71+
const style = computed(() => {
72+
return { height: px(props.height), fontSize: px(props.fontSize) };
73+
});
74+
7675
// 值改变
7776
function onChange(value: string) {
7877
emit("update:modelValue", value);
@@ -83,7 +82,7 @@ export default defineComponent({
8382
watch(
8483
() => props.modelValue,
8584
(val) => {
86-
content.value = val;
85+
content.value = val || "";
8786
},
8887
{
8988
immediate: true
@@ -93,7 +92,7 @@ export default defineComponent({
9392
return {
9493
Editor,
9594
isDark,
96-
height,
95+
style,
9796
content,
9897
extensions,
9998
onChange

src/modules/base/components/select/index.vue

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<template>
2-
<el-select v-model="value" @change="onChange" clearable>
2+
<el-select v-model="value" :clearable="clearable" @change="onChange">
33
<el-option
44
v-for="(item, index) in list"
55
:key="index"
66
:label="item.label"
77
:value="item.value"
8+
:disabled="item.disabled"
89
></el-option>
910
</el-select>
1011
</template>
@@ -22,6 +23,10 @@ export default defineComponent({
2223
type: [Array, Object],
2324
default: () => []
2425
},
26+
clearable: {
27+
type: Boolean,
28+
default: true
29+
},
2530
prop: String
2631
},
2732
@@ -30,7 +35,11 @@ export default defineComponent({
3035
setup(props, { emit }) {
3136
// cl-crud
3237
const Crud = useCrud();
38+
39+
// 选中值
3340
const value = ref();
41+
42+
// 列表
3443
const list = computed<any>(() =>
3544
isRef(props.options) ? props.options.value : props.options
3645
);

src/modules/base/store/user.ts

+3-17
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,6 @@ import { ref } from "vue";
33
import { storage } from "/@/cool/utils";
44
import { service, config, router } from "/@/cool";
55

6-
interface User {
7-
id: number;
8-
name: string;
9-
username: string;
10-
nickName: string;
11-
phone: string;
12-
headImg: string;
13-
email: string;
14-
status: 0 | 1;
15-
departmentId: string;
16-
createTime: Date;
17-
[key: string]: any;
18-
}
19-
206
// 本地缓存
217
const data = storage.info();
228

@@ -27,9 +13,9 @@ export const useUserStore = defineStore("user", function () {
2713
// 设置标识
2814
function setToken(data: {
2915
token: string;
30-
expire: string;
16+
expire: number;
3117
refreshToken: string;
32-
refreshExpire: string;
18+
refreshExpire: number;
3319
}) {
3420
// 请求的唯一标识
3521
token.value = data.token;
@@ -58,7 +44,7 @@ export const useUserStore = defineStore("user", function () {
5844
}
5945

6046
// 用户信息
61-
const info = ref<User | null>(data.userInfo);
47+
const info = ref<Eps.BaseSysUserEntity | null>(data.userInfo);
6248

6349
// 设置用户信息
6450
function set(value: any) {

src/modules/chat/components/message.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
<ul>
6464
<cl-upload @success="onImageSend" :show-file-list="false">
6565
<li>
66-
<el-icon><picture /></el-icon>
66+
<el-icon><picture-filled /></el-icon>
6767
</li>
6868
</cl-upload>
6969

@@ -101,7 +101,7 @@
101101
import { computed, ref } from "vue";
102102
import { useChat } from "../hooks";
103103
import { useStore } from "../store";
104-
import { Picture, VideoCamera, Microphone } from "@element-plus/icons-vue";
104+
import { PictureFilled, VideoCamera, Microphone } from "@element-plus/icons-vue";
105105
import { useBase } from "/$/base";
106106
import { ContextMenu } from "@cool-vue/crud";
107107
import { useClipboard } from "@vueuse/core";

src/modules/demo/views/editor-quill.vue

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div class="editor">
3-
<el-tabs>
3+
<el-tabs type="card">
44
<el-tab-pane label="WangEditor">
55
<cl-editor-wang v-model="w" :height="400" />
66
</el-tab-pane>
@@ -20,7 +20,9 @@ const w = ref("Wang");
2020

2121
<style lang="scss" scoped>
2222
.editor {
23-
background-color: #fff;
24-
padding: 0 10px 10px 10px;
23+
background-color: var(--el-bg-color);
24+
padding: 10px;
25+
height: 100%;
26+
box-sizing: border-box;
2527
}
2628
</style>

src/modules/demo/views/upload.vue

+42-49
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,67 @@
11
<template>
22
<div class="demo">
3-
<el-image
4-
v-for="(item, index) in list"
5-
:key="index"
6-
:src="item"
7-
:style="{ width: '100px', marginRight: '10px' }"
8-
/>
3+
<el-tabs type="card">
4+
<el-tab-pane label="普通上传">
5+
<cl-upload v-model="urls" />
6+
</el-tab-pane>
97

10-
<div class="item">
11-
<p>普通上传</p>
12-
<cl-upload v-model="urls" />
13-
</div>
8+
<el-tab-pane label="多图上传" lazy>
9+
<cl-upload text="选择图片" v-model="urls" multiple drag />
10+
</el-tab-pane>
1411

15-
<div class="item">
16-
<p>多图上传 multiple</p>
17-
<cl-upload v-model="urls" multiple drag />
18-
</div>
12+
<el-tab-pane label="文件上传" lazy>
13+
<cl-upload v-model="urls" multiple text="文件上传" type="file" />
14+
</el-tab-pane>
1915

20-
<div class="item">
21-
<p>文件上传 file</p>
22-
<cl-upload v-model="urls" multiple text="文件上传" type="file" />
23-
</div>
16+
<el-tab-pane label="自定义内容">
17+
<cl-upload text="选择图片" multiple drag custom-class="custom-upload">
18+
<el-button :icon="Upload">上传</el-button>
2419

25-
<div class="item">
26-
<p>自定义内容</p>
27-
<cl-upload text="选择图片" multiple drag>
28-
<div style="width: 100%">
29-
<el-button>上传</el-button>
30-
</div>
31-
<template #item="{ item }">
32-
<div class="cs-item">{{ item.url }}</div>
33-
</template>
34-
</cl-upload>
35-
</div>
20+
<template #item="{ item }">
21+
<div class="item" v-show="item.url">{{ item.url }}</div>
22+
</template>
23+
</cl-upload>
24+
</el-tab-pane>
3625

37-
<div class="item">
38-
<p>自定义大小</p>
39-
<cl-upload text="选择图片" :size="[120, 200]" />
40-
</div>
26+
<el-tab-pane label="自定义大小">
27+
<cl-upload text="选择图片" :size="[120, 200]" />
28+
</el-tab-pane>
4129

42-
<div class="item">
43-
<p>文件空间</p>
44-
<cl-upload-space />
45-
</div>
30+
<el-tab-pane label="文件空间">
31+
<cl-upload-space />
32+
</el-tab-pane>
33+
</el-tabs>
4634
</div>
4735
</template>
4836

4937
<script lang="ts" name="upload" setup>
50-
import { computed, ref } from "vue";
38+
import { ref } from "vue";
39+
import { Upload } from "@element-plus/icons-vue";
5140
5241
const urls = ref("");
53-
const list = computed(() => urls.value.split(",").filter(Boolean));
5442
</script>
5543

5644
<style lang="scss" scoped>
5745
.demo {
5846
background-color: var(--el-bg-color);
59-
.item {
60-
margin-bottom: 10px;
61-
padding: 10px;
47+
padding: 10px;
48+
height: 100%;
49+
box-sizing: border-box;
6250
63-
& > p {
64-
margin-bottom: 10px;
65-
font-size: 14px;
51+
:deep(.custom-upload) {
52+
.item {
53+
border: 1px solid var(--el-border-color);
54+
border-radius: 3px;
55+
padding: 5px 10px;
56+
margin-top: 10px;
57+
font-size: 12px;
58+
width: 100%;
59+
box-sizing: border-box;
6660
}
67-
}
6861
69-
.cs-item {
70-
border: 1px solid var(--el-border-color);
71-
padding: 5px 10px;
62+
.cl-upload__list {
63+
width: 100%;
64+
}
7265
}
7366
}
7467
</style>

0 commit comments

Comments
 (0)