神仙都没用 1 жил өмнө
parent
commit
8ce4c5047e

+ 1 - 1
package.json

@@ -9,7 +9,7 @@
 		"lint:eslint": "eslint \"{src}/**/*.{vue,ts,tsx}\" --fix"
 	},
 	"dependencies": {
-		"@cool-vue/crud": "^7.0.0-beta9",
+		"@cool-vue/crud": "^7.0.1-beta1",
 		"@element-plus/icons-vue": "^2.1.0",
 		"@vueuse/core": "^10.4.0",
 		"@wangeditor/editor": "^5.1.23",

+ 1 - 1
packages/crud/package.json

@@ -1,6 +1,6 @@
 {
 	"name": "@cool-vue/crud",
-	"version": "7.0.1",
+	"version": "7.0.1-beta2",
 	"private": false,
 	"main": "./dist/index.umd.min.js",
 	"typings": "types/index.d.ts",

+ 6 - 0
packages/crud/src/hooks/crud.ts

@@ -1,3 +1,4 @@
+import { TestService } from "../test/service";
 import { watch, ref, nextTick, getCurrentInstance, Ref, inject, provide } from "vue";
 
 // 获取上级
@@ -56,6 +57,11 @@ export function useCrud(options?: DeepPartial<ClCrud.Options>, cb?: (app: ClCrud
 	useParent("cl-crud", Crud);
 
 	if (options) {
+		// 测试模式
+		if (options.service == "test") {
+			options.service = new TestService();
+		}
+
 		provide("useCrud__options", options);
 	}
 

+ 190 - 0
packages/crud/src/test/service.ts

@@ -0,0 +1,190 @@
+import { orderBy } from "lodash-es";
+import { uuid } from "../utils";
+
+const userList = [
+	{
+		id: "110000199206102819",
+		name: "楚行云",
+		createTime: "1996-09-14",
+		wages: 73026,
+		status: 1,
+		account: "ihknssft",
+		occupation: 4,
+		phone: 13797353874
+	},
+	{
+		id: "410000199208224044",
+		name: "秦尘",
+		createTime: "1977-11-09",
+		wages: 74520,
+		status: 0,
+		account: "xlabchey",
+		occupation: 3,
+		phone: 18593911044
+	},
+	{
+		id: "120000199708139664",
+		name: "叶凡",
+		createTime: "1982-11-28",
+		wages: 81420,
+		status: 0,
+		account: "xpqbtkul",
+		occupation: 1,
+		phone: 16234136338
+	},
+	{
+		id: "710000200203060278",
+		name: "白小纯",
+		createTime: "2012-12-17",
+		wages: 65197,
+		status: 1,
+		account: "kirukkje",
+		occupation: 2,
+		phone: 16325661110
+	},
+	{
+		id: "210000201007157714",
+		name: "韩立",
+		createTime: "1982-07-10",
+		wages: 99107,
+		status: 1,
+		account: "rbrohvoj",
+		occupation: 2,
+		phone: 18486594866
+	},
+	{
+		id: "420000200901038044",
+		name: "唐三",
+		createTime: "2019-07-31",
+		wages: 80658,
+		status: 1,
+		account: "qtuwsfuh",
+		occupation: 5,
+		phone: 15565014642
+	},
+	{
+		id: "150000197711136225",
+		name: "王林",
+		createTime: "2009-07-26",
+		wages: 57408,
+		status: 1,
+		account: "gxyhlwdq",
+		occupation: 1,
+		phone: 13852767084
+	},
+	{
+		id: "710000198106232170",
+		name: "李强",
+		createTime: "2016-04-26",
+		wages: 71782,
+		status: 1,
+		account: "vruiimiy",
+		occupation: 3,
+		phone: 18365332834
+	},
+	{
+		id: "530000199311309764",
+		name: "秦羽",
+		createTime: "1984-01-18",
+		wages: 87860,
+		status: 1,
+		account: "dtvkpyag",
+		occupation: 0,
+		phone: 18149247129
+	}
+];
+
+class TestService {
+	// 分页列表
+	async page(params: any) {
+		const { status, occupation, keyWord, page, size, phone, name, sort, order } = params || {};
+
+		// 过滤后的列表
+		const list = orderBy(userList, order, sort).filter((e) => {
+			if (status !== undefined) {
+				return e.status == status;
+			}
+
+			if (phone !== undefined) {
+				return String(e.phone).includes(phone);
+			}
+
+			if (name !== undefined) {
+				return e.name.includes(name);
+			}
+
+			if (keyWord !== undefined) {
+				return e.name.includes(keyWord) || String(e.phone).includes(keyWord);
+			}
+
+			if (occupation !== undefined) {
+				return e.occupation == occupation;
+			}
+
+			return true;
+		});
+
+		return new Promise((resolve) => {
+			// 模拟延迟
+			setTimeout(() => {
+				resolve({
+					list: list.slice((page - 1) * size, page * size),
+					pagination: {
+						total: list.length,
+						page,
+						size
+					},
+					subData: {
+						wages: list.reduce((a, b) => {
+							return a + b.wages;
+						}, 0)
+					}
+				});
+			}, 500);
+		});
+	}
+
+	// 更新
+	async update(params: { id: any; [key: string]: any }) {
+		const item = userList.find((e) => e.id == params.id);
+
+		if (item) {
+			Object.assign(item, params);
+		}
+	}
+
+	// 新增
+	async add(params: any) {
+		const id = uuid();
+
+		userList.push({
+			id,
+			...params
+		});
+
+		return id;
+	}
+
+	// 详情
+	async info(params: { id: any }) {
+		const { id } = params || {};
+		return userList.find((e) => e.id == id);
+	}
+
+	// 删除
+	async delete(params: { ids: any[] }) {
+		const { ids = [] } = params || {};
+
+		ids.forEach((id) => {
+			const index = userList.findIndex((e) => e.id == id);
+			userList.splice(index, 1);
+		});
+	}
+
+	// 全部列表
+	async list() {
+		return userList;
+	}
+}
+
+export { TestService };

+ 14 - 0
packages/crud/src/utils/index.ts

@@ -132,3 +132,17 @@ export function deepFind(value: any, list: any[]) {
 
 	return deep(list);
 }
+
+// uuid
+export function uuid(separator = "-"): string {
+	const s: any[] = [];
+	const hexDigits = "0123456789abcdef";
+	for (let i = 0; i < 36; i++) {
+		s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
+	}
+	s[14] = "4";
+	s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1);
+	s[8] = s[13] = s[18] = s[23] = separator;
+
+	return s.join("");
+}

+ 1 - 1
packages/crud/types/components/adv/search.d.ts

@@ -34,8 +34,8 @@ declare const _default: import("vue").DefineComponent<{
     onReset?: ((...args: any[]) => any) | undefined;
     onClear?: ((...args: any[]) => any) | undefined;
 }, {
+    size: string | number;
     items: ClForm.Item[];
     op: unknown[];
-    size: string | number;
 }, {}>;
 export default _default;

+ 1 - 1
packages/crud/types/components/table/helper/index.d.ts

@@ -80,7 +80,7 @@ export declare function useTable(props: any): {
                 column: any;
                 $index: number;
             }) => any;
-            sortable: boolean | "desc" | "asc" | "custom" | "descending" | "ascending";
+            sortable: boolean | "asc" | "desc" | "custom" | "descending" | "ascending";
             sortMethod: fn;
             sortBy: string | any[] | ((row: any, index: number) => any);
             resizable: boolean;

+ 34 - 0
packages/crud/types/test/service.d.ts

@@ -0,0 +1,34 @@
+declare class TestService {
+    page(params: any): Promise<unknown>;
+    update(params: {
+        id: any;
+        [key: string]: any;
+    }): Promise<void>;
+    add(params: any): Promise<string>;
+    info(params: {
+        id: any;
+    }): Promise<{
+        id: string;
+        name: string;
+        createTime: string;
+        wages: number;
+        status: number;
+        account: string;
+        occupation: number;
+        phone: number;
+    } | undefined>;
+    delete(params: {
+        ids: any[];
+    }): Promise<void>;
+    list(): Promise<{
+        id: string;
+        name: string;
+        createTime: string;
+        wages: number;
+        status: number;
+        account: string;
+        occupation: number;
+        phone: number;
+    }[]>;
+}
+export { TestService };

+ 1 - 0
packages/crud/types/utils/index.d.ts

@@ -8,3 +8,4 @@ export declare function addClass(el: Element, name: string): void;
 export declare function removeClass(el: Element, name: string): void;
 export declare function getValue(data: any, params?: any): any;
 export declare function deepFind(value: any, list: any[]): any;
+export declare function uuid(separator?: string): string;

+ 2 - 6
src/cool/service/request.ts

@@ -127,17 +127,13 @@ request.interceptors.response.use(
 		NProgress.done();
 
 		if (error.response) {
-			const { status, config: c } = error.response;
+			const { status } = error.response;
 			const { user } = useBase();
 
 			if (status == 401) {
 				user.logout();
 			} else {
-				if (isDev) {
-					if (c.url != `${config.baseUrl}/`) {
-						ElMessage.error(`${c.url} ${status}`);
-					}
-				} else {
+				if (!isDev) {
 					switch (status) {
 						case 403:
 							router.push("/403");

+ 20 - 3
src/modules/base/pages/login/components/pic-captcha.vue

@@ -1,13 +1,20 @@
 <template>
 	<div class="pic-captcha" @click="refresh">
 		<div v-if="svg" class="svg" v-html="svg" />
-		<img v-else class="base64" :src="base64" alt="" />
+		<img v-else-if="base64" class="base64" :src="base64" alt="" />
+
+		<template v-else>
+			<el-icon class="is-loading">
+				<Loading />
+			</el-icon>
+		</template>
 	</div>
 </template>
 
 <script lang="ts" setup>
 import { onMounted, ref } from "vue";
 import { ElMessage } from "element-plus";
+import { Loading } from "@element-plus/icons-vue";
 import { useCool } from "/@/cool";
 
 const emit = defineEmits(["update:modelValue", "change"]);
@@ -20,8 +27,8 @@ const base64 = ref("");
 // svg
 const svg = ref("");
 
-function refresh() {
-	service.base.open
+async function refresh() {
+	await service.base.open
 		.captcha({
 			height: 45,
 			width: 150,
@@ -57,9 +64,13 @@ defineExpose({
 
 <style lang="scss" scoped>
 .pic-captcha {
+	display: flex;
+	justify-content: center;
+	align-items: center;
 	cursor: pointer;
 	height: 45px;
 	width: 150px;
+	position: relative;
 
 	.svg {
 		height: 100%;
@@ -69,5 +80,11 @@ defineExpose({
 	.base64 {
 		height: 100%;
 	}
+
+	.el-icon {
+		position: absolute;
+		font-size: 22px;
+		right: 20px;
+	}
 }
 </style>

+ 7 - 3
src/modules/base/pages/login/index.vue

@@ -125,11 +125,15 @@ async function toLogin() {
 		// 设置缓存
 		storage.set("username", form.username);
 
-		// 跳转
+		// 跳转首页
 		router.push("/");
-	} catch (err: any) {
+	} catch (err) {
+		// 刷新验证码
 		refs.picCaptcha.refresh();
-		ElMessage.error(err.message);
+
+		if (err instanceof Error) {
+			ElMessage.error(err.message);
+		}
 	}
 
 	saving.value = false;

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 0 - 0
src/modules/base/static/svg/icon-earth.svg


+ 29 - 1
src/modules/base/static/svg/icon-fx.svg

@@ -1 +1,29 @@
-<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1695872084016" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3043" xmlns:xlink="http://www.w3.org/1999/xlink" width="64" height="64"><path d="M853.333333 85.333333H170.666667a86.570667 86.570667 0 0 0-85.333334 85.333334v682.666666a85.717333 85.717333 0 0 0 85.333334 85.333334h682.666666a86.186667 86.186667 0 0 0 85.333334-85.333334V170.666667a85.333333 85.333333 0 0 0-85.333334-85.333334zM170.666667 853.333333V170.666667h682.666666v682.666666z" fill="#2c2c2c" p-id="3044"></path><path d="M387.2 379.733333a61.781333 61.781333 0 0 1 61.781333-61.781333h19.114667a30.890667 30.890667 0 0 0 0-61.781333h-19.114667a123.733333 123.733333 0 0 0-123.733333 123.733333v304.512a30.890667 30.890667 0 1 0 61.781333 0z" fill="#2c2c2c" p-id="3045"></path><path d="M261.76 429.610667h217.728a27.392 27.392 0 0 1 31.146667 30.890666 27.392 27.392 0 0 1-31.146667 30.890667h-217.6a27.434667 27.434667 0 0 1-31.146667-30.890667 27.392 27.392 0 0 1 31.146667-30.890666z" fill="#2c2c2c" p-id="3046"></path><path d="M737.322667 331.008a30.890667 30.890667 0 0 0-26.88 15.445333l-61.781334 108.117334-61.781333-108.117334a30.890667 30.890667 0 1 0-53.461333 30.890667l80.341333 139.008-80.341333 139.008a30.890667 30.890667 0 1 0 53.461333 30.890667l61.781333-108.117334 61.781334 108.117334a30.890667 30.890667 0 1 0 53.461333-30.890667l-80.341333-139.008 80.341333-139.008a30.890667 30.890667 0 0 0-26.581333-46.336z" fill="#2c2c2c" p-id="3047"></path></svg>
+<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg
+	t="1695872084016"
+	class="icon"
+	viewBox="0 0 1024 1024"
+	version="1.1"
+	xmlns="http://www.w3.org/2000/svg"
+	p-id="3043"
+	xmlns:xlink="http://www.w3.org/1999/xlink"
+	width="64"
+	height="64"
+>
+	<path
+		d="M853.333333 85.333333H170.666667a86.570667 86.570667 0 0 0-85.333334 85.333334v682.666666a85.717333 85.717333 0 0 0 85.333334 85.333334h682.666666a86.186667 86.186667 0 0 0 85.333334-85.333334V170.666667a85.333333 85.333333 0 0 0-85.333334-85.333334zM170.666667 853.333333V170.666667h682.666666v682.666666z"
+		p-id="3044"
+	></path>
+	<path
+		d="M387.2 379.733333a61.781333 61.781333 0 0 1 61.781333-61.781333h19.114667a30.890667 30.890667 0 0 0 0-61.781333h-19.114667a123.733333 123.733333 0 0 0-123.733333 123.733333v304.512a30.890667 30.890667 0 1 0 61.781333 0z"
+		p-id="3045"
+	></path>
+	<path
+		d="M261.76 429.610667h217.728a27.392 27.392 0 0 1 31.146667 30.890666 27.392 27.392 0 0 1-31.146667 30.890667h-217.6a27.434667 27.434667 0 0 1-31.146667-30.890667 27.392 27.392 0 0 1 31.146667-30.890666z"
+		p-id="3046"
+	></path>
+	<path
+		d="M737.322667 331.008a30.890667 30.890667 0 0 0-26.88 15.445333l-61.781334 108.117334-61.781333-108.117334a30.890667 30.890667 0 1 0-53.461333 30.890667l80.341333 139.008-80.341333 139.008a30.890667 30.890667 0 1 0 53.461333 30.890667l61.781333-108.117334 61.781334 108.117334a30.890667 30.890667 0 1 0 53.461333-30.890667l-80.341333-139.008 80.341333-139.008a30.890667 30.890667 0 0 0-26.581333-46.336z"
+		p-id="3047"
+	></path>
+</svg>

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 0 - 0
src/modules/base/static/svg/icon-map.svg


+ 1 - 1
src/modules/base/views/role.vue

@@ -5,7 +5,7 @@
 			<cl-add-btn />
 			<cl-multi-delete-btn />
 			<cl-flex1 />
-			<cl-search-key />
+			<cl-search-key placeholder="搜索名称" />
 		</cl-row>
 
 		<cl-row>

+ 17 - 1
src/modules/demo/views/crud.vue

@@ -96,7 +96,7 @@
 </template>
 
 <script lang="tsx" name="demo-crud" setup>
-import { useCrud, useUpsert, useTable, useAdvSearch, setFocus } from "@cool-vue/crud";
+import { useCrud, useUpsert, useTable, useAdvSearch, setFocus, useSearch } from "@cool-vue/crud";
 import { useDict } from "/$/dict";
 import { reactive } from "vue";
 import { ElMessage, ElMessageBox } from "element-plus";
@@ -485,4 +485,20 @@ const AdvSearch = useAdvSearch({
 		}
 	]
 });
+
+// 搜索
+const Search = useSearch({
+	items: [
+		{
+			label: "姓名",
+			prop: "name",
+			component: {
+				name: "el-input",
+				props: {
+					clearable: true
+				}
+			}
+		}
+	]
+});
 </script>

+ 1 - 2
src/modules/magic/hooks/ai.ts

@@ -1,7 +1,6 @@
 import { ElNotification } from "element-plus";
 import { io, Socket } from "socket.io-client";
 import { useCool } from "/@/cool";
-import { isString } from "lodash-es";
 
 export function useAi() {
 	const { route, router } = useCool();
@@ -11,7 +10,7 @@ export function useAi() {
 	// 连接
 	function connect(cb: { onMessage?(content: string): void; onComplete?(): void }) {
 		if (!socket) {
-			socket = io("http://192.168.0.224:9009/code", {
+			socket = io("https://service.cool-js.com/code", {
 				transports: ["websocket"]
 			});
 

+ 2 - 1
src/modules/upload/components/upload.vue

@@ -291,7 +291,8 @@ async function onBeforeUpload(file: any, item?: Upload.Item) {
 			type: getType(file.name),
 			progress: 0,
 			url: "",
-			preload: ""
+			preload: "",
+			error: ""
 		};
 
 		// 图片预览地址

+ 4 - 4
yarn.lock

@@ -282,10 +282,10 @@
     "@babel/helper-validator-identifier" "^7.22.20"
     to-fast-properties "^2.0.0"
 
-"@cool-vue/crud@^7.0.0-beta9":
-  version "7.0.0-beta9"
-  resolved "https://registry.yarnpkg.com/@cool-vue/crud/-/crud-7.0.0-beta9.tgz#4ce18b4f10a0deaf7715febfef88d0e068c615ba"
-  integrity sha512-uVBw7abKzkoZ3Q+VAQ2xVhMzScdjpwgbpcBVaNNj2zChELfsfmaxcFT19KLjdKmAyOtWE0+aMbj5/jyQPcJLnA==
+"@cool-vue/crud@^7.0.1-beta1":
+  version "7.0.1-beta1"
+  resolved "https://registry.yarnpkg.com/@cool-vue/crud/-/crud-7.0.1-beta1.tgz#74f74b2c2604bfb3a006fe19dfe96aee389ce21e"
+  integrity sha512-69QaNJ6I+Ha4bYo5vZiMpbb0z2q6hPbR/G997WIhXdLYDfwhRjrjpB2PnH1JIXMo00iuC5DJS01QdYBpXxVHFw==
   dependencies:
     array.prototype.flat "^1.2.4"
     core-js "^3.21.1"

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно