Skip to content

Commit

Permalink
perf: rowHandle动态显隐示例
Browse files Browse the repository at this point in the history
  • Loading branch information
greper committed Jul 6, 2021
1 parent bff2a77 commit 0ad8205
Show file tree
Hide file tree
Showing 10 changed files with 107 additions and 25 deletions.
2 changes: 1 addition & 1 deletion packages/demo-element/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"author": "Greper",
"license": "MIT",
"dependencies": {
"@fast-crud/extends-uploader": "^0.13.0",
"@fast-crud/fast-extends": "^0.14.0",
"@fast-crud/fast-crud": "^0.14.0",
"@fast-crud/ui-element": "^0.14.0",
"@iconify/iconify": "^2.0.1",
Expand Down
28 changes: 14 additions & 14 deletions packages/demo-element/src/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { request, requestForMock } from "./api/service";
import "./mock";
import { FastCrud, setLogger } from "@fast-crud/fast-crud";
import "@fast-crud/fast-crud/dist/style.css";
import FsUploader from "@fast-crud/extends-uploader";
import "@fast-crud/extends-uploader/dist/style.css";
import { FsExtendsUploader, FsExtendsEditor } from "@fast-crud/fast-extends";
import "@fast-crud/fast-extends/dist/style.css";
import UiElement from "@fast-crud/ui-element";
//设置crud log级别
if (import.meta.env.mode !== "production") {
Expand Down Expand Up @@ -39,30 +39,30 @@ export default function (app, i18n) {
}
});

app.use(FsExtendsEditor);
//配置uploader 公共参数
app.use(FsUploader, {
app.use(FsExtendsUploader, {
defaultType: "cos",
cos: {
domain: "https://d2p-demo-1251260344.cos.ap-guangzhou.myqcloud.com",
bucket: "d2p-demo-1251260344",
region: "ap-guangzhou",
secretId: "", //
secretKey: "", // 传了secretKey 和secretId 代表使用本地签名模式(不安全,生产环境不推荐)
getAuthorization(custom) {
async getAuthorization(custom) {
// 不传secretKey代表使用临时签名模式,此时此参数必传(安全,生产环境推荐)
return request({
const ret = await request({
url: "/upload/cos/getAuthorization",
method: "get"
}).then((ret) => {
// 返回结构如下
// ret.data:{
// TmpSecretId,
// TmpSecretKey,
// XCosSecurityToken,
// ExpiredTime, // SDK 在 ExpiredTime 时间前,不会再次调用 getAuthorization
// }
return ret;
});
// 返回结构如下
// ret.data:{
// TmpSecretId,
// TmpSecretKey,
// XCosSecurityToken,
// ExpiredTime, // SDK 在 ExpiredTime 时间前,不会再次调用 getAuthorization
// }
return ret;
},
successHandle(ret) {
// 上传完成后可以在此处处理结果,修改url什么的
Expand Down
1 change: 1 addition & 0 deletions packages/fast-crud/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"@types/chai": "^4.2.11",
"@types/jest": "^26.0.21",
"@types/mocha": "^8.2.2",
"@types/node": "^16.0.0",
"@typescript-eslint/eslint-plugin": "^4.16.1",
"@typescript-eslint/parser": "^4.16.1",
"@vitejs/plugin-legacy": "^1.3.1",
Expand Down
4 changes: 3 additions & 1 deletion packages/fast-crud/src/components/crud/fs-row-handle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ export default defineComponent({
};
});
const computeProps = doComputed(pickedProps, () => {
return props.scope;
const index = props.scope[ui.tableColumn.index];
const row = props.scope[ui.tableColumn.row];
return { ...props.scope, index, row };
});
//const computeProps = { value: props };
const computedAllHandleBtns = computed(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
</component>
</template>

<script>
<script lang="ts">
import draggable from "vuedraggable/src/vuedraggable";
import _ from "lodash-es";
import FsButton from "../../basic/fs-button";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import defaultCrudOptions from "./use/default-crud-options";
import utils from "./utils/index.js";
import utils from "./utils/index";
export * from "./utils/index";
export * from "./use";
import types from "./types/index.ts";
import types from "./types/index";
import * as components from "./components/index";
import { i18n, useI18n } from "./locale/";
import { uiContext } from "./ui";
Expand Down
4 changes: 3 additions & 1 deletion packages/fast-crud/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import logger from "./util.log";
import strings from "./util.string";
import trace from "./util.trace";
import vite from "./util.vite";
import store from "./util.store";
export * from "./util.log";
export default {
logger,
strings,
trace,
vite
vite,
store
};
77 changes: 77 additions & 0 deletions packages/fast-crud/src/utils/util.store.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
export default class TableStore {
constructor({ $router, tableName, keyType }) {
this.key = this.getItemKey($router, keyType);
this.tableId = this.getTableId(tableName);
}

getTableId(name) {
const prefix = "fs-crud";
if (name && typeof name === "string") {
return prefix + "." + name;
}
return prefix;
}

getTable() {
const saved = localStorage.getItem(this.tableId);
if (saved == null) {
return;
}
return JSON.parse(saved);
}

saveTable(table) {
localStorage.setItem(this.tableId, JSON.stringify(table));
}

clearTable() {
localStorage.setItem(this.tableId, null);
}

updateTableValue(value, key) {
let table = this.getTable();
if (table == null) {
table = {};
}

if (key == null) {
key = this.key;
}
table[key] = value;
this.saveTable(table);
}

getItemKey($route, keyType) {
let key = location.href;
if ($route) {
key = $route.path;
}
if (keyType == null || typeof keyType !== "string") {
return key;
}
return key + "." + keyType;
}

getTableValue(key) {
const table = this.getTable();
if (table == null) {
return null;
}
if (key == null) {
key = this.key;
}
return table[key];
}

clearTableValue(key) {
const table = this.getTable();
if (table == null) {
return;
}
if (key == null) {
key = this.key;
}
delete table[key];
this.saveTable(table);
}
}
8 changes: 4 additions & 4 deletions packages/fast-crud/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
"vite/client", "@types/jest",
"webpack-env",
"mocha",
"chai"
"chai",
"node"
],
"paths": {
"@/*": [
"src/*"
]
"/@/*": ["src/*"],
"/src/*": [ "src/*"]
},
"lib": [
"esnext",
Expand Down

0 comments on commit 0ad8205

Please sign in to comment.