feat(Topology): upgrade to meta2d lib (#2499)

* refactor: 更新脚本为 meta2d

* chore: bump version 8.0.1

* feat: 移除 isSupportTouch 参数

* doc: 更新脚本名称

* chore: 更新依赖包

* refactor: 更新脚本

* chore: 更新引用包顺序
This commit is contained in:
Argo Zhang 2023-12-08 13:40:07 +08:00 committed by GitHub
parent a1fa395ce3
commit 167ea6424d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 45 additions and 41 deletions

View File

@ -27,7 +27,6 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="BootstrapBlazor.Middleware" Version="8.0.0" />
<PackageReference Include="Longbow.Logging" Version="7.0.0" />
<PackageReference Include="Longbow.Tasks" Version="7.0.0" />
<PackageReference Include="BootstrapBlazor.AzureOpenAI" Version="8.0.1" />
@ -47,6 +46,7 @@
<PackageReference Include="BootstrapBlazor.Markdown" Version="8.0.0" />
<PackageReference Include="BootstrapBlazor.MaterialDesign" Version="8.0.0" />
<PackageReference Include="BootstrapBlazor.MaterialDesign.Extensions" Version="8.0.0" />
<PackageReference Include="BootstrapBlazor.Middleware" Version="8.0.0" />
<PackageReference Include="BootstrapBlazor.MindMap" Version="8.0.0" />
<PackageReference Include="BootstrapBlazor.MouseFollower" Version="8.0.0" />
<PackageReference Include="BootstrapBlazor.OnScreenKeyboard" Version="8.0.0" />
@ -55,7 +55,7 @@
<PackageReference Include="BootstrapBlazor.Splitting" Version="8.0.0" />
<PackageReference Include="BootstrapBlazor.SummerNote" Version="8.0.1" />
<PackageReference Include="BootstrapBlazor.TableExport" Version="8.0.0" />
<PackageReference Include="BootstrapBlazor.Topology" Version="8.0.0" />
<PackageReference Include="BootstrapBlazor.Topology" Version="8.0.1" />
<PackageReference Include="BootstrapBlazor.VideoPlayer" Version="8.0.1" />
<PackageReference Include="BootstrapBlazor.WebAPI" Version="8.0.0" />
</ItemGroup>

View File

@ -7,5 +7,5 @@
}
export function execute() {
window.topology.setOptions({ hoverColor: '', hoverCursor: '', activeColor: '' });
window.meta2d.setOptions({ hoverColor: '', hoverCursor: '', activeColor: '' });
}

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">
<PropertyGroup>
<Version>8.0.0</Version>
<Version>8.0.1</Version>
</PropertyGroup>
<PropertyGroup>

View File

@ -44,6 +44,7 @@ public partial class Topology : IAsyncDisposable
/// </summary>
/// <remarks></remarks>
[Parameter]
[Obsolete("已过期,脚本已支持")]
public bool IsSupportTouch { get; set; }
/// <summary>
@ -74,7 +75,7 @@ public partial class Topology : IAsyncDisposable
/// <inheritdoc/>
/// </summary>
/// <returns></returns>
protected override Task InvokeInitAsync() => InvokeVoidAsync("init", Id, Interop, Content, nameof(PushData), IsSupportTouch, IsFitView, IsCenterView);
protected override Task InvokeInitAsync() => InvokeVoidAsync("init", Id, Interop, Content, nameof(PushData), IsFitView, IsCenterView);
/// <summary>
/// 开始推送数据方法

View File

@ -1,16 +1,16 @@
import '../../topology.js'
import '../../meta2d.js'
import Data from '../../../BootstrapBlazor/modules/data.js'
export function init(id, invoker, data, callback, isSupportTouch, isFit, isCenter) {
export function init(id, invoker, data, callback, isFit, isCenter) {
const el = document.getElementById(id)
if (el === null) { return }
const initCanvas = () => {
const option = { isFit, isCenter, isSupportTouch }
const topology = createTopology(el, data, option)
const option = { isFit, isCenter }
const meta2d = createMeta2d(el, data, option)
Data.set(id, {
el,
topology,
meta2d,
option
})
@ -34,16 +34,16 @@ export function init(id, invoker, data, callback, isSupportTouch, isFit, isCente
export function update(id, data) {
const meta = Data.get(id)
if (meta) {
meta.topology.doSocket(JSON.stringify(data))
meta.meta2d.doSocket(JSON.stringify(data))
}
}
export function scale(id, rate) {
const meta = Data.get(id)
if (meta) {
meta.topology.scale(rate)
meta.meta2d.scale(rate)
if (meta.option.isCenter) {
meta.topology.centerView()
meta.meta2d.centerView()
}
}
}
@ -51,32 +51,32 @@ export function scale(id, rate) {
export function reset(id) {
const meta = Data.get(id)
if (meta) {
meta.topology.fitView()
meta.topology.centerView()
meta.meta2d.fitView()
meta.meta2d.centerView()
}
}
export function resize(id, width, height, el, option) {
let topology = id
let meta2d = id
if (typeof (id) === 'string') {
const meta = Data.get(id)
if (meta) {
topology = meta.topology
meta2d = meta.meta2d
el = meta.el
option = meta.option
}
}
if (el.offsetHeight > 0 && el.offsetWidth > 0) {
topology.canvas.dirty = true
meta2d.canvas.dirty = true
if (width && height) {
topology.resize(width, height)
meta2d.resize(width, height)
}
else {
topology.resize()
meta2d.resize()
}
if (option.isCenter) {
topology.centerView()
meta2d.centerView()
}
}
}
@ -86,52 +86,55 @@ export function dispose(id) {
Data.remove(id)
if (meta) {
meta.topology.destroy()
delete meta.topology
meta.meta2d.destroy()
delete meta.meta2d
}
}
const createTopology = (el, data, option) => {
const topology = hackTopology(el, option.isSupportTouch)
topology.open(JSON.parse(data))
topology.lock(1)
const createMeta2d = (el, data, option) => {
const meta2d = hackMeta2d(el)
meta2d.open(JSON.parse(data))
meta2d.lock(1)
if (option.isFit) {
topology.fitView()
meta2d.fitView()
}
if (option.isCenter) {
topology.centerView()
meta2d.centerView()
}
el.observer = new ResizeObserver(() => {
resize(topology, null, null, el, option)
resize(meta2d, null, null, el, option)
})
el.observer.observe(el)
return topology
return meta2d
}
const hackTopology = (el, isSupportTouch) => {
if (Topology.isHack === undefined) {
Topology.isHack = true
Topology.prototype.lock = function (status) {
const hackMeta2d = el => {
if (Meta2d.isHack === void 0) {
Meta2d.isHack = true
Meta2d.prototype.lock = function (status) {
this.store.data.locked = status
this.finishDrawLine(!0)
this.canvas.drawingLineName = ""
this.stopPencil()
}
Topology.prototype.connectSocket = function () {
Meta2d.prototype.connectSocket = function () {
}
Meta2d.prototype.doSocket = function(data) {
this.socketCallback(data)
}
}
const topology = new Topology(el, {}, isSupportTouch)
const meta2d = new Meta2d(el)
const originalCanvasResize = topology.canvas.resize
topology.canvas.resize = function () {
const originalCanvasResize = meta2d.canvas.resize
meta2d.canvas.resize = function () {
const width = this.parentElement.clientWidth
const height = this.parentElement.clientHeight
if (width > 0 && height > 0) {
originalCanvasResize.call(this)
}
}
return topology;
return meta2d;
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long