refactor: 组件示例重构
Former-commit-id: 039dc1ce505489c4d1b360fd50771a10b5476227
This commit is contained in:
9
src/components.d.ts
vendored
9
src/components.d.ts
vendored
@@ -1,9 +0,0 @@
|
|||||||
// 全局组件类型声明
|
|
||||||
import Pagination from '@/components/Pagination/index.vue';
|
|
||||||
|
|
||||||
declare module '@vue/runtime-core' {
|
|
||||||
export interface GlobalComponents {
|
|
||||||
Pagination: typeof Pagination;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
export {};
|
|
||||||
@@ -5,7 +5,7 @@ const props = defineProps({
|
|||||||
require: false
|
require: false
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* 选择器宽度
|
* 图标选择器宽度
|
||||||
*/
|
*/
|
||||||
width: {
|
width: {
|
||||||
type: String,
|
type: String,
|
||||||
@@ -36,9 +36,8 @@ function loadIcons() {
|
|||||||
* 筛选图标
|
* 筛选图标
|
||||||
*/
|
*/
|
||||||
function handleIconFilter() {
|
function handleIconFilter() {
|
||||||
console.log('筛选关键字', filterValue.value);
|
|
||||||
if (filterValue.value) {
|
if (filterValue.value) {
|
||||||
filterIconNames.value = filterIconNames.value.filter(iconName =>
|
filterIconNames.value = iconNames.filter(iconName =>
|
||||||
iconName.includes(filterValue.value)
|
iconName.includes(filterValue.value)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
19
src/env.d.ts
vendored
19
src/env.d.ts
vendored
@@ -1,19 +0,0 @@
|
|||||||
/// <reference types="vite/client" />
|
|
||||||
|
|
||||||
declare module '*.vue' {
|
|
||||||
import { DefineComponent } from 'vue';
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types
|
|
||||||
const component: DefineComponent<{}, {}, any>;
|
|
||||||
export default component;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 环境变量 TypeScript的智能提示
|
|
||||||
interface ImportMetaEnv {
|
|
||||||
VITE_APP_TITLE: string;
|
|
||||||
VITE_APP_PORT: string;
|
|
||||||
VITE_APP_BASE_API: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ImportMeta {
|
|
||||||
readonly env: ImportMetaEnv;
|
|
||||||
}
|
|
||||||
7
src/types/components.d.ts
vendored
7
src/types/components.d.ts
vendored
@@ -45,21 +45,16 @@ declare module '@vue/runtime-core' {
|
|||||||
ElTabs: typeof import('element-plus/es')['ElTabs']
|
ElTabs: typeof import('element-plus/es')['ElTabs']
|
||||||
ElTag: typeof import('element-plus/es')['ElTag']
|
ElTag: typeof import('element-plus/es')['ElTag']
|
||||||
ElTooltip: typeof import('element-plus/es')['ElTooltip']
|
ElTooltip: typeof import('element-plus/es')['ElTooltip']
|
||||||
ElTree: typeof import('element-plus/es')['ElTree']
|
|
||||||
ElTreeSelect: typeof import('element-plus/es')['ElTreeSelect']
|
ElTreeSelect: typeof import('element-plus/es')['ElTreeSelect']
|
||||||
ElUpload: typeof import('element-plus/es')['ElUpload']
|
ElUpload: typeof import('element-plus/es')['ElUpload']
|
||||||
GithubCorner: typeof import('./../components/GithubCorner/index.vue')['default']
|
GithubCorner: typeof import('./../components/GithubCorner/index.vue')['default']
|
||||||
Hamburger: typeof import('./../components/Hamburger/index.vue')['default']
|
Hamburger: typeof import('./../components/Hamburger/index.vue')['default']
|
||||||
IconSelect: typeof import('./../components/IconSelect/index.vue')['default']
|
IconSelect: typeof import('./../components/IconSelect/index.vue')['default']
|
||||||
IEpAddLocation: typeof import('~icons/ep/add-location')['default']
|
|
||||||
IEpAim: typeof import('~icons/ep/aim')['default']
|
|
||||||
IEpCaretBottom: typeof import('~icons/ep/caret-bottom')['default']
|
IEpCaretBottom: typeof import('~icons/ep/caret-bottom')['default']
|
||||||
IEpCaretTop: typeof import('~icons/ep/caret-top')['default']
|
IEpCaretTop: typeof import('~icons/ep/caret-top')['default']
|
||||||
IEpCircleCheckFilled: typeof import('~icons/ep/circle-check-filled')['default']
|
|
||||||
IEpClose: typeof import('~icons/ep/close')['default']
|
IEpClose: typeof import('~icons/ep/close')['default']
|
||||||
IEpDownload: typeof import('~icons/ep/download')['default']
|
IEpDownload: typeof import('~icons/ep/download')['default']
|
||||||
IEpEdit: typeof import('~icons/ep/edit')['default']
|
IEpPlus: typeof import('~icons/ep/plus')['default']
|
||||||
IEpIcon: typeof import('~icons/ep/icon')['default']
|
|
||||||
IEpTop: typeof import('~icons/ep/top')['default']
|
IEpTop: typeof import('~icons/ep/top')['default']
|
||||||
LangSelect: typeof import('./../components/LangSelect/index.vue')['default']
|
LangSelect: typeof import('./../components/LangSelect/index.vue')['default']
|
||||||
MultiUpload: typeof import('./../components/Upload/MultiUpload.vue')['default']
|
MultiUpload: typeof import('./../components/Upload/MultiUpload.vue')['default']
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
import Editor from '@/components/WangEditor/index.vue';
|
|
||||||
import { ElForm } from 'element-plus';
|
|
||||||
import { reactive, ref, toRefs } from 'vue';
|
|
||||||
|
|
||||||
const dataFormRef = ref(ElForm);
|
|
||||||
|
|
||||||
const state = reactive({
|
|
||||||
formData: {
|
|
||||||
content: '初始内容'
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const { formData } = toRefs(state);
|
|
||||||
</script>
|
|
||||||
<template>
|
|
||||||
<div class="app-container">
|
|
||||||
<el-form ref="dataFormRef" :model="formData">
|
|
||||||
<editor v-model="formData.content" style="height: 600px" />
|
|
||||||
</el-form>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
import SingleUpload from '@/components/Upload/SingleUpload.vue';
|
|
||||||
import MultiUpload from '@/components/Upload/MultiUpload.vue';
|
|
||||||
import { ElForm } from 'element-plus';
|
|
||||||
import { reactive, ref, toRefs } from 'vue';
|
|
||||||
|
|
||||||
const dataFormRef = ref(ElForm);
|
|
||||||
|
|
||||||
const state = reactive({
|
|
||||||
formData: {
|
|
||||||
picUrl:
|
|
||||||
'https://oss.youlai.tech/default/2022/11/20/18e206dae97b40329661537d1e433639.jpg',
|
|
||||||
picUrls: [
|
|
||||||
'https://oss.youlai.tech/default/2022/11/20/8af5567816094545b53e76b38ae9c974.webp',
|
|
||||||
'https://oss.youlai.tech/default/2022/11/20/13dbfd7feaf848c2acec2b21675eb9d3.webp'
|
|
||||||
]
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const { formData } = toRefs(state);
|
|
||||||
</script>
|
|
||||||
<template>
|
|
||||||
<div class="app-container">
|
|
||||||
<el-form ref="dataFormRef" :model="formData">
|
|
||||||
<el-form-item label="单图上传">
|
|
||||||
<single-upload v-model="formData.picUrl"></single-upload>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="多图上传">
|
|
||||||
<multi-upload v-model="formData.picUrls"></multi-upload>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
11
src/views/demo/editor.vue
Normal file
11
src/views/demo/editor.vue
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<!-- wangEditor富文本编辑器示例 -->
|
||||||
|
<script setup lang="ts">
|
||||||
|
import Editor from '@/components/WangEditor/index.vue';
|
||||||
|
const value = ref('初始内容');
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
<editor v-model="value" style="height: 600px" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
11
src/views/demo/icon-selector.vue
Normal file
11
src/views/demo/icon-selector.vue
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<!-- 图标选择器 -->
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
const value = ref('edit');
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
<icon-select v-model="value" width="400px" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
26
src/views/demo/uploader.vue
Normal file
26
src/views/demo/uploader.vue
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<!-- 文件上传组件(单图+多图)示例 -->
|
||||||
|
<script setup lang="ts">
|
||||||
|
import SingleUpload from '@/components/Upload/SingleUpload.vue';
|
||||||
|
import MultiUpload from '@/components/Upload/MultiUpload.vue';
|
||||||
|
|
||||||
|
const singlePicUrl = ref(
|
||||||
|
'https://oss.youlai.tech/default/2022/11/20/18e206dae97b40329661537d1e433639.jpg'
|
||||||
|
);
|
||||||
|
|
||||||
|
const multiPicUrls = ref([
|
||||||
|
'https://oss.youlai.tech/default/2022/11/20/8af5567816094545b53e76b38ae9c974.webp',
|
||||||
|
'https://oss.youlai.tech/default/2022/11/20/13dbfd7feaf848c2acec2b21675eb9d3.webp'
|
||||||
|
]);
|
||||||
|
</script>
|
||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
<el-form>
|
||||||
|
<el-form-item label="单图上传">
|
||||||
|
<single-upload v-model="singlePicUrl"></single-upload>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="多图上传">
|
||||||
|
<multi-upload v-model="multiPicUrls"></multi-upload>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -252,8 +252,6 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { reactive, ref, onMounted, toRefs } from 'vue';
|
|
||||||
|
|
||||||
import { Search, Plus, Refresh } from '@element-plus/icons-vue';
|
import { Search, Plus, Refresh } from '@element-plus/icons-vue';
|
||||||
import { ElForm, ElMessage, ElMessageBox } from 'element-plus';
|
import { ElForm, ElMessage, ElMessageBox } from 'element-plus';
|
||||||
|
|
||||||
@@ -279,10 +277,6 @@ const state = reactive({
|
|||||||
loading: true,
|
loading: true,
|
||||||
// 选中ID数组
|
// 选中ID数组
|
||||||
ids: [],
|
ids: [],
|
||||||
// 非单个禁用
|
|
||||||
single: true,
|
|
||||||
// 非多个禁用
|
|
||||||
multiple: true,
|
|
||||||
queryParams: {} as MenuQuery,
|
queryParams: {} as MenuQuery,
|
||||||
menuList: [] as Menu[],
|
menuList: [] as Menu[],
|
||||||
dialog: { visible: false } as DialogType,
|
dialog: { visible: false } as DialogType,
|
||||||
@@ -305,8 +299,6 @@ const state = reactive({
|
|||||||
},
|
},
|
||||||
menuOptions: [] as OptionType[],
|
menuOptions: [] as OptionType[],
|
||||||
currentRow: undefined,
|
currentRow: undefined,
|
||||||
// Icon选择器显示状态
|
|
||||||
iconSelectVisible: false,
|
|
||||||
cacheData: {
|
cacheData: {
|
||||||
menuType: '',
|
menuType: '',
|
||||||
menuPath: ''
|
menuPath: ''
|
||||||
@@ -330,27 +322,24 @@ const {
|
|||||||
function handleQuery() {
|
function handleQuery() {
|
||||||
// 重置父组件
|
// 重置父组件
|
||||||
emit('menuClick', null);
|
emit('menuClick', null);
|
||||||
state.loading = true;
|
loading.value = true;
|
||||||
listMenus(state.queryParams).then(({ data }) => {
|
listMenus(state.queryParams).then(({ data }) => {
|
||||||
state.menuList = data;
|
menuList.value = data;
|
||||||
state.loading = false;
|
loading.value = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 加载菜单下拉树
|
* 下拉菜单
|
||||||
*/
|
*/
|
||||||
async function loadMenuData() {
|
async function loadMenuData() {
|
||||||
const menuOptions: any[] = [];
|
|
||||||
await listMenuOptions().then(({ data }) => {
|
await listMenuOptions().then(({ data }) => {
|
||||||
const menuOption = { value: '0', label: '顶级菜单', children: data };
|
menuOptions.value = [{ value: '0', label: '顶级菜单', children: data }];
|
||||||
menuOptions.push(menuOption);
|
|
||||||
state.menuOptions = menuOptions;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 重置查询
|
* 查询重置
|
||||||
*/
|
*/
|
||||||
function resetQuery() {
|
function resetQuery() {
|
||||||
queryFormRef.value.resetFields();
|
queryFormRef.value.resetFields();
|
||||||
@@ -363,7 +352,7 @@ function handleRowClick(row: any) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增菜单打开
|
* 新增菜单
|
||||||
*/
|
*/
|
||||||
async function handleAdd(row: any) {
|
async function handleAdd(row: any) {
|
||||||
formData.value.id = undefined;
|
formData.value.id = undefined;
|
||||||
@@ -375,11 +364,9 @@ async function handleAdd(row: any) {
|
|||||||
|
|
||||||
if (row.id) {
|
if (row.id) {
|
||||||
// 行点击新增
|
// 行点击新增
|
||||||
|
|
||||||
formData.value.parentId = row.id;
|
formData.value.parentId = row.id;
|
||||||
} else {
|
} else {
|
||||||
// 工具栏新增
|
// 工具栏新增
|
||||||
|
|
||||||
if (state.currentRow) {
|
if (state.currentRow) {
|
||||||
// 选择行
|
// 选择行
|
||||||
formData.value.parentId = (state.currentRow as any).id;
|
formData.value.parentId = (state.currentRow as any).id;
|
||||||
@@ -395,7 +382,7 @@ async function handleAdd(row: any) {
|
|||||||
*/
|
*/
|
||||||
async function handleUpdate(row: MenuForm) {
|
async function handleUpdate(row: MenuForm) {
|
||||||
await loadMenuData();
|
await loadMenuData();
|
||||||
state.dialog = {
|
dialog.value = {
|
||||||
title: '编辑菜单',
|
title: '编辑菜单',
|
||||||
visible: true
|
visible: true
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user