From 95f8bcd2b9ef830df37d013f85d0b30ef3c2fafa Mon Sep 17 00:00:00 2001 From: nmtuan Date: Tue, 8 Aug 2023 07:44:35 +0800 Subject: [PATCH 1/6] =?UTF-8?q?chore:=20=E8=A1=A8=E5=8D=95=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E8=AE=BE=E7=BD=AE=EF=BC=8C=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/database/fields.vue | 33 +++++++++++++++++++++++++++++++++ composables/cloud.js | 4 +++- pages/index/[...key].vue | 1 + 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 components/database/fields.vue diff --git a/components/database/fields.vue b/components/database/fields.vue new file mode 100644 index 0000000..e334378 --- /dev/null +++ b/components/database/fields.vue @@ -0,0 +1,33 @@ + + + diff --git a/composables/cloud.js b/composables/cloud.js index 84fd666..76826bf 100644 --- a/composables/cloud.js +++ b/composables/cloud.js @@ -2,7 +2,7 @@ * @Author: NMTuan * @Email: NMTuan@qq.com * @Date: 2023-07-13 10:34:44 - * @LastEditTime: 2023-07-15 18:22:39 + * @LastEditTime: 2023-08-08 07:37:08 * @LastEditors: NMTuan * @Description: * @FilePath: \laf_curd\composables\cloud.js @@ -243,6 +243,8 @@ export const useCloud = (payload) => { return { _, collection, + collectionName, + cloud, fetch, count, fetchOne, diff --git a/pages/index/[...key].vue b/pages/index/[...key].vue index 1c7a571..380d4a0 100644 --- a/pages/index/[...key].vue +++ b/pages/index/[...key].vue @@ -21,6 +21,7 @@ +
From 9918fd0a2d68006d51992ea4468447e23ff862f1 Mon Sep 17 00:00:00 2001 From: nmtuan Date: Sat, 12 Aug 2023 16:06:45 +0800 Subject: [PATCH 2/6] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=EF=BC=9A?= =?UTF-8?q?=E8=A1=A8=E6=A0=BC=E5=88=97=E7=9A=84=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/database/fields.vue | 97 ++- components/manager/header.vue | 2 +- composables/cloud.js | 76 +- package.json | 2 +- pages/index/[...key].vue | 67 +- stores/field.ts.bak | 69 ++ yarn.lock | 1395 ++++++++++++++++---------------- 7 files changed, 991 insertions(+), 717 deletions(-) create mode 100644 stores/field.ts.bak diff --git a/components/database/fields.vue b/components/database/fields.vue index e334378..71ac4ff 100644 --- a/components/database/fields.vue +++ b/components/database/fields.vue @@ -2,32 +2,97 @@ * @Author: NMTuan * @Email: NMTuan@qq.com * @Date: 2023-08-08 07:34:55 - * @LastEditTime: 2023-08-08 07:42:48 + * @LastEditTime: 2023-08-12 15:05:11 * @LastEditors: NMTuan * @Description: * @FilePath: \laf_curd\components\database\fields.vue --> diff --git a/components/manager/header.vue b/components/manager/header.vue index 824af00..e150240 100644 --- a/components/manager/header.vue +++ b/components/manager/header.vue @@ -58,7 +58,7 @@ const fetchProfile = () => { path: '/v1/user/profile' }).then(res => { username.value = res.data.username || res.data.name - console.log('res', res) + // console.log('res', res) }) .catch(() => { }) } diff --git a/composables/cloud.js b/composables/cloud.js index 76826bf..c99934f 100644 --- a/composables/cloud.js +++ b/composables/cloud.js @@ -2,7 +2,7 @@ * @Author: NMTuan * @Email: NMTuan@qq.com * @Date: 2023-07-13 10:34:44 - * @LastEditTime: 2023-08-08 07:37:08 + * @LastEditTime: 2023-08-12 14:43:13 * @LastEditors: NMTuan * @Description: * @FilePath: \laf_curd\composables\cloud.js @@ -240,6 +240,76 @@ export const useCloud = (payload) => { }) } + // 获取字段配置 + const getFieldConfig = () => { + return new Promise((resolve, reject) => { + cloud + .database() + .collection('lafDB_fields') + .where({ + collectionName + }) + .getOne() + .then((res) => { + resolve(res) + }) + .catch((error) => { + reject(error) + }) + }) + } + const updateFieldConfig = (id, data) => { + console.log('updateFieldConfig', id, collectionName, data) + return new Promise((resolve, reject) => { + if (!id) { + cloud + .database() + .collection('lafDB_fields') + .add({ + collectionName, + columns: data + }) + .then((res) => { + resolve(res) + }) + .catch((err) => { + reject(err) + }) + } else { + cloud + .database() + .collection('lafDB_fields') + .doc(id) + .update({ + columns: data + }) + .then((res) => { + resolve(res) + }) + .catch((err) => { + reject(err) + }) + } + }) + + // const id = data._id + // delete data._id + // return new Promise((resolve, reject) => { + // cloud + // .database() + // .collection('lafDB_fields') + // .doc(id) + // .update(data) + // .then((res) => { + // console.log('x', res) + // resolve(res) + // }) + // .catch((error) => { + // reject(error) + // }) + // }) + } + return { _, collection, @@ -251,6 +321,8 @@ export const useCloud = (payload) => { update, remove, create, - run + run, + getFieldConfig, + updateFieldConfig } } diff --git a/package.json b/package.json index e8301c2..46503ea 100644 --- a/package.json +++ b/package.json @@ -15,13 +15,13 @@ "@types/node": "^18", "@unocss/nuxt": "^0.53.4", "element-plus": "^2.3.7", - "nuxt": "^3.6.1", "sass": "^1.63.6" }, "dependencies": { "@pinia/nuxt": "^0.4.11", "ejson-shell-parser": "^1.2.4", "laf-client-sdk": "^1.0.0-beta.8", + "nuxt": "^3.6.5", "pinia": "^2.1.4", "simplebar-vue": "^2.3.3" } diff --git a/pages/index/[...key].vue b/pages/index/[...key].vue index 380d4a0..659f768 100644 --- a/pages/index/[...key].vue +++ b/pages/index/[...key].vue @@ -20,8 +20,8 @@ +
-
@@ -29,9 +29,9 @@ @@ -52,8 +52,11 @@