mirror of
https://github.com/real-zony/ZonyLrcToolsX.git
synced 2025-07-01 20:30:41 +00:00
feat: Completed early communication testing.
data-table has serious performance problem.
This commit is contained in:
parent
6554be6b6d
commit
a11ef70021
@ -16,7 +16,12 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Folder Include="Lyrics\Providers\Kugeci" />
|
||||||
<Folder Include="Lyrics\Providers\KuWo" />
|
<Folder Include="Lyrics\Providers\KuWo" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Remove="Lyrics\Providers\Kugeci\KugeciDownloader.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -30,7 +30,7 @@ WebApplication? RegisterAndConfigureServices()
|
|||||||
|
|
||||||
insideApp.UseAuthorization();
|
insideApp.UseAuthorization();
|
||||||
insideApp.MapControllers();
|
insideApp.MapControllers();
|
||||||
insideApp.Lifetime.ApplicationStarted.Register(OpenBrowser);
|
// insideApp.Lifetime.ApplicationStarted.Register(OpenBrowser);
|
||||||
|
|
||||||
return insideApp;
|
return insideApp;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using SuperSocket.WebSocket.Server;
|
using Newtonsoft.Json;
|
||||||
|
using SuperSocket.WebSocket.Server;
|
||||||
|
|
||||||
namespace ZonyLrcTools.LocalServer;
|
namespace ZonyLrcTools.LocalServer;
|
||||||
|
|
||||||
@ -7,9 +8,65 @@ public class SuperSocketListener
|
|||||||
public async Task ListenAsync()
|
public async Task ListenAsync()
|
||||||
{
|
{
|
||||||
var host = WebSocketHostBuilder.Create()
|
var host = WebSocketHostBuilder.Create()
|
||||||
.UseWebSocketMessageHandler(async (session, message) => { await session.SendAsync(message.Message); })
|
.UseWebSocketMessageHandler(async (session, message) =>
|
||||||
|
{
|
||||||
|
await session.SendAsync(JsonConvert.SerializeObject(new CommunicateEvent<OutputEvent>
|
||||||
|
{
|
||||||
|
Action = "output",
|
||||||
|
Type = ActionType.ResponseAction,
|
||||||
|
Data = new OutputEvent()
|
||||||
|
}));
|
||||||
|
|
||||||
|
for (int index = 0; index < 50; index++)
|
||||||
|
{
|
||||||
|
var data = new List<GetFileInfoEvent>();
|
||||||
|
for (int j = 0; j < 500; j++)
|
||||||
|
{
|
||||||
|
data.Add(new GetFileInfoEvent
|
||||||
|
{
|
||||||
|
Name = j.ToString(),
|
||||||
|
Size = j.ToString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
await session.SendAsync(JsonConvert.SerializeObject(new CommunicateEvent<List<GetFileInfoEvent>>
|
||||||
|
{
|
||||||
|
Action = "getFileInfo",
|
||||||
|
Type = ActionType.ResponseAction,
|
||||||
|
Data = data
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
await Task.Delay(100);
|
||||||
|
})
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
await host.StartAsync();
|
await host.StartAsync();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class CommunicateEvent<T> where T : class
|
||||||
|
{
|
||||||
|
[JsonProperty("action")] public string? Action { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("type")] public ActionType Type { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("data")] public T? Data { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class OutputEvent
|
||||||
|
{
|
||||||
|
[JsonProperty("text")] public string Text => DateTime.Now.ToString("HH:mm:ss");
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GetFileInfoEvent
|
||||||
|
{
|
||||||
|
[JsonProperty("name")] public string Name { get; set; }
|
||||||
|
[JsonProperty("size")] public string Size { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum ActionType
|
||||||
|
{
|
||||||
|
RequestAction,
|
||||||
|
ResponseAction
|
||||||
}
|
}
|
@ -25,6 +25,10 @@
|
|||||||
<EmbeddedResource Include="UiStaticResources\**" />
|
<EmbeddedResource Include="UiStaticResources\**" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\ZonyLrcTools.Common\ZonyLrcTools.Common.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<!-- <ItemGroup>-->
|
<!-- <ItemGroup>-->
|
||||||
<!-- <ProjectReference Include="..\ZonyLrcTools.Cli\ZonyLrcTools.Cli.csproj" />-->
|
<!-- <ProjectReference Include="..\ZonyLrcTools.Cli\ZonyLrcTools.Cli.csproj" />-->
|
||||||
<!-- </ItemGroup>-->
|
<!-- </ItemGroup>-->
|
||||||
|
5
src/ui/src/communication/eventbus.js
Normal file
5
src/ui/src/communication/eventbus.js
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import Vue from "vue";
|
||||||
|
|
||||||
|
const eventBus = new Vue();
|
||||||
|
|
||||||
|
export default eventBus;
|
@ -1,4 +1,5 @@
|
|||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
|
import eventBus from "@/communication/eventbus";
|
||||||
|
|
||||||
// const wsUrl = process.env.VUE_APP_WS_URL;
|
// const wsUrl = process.env.VUE_APP_WS_URL;
|
||||||
const wsUrl = "ws://127.0.0.1:50001"
|
const wsUrl = "ws://127.0.0.1:50001"
|
||||||
@ -13,10 +14,11 @@ const emitter = new Vue({
|
|||||||
}, connect() {
|
}, connect() {
|
||||||
socket = new WebSocket(wsUrl);
|
socket = new WebSocket(wsUrl);
|
||||||
socket.onmessage = (msg) => {
|
socket.onmessage = (msg) => {
|
||||||
this.$emit('message', msg.data);
|
let event = JSON.parse(msg.data);
|
||||||
|
eventBus.$emit(event.action, event);
|
||||||
};
|
};
|
||||||
socket.onerror = (err) => {
|
socket.onerror = (err) => {
|
||||||
this.$emit('error', err);
|
eventBus.$emit('error', err);
|
||||||
};
|
};
|
||||||
socket.onclose = () => {
|
socket.onclose = () => {
|
||||||
emitter.connect()
|
emitter.connect()
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import Vuex from 'vuex'
|
import Vuex from 'vuex'
|
||||||
import ws from './ws'
|
|
||||||
|
|
||||||
Vue.use(Vuex)
|
Vue.use(Vuex)
|
||||||
|
|
||||||
@ -9,5 +8,5 @@ export default new Vuex.Store({
|
|||||||
getters: {},
|
getters: {},
|
||||||
mutations: {},
|
mutations: {},
|
||||||
actions: {},
|
actions: {},
|
||||||
modules: {ws}
|
modules: {}
|
||||||
})
|
})
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
export const state = {
|
|
||||||
wsRes: {}
|
|
||||||
};
|
|
||||||
|
|
||||||
export const actions = {};
|
|
||||||
|
|
||||||
export const mutations = {
|
|
||||||
setWsRes(newState, payload) {
|
|
||||||
state.wsRes = payload;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getters = {};
|
|
||||||
|
|
||||||
export default {
|
|
||||||
state,
|
|
||||||
actions,
|
|
||||||
mutations,
|
|
||||||
getters,
|
|
||||||
namespaced: true
|
|
||||||
}
|
|
@ -21,15 +21,15 @@
|
|||||||
</template>
|
</template>
|
||||||
</v-data-table>
|
</v-data-table>
|
||||||
<div class="output mt-8">
|
<div class="output mt-8">
|
||||||
<v-textarea disabled outlined label="日志信息" value="输出"/>
|
<v-textarea disabled outlined label="日志信息" :value='outputText'/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {mapState} from 'vuex'
|
|
||||||
import Socket from '@/communication/socket'
|
import Socket from '@/communication/socket'
|
||||||
|
import eventBus from "@/communication/eventbus";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Home',
|
name: 'Home',
|
||||||
@ -52,14 +52,9 @@ export default {
|
|||||||
size: 159,
|
size: 159,
|
||||||
status: 'success',
|
status: 'success',
|
||||||
action: 4.0,
|
action: 4.0,
|
||||||
},
|
}
|
||||||
{
|
|
||||||
name: 'Ice cream sandwich',
|
|
||||||
size: 237,
|
|
||||||
status: 'error',
|
|
||||||
action: 4.3,
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
|
outputText: ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@ -70,15 +65,25 @@ export default {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {},
|
||||||
...mapState({
|
mounted() {
|
||||||
wsRes: state => state.ws.wsRes
|
// eventBus.$on('getFile', (msgData) => {
|
||||||
})
|
// console.log(msgData);
|
||||||
},
|
// });
|
||||||
watch: {
|
eventBus.$on('getFileInfo', (msgData) => {
|
||||||
wsRes(val) {
|
this.items = [...this.items, ...msgData.data.map(item => {
|
||||||
console.log('echo from server: ', val)
|
return {
|
||||||
}
|
name: item.name,
|
||||||
|
size: item.size,
|
||||||
|
status: 'success',
|
||||||
|
action: 4.0,
|
||||||
|
}
|
||||||
|
})]
|
||||||
|
});
|
||||||
|
|
||||||
|
eventBus.$on('output', (msgData) => {
|
||||||
|
this.outputText = this.outputText.concat(msgData.data.text).concat('\n');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user