Browse Source

update

pull/1/head
wanggang 1 year ago
parent
commit
d1ccdc2b50
  1. 16
      code/.gitignore
  2. BIN
      code/.vs/BeiJinSettleAccount/v17/.suo
  3. 6
      code/WebApp/vanilla/index.html
  4. 14
      code/WebApp/vanilla/router/index.js
  5. 15
      code/WebApp/vanilla/views/user/index.js
  6. 2
      docs/demo/src/WTA.Shared/Attributes/OneToManyAttribute.cs
  7. 4
      docs/demo/src/WTA.Shared/Extensions/JsonSchemaExtensions.cs

16
code/.gitignore

@ -0,0 +1,16 @@
*.bak
#fe
node_modules/
dist/
#be
.vs/
bin/
obj/
*.suo
*.user
*.db
*.db-shm
*.db-wal

BIN
code/.vs/BeiJinSettleAccount/v17/.suo

Binary file not shown.

6
code/WebApp/vanilla/index.html

@ -3,7 +3,9 @@
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="renderer" content="webkit">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<base href="/" /> <base href="/" />
<style> <style>
@keyframes loading-rotate { @keyframes loading-rotate {
@ -69,4 +71,4 @@
<script type="module" src="./main.js"></script> <script type="module" src="./main.js"></script>
</body> </body>
</html> </html>

14
code/WebApp/vanilla/router/index.js

@ -89,14 +89,18 @@ router.afterEach((to, from) => {
} }
}); });
const reset = (list, parent = null) => { const reset = async (list, parent = null) => {
return list.map((o) => { return list.map(async (o) => {
const item = { const item = {
path: o.path, path: o.path,
meta: o.meta, meta: o.meta,
}; };
if (item.component && item.component !== "Layout") { if (o.component && typeof o.component === "string" && o.component !== "Layout") {
item.component = import(`../views/${o.component ? o.component : "list"}.js`); try {
item.component = await import(`../views/${o.component}.js`);
} catch (error) {
item.component = await import(`../views/list.js`);
}
} }
item.meta.path = `${parent === null ? "" : parent.meta.path + "/"}${item.path}`; item.meta.path = `${parent === null ? "" : parent.meta.path + "/"}${item.path}`;
item.meta.fullName = `${parent === null ? "" : parent.meta.title + " > "}${item.meta.title}`; item.meta.fullName = `${parent === null ? "" : parent.meta.title + " > "}${item.meta.title}`;
@ -120,7 +124,7 @@ const refreshRouter = async () => {
await connect(); await connect();
const appStore = useAppStore(); const appStore = useAppStore();
const permissions = appStore.user.permissions.filter((o) => !o.isHidden); const permissions = appStore.user.permissions.filter((o) => !o.isHidden);
const serverRoutes = reset(permissions); const serverRoutes = await reset(permissions);
const route = { const route = {
name: "layout", name: "layout",
path: "", path: "",

15
code/WebApp/vanilla/views/user/index.js

@ -0,0 +1,15 @@
import AppList from "../components/list/index.js";
import html from "html";
import router from "../router/index.js";
export default {
components: { AppList },
template: html`<app-list @command="onCommand"> </app-list>`,
setup() {
console.log(router.currentRoute.value.fullPath);
const onCommand = (item, rows) => {
console.log(item.path, item, rows);
};
return { onCommand };
},
};

2
docs/demo/src/WTA.Shared/Attributes/OneToManyAttribute.cs

@ -1,7 +1,7 @@
namespace WTA.Shared.Attributes; namespace WTA.Shared.Attributes;
[AttributeUsage(AttributeTargets.Property)] [AttributeUsage(AttributeTargets.Property)]
public class OneToManyAttribute<TEntity> : Attribute public class OneToManyAttribute<TEntity> : Attribute, ITypeAttribute
{ {
public Type Type { get; set; } = null!; public Type Type { get; set; } = null!;
public string? Property { get; } public string? Property { get; }

4
docs/demo/src/WTA.Shared/Extensions/JsonSchemaExtensions.cs

@ -153,6 +153,10 @@ public static class JsonSchemaExtensions
schema.Add("input", "select"); schema.Add("input", "select");
schema.Add("url", propertyName[..^2].ToSlugify()); schema.Add("url", propertyName[..^2].ToSlugify());
} }
if (defaultModelMetadata.Attributes.Attributes.FirstOrDefault(o => o.GetType().IsGenericType && o.GetType().GetGenericTypeDefinition() == typeof(OneToManyAttribute<>)) is ITypeAttribute oneToManyAttribute)
{
schema.Add("oneToMany",$"{oneToManyAttribute.Type.Name}.{oneToManyAttribute.GetType().GetProperty("Property")?.GetValue(oneToManyAttribute)??defaultModelMetadata.PropertyName}");
}
if (defaultModelMetadata.Attributes.Attributes.FirstOrDefault(o => o.GetType() == typeof(ScaffoldColumnAttribute)) is ScaffoldColumnAttribute scaffoldColumnAttribute if (defaultModelMetadata.Attributes.Attributes.FirstOrDefault(o => o.GetType() == typeof(ScaffoldColumnAttribute)) is ScaffoldColumnAttribute scaffoldColumnAttribute
&& !scaffoldColumnAttribute.Scaffold) && !scaffoldColumnAttribute.Scaffold)
{ {

Loading…
Cancel
Save