mirror of
https://github.com/ArvinLovegood/go-stock.git
synced 2025-07-19 00:00:09 +08:00
refactor(frontend):优化股票排序
- 在 stock.vue 中引入 lodash 的 keys 和 pad 函数 -优化排序逻辑,使用 lodash 的 keys 函数替代 Object.keys -移除不必要的 padZero 函数,简化 GetSortKey 的实现 - 在 package.json 中添加 lodash 依赖
This commit is contained in:
parent
7af3fe72d5
commit
63e898bef8
4
frontend/package-lock.json
generated
4
frontend/package-lock.json
generated
@ -14,6 +14,7 @@
|
|||||||
"@vicons/ionicons5": "^0.13.0",
|
"@vicons/ionicons5": "^0.13.0",
|
||||||
"file-saver": "^2.0.5",
|
"file-saver": "^2.0.5",
|
||||||
"html2canvas": "^1.4.1",
|
"html2canvas": "^1.4.1",
|
||||||
|
"lodash": "^4.17.21",
|
||||||
"md-editor-v3": "^5.2.3",
|
"md-editor-v3": "^5.2.3",
|
||||||
"vue": "^3.2.25",
|
"vue": "^3.2.25",
|
||||||
"vue-router": "^4.5.0",
|
"vue-router": "^4.5.0",
|
||||||
@ -1758,8 +1759,7 @@
|
|||||||
"node_modules/lodash": {
|
"node_modules/lodash": {
|
||||||
"version": "4.17.21",
|
"version": "4.17.21",
|
||||||
"resolved": "https://registry.npmmirror.com/lodash/-/lodash-4.17.21.tgz",
|
"resolved": "https://registry.npmmirror.com/lodash/-/lodash-4.17.21.tgz",
|
||||||
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
|
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"node_modules/lodash-es": {
|
"node_modules/lodash-es": {
|
||||||
"version": "4.17.21",
|
"version": "4.17.21",
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
"@vicons/ionicons5": "^0.13.0",
|
"@vicons/ionicons5": "^0.13.0",
|
||||||
"file-saver": "^2.0.5",
|
"file-saver": "^2.0.5",
|
||||||
"html2canvas": "^1.4.1",
|
"html2canvas": "^1.4.1",
|
||||||
|
"lodash": "^4.17.21",
|
||||||
"md-editor-v3": "^5.2.3",
|
"md-editor-v3": "^5.2.3",
|
||||||
"vue": "^3.2.25",
|
"vue": "^3.2.25",
|
||||||
"vue-router": "^4.5.0",
|
"vue-router": "^4.5.0",
|
||||||
|
@ -1 +1 @@
|
|||||||
2091cce83d29f564a50e85f1667b2f4c
|
cf858d682535e094e087a036e009d7f8
|
@ -46,6 +46,7 @@ import html2canvas from "html2canvas";
|
|||||||
import {asBlob} from 'html-docx-js-typescript';
|
import {asBlob} from 'html-docx-js-typescript';
|
||||||
|
|
||||||
import vueDanmaku from 'vue3-danmaku'
|
import vueDanmaku from 'vue3-danmaku'
|
||||||
|
import {keys, pad} from "lodash";
|
||||||
const danmus = ref([])
|
const danmus = ref([])
|
||||||
const ws = ref(null)
|
const ws = ref(null)
|
||||||
|
|
||||||
@ -116,7 +117,8 @@ const icon = ref('https://raw.githubusercontent.com/ArvinLovegood/go-stock/maste
|
|||||||
|
|
||||||
const sortedResults = computed(() => {
|
const sortedResults = computed(() => {
|
||||||
//console.log("computed",sortedResults.value)
|
//console.log("computed",sortedResults.value)
|
||||||
const sortedKeys =Object.keys(results.value).sort();
|
const sortedKeys =keys(results.value).sort();
|
||||||
|
//console.log("sortedKeys",sortedKeys)
|
||||||
const sortedObject = {};
|
const sortedObject = {};
|
||||||
sortedKeys.forEach(key => {
|
sortedKeys.forEach(key => {
|
||||||
sortedObject[key] = results.value[key];
|
sortedObject[key] = results.value[key];
|
||||||
@ -141,7 +143,7 @@ onBeforeMount(()=>{
|
|||||||
followedStock.StockCode="gb_"+ followedStock.StockCode.replace("us", "").toLowerCase()
|
followedStock.StockCode="gb_"+ followedStock.StockCode.replace("us", "").toLowerCase()
|
||||||
}
|
}
|
||||||
if (!stocks.value.includes(followedStock.StockCode)) {
|
if (!stocks.value.includes(followedStock.StockCode)) {
|
||||||
console.log("followList",followedStock.StockCode)
|
//console.log("followList",followedStock.StockCode)
|
||||||
stocks.value.push(followedStock.StockCode)
|
stocks.value.push(followedStock.StockCode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -395,6 +397,7 @@ function removeMonitor(code,name,key) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function SendDanmu(){
|
function SendDanmu(){
|
||||||
//danmus.value.push(data.name)
|
//danmus.value.push(data.name)
|
||||||
console.log("SendDanmu",data.name)
|
console.log("SendDanmu",data.name)
|
||||||
@ -491,7 +494,8 @@ async function updateData(result) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result.key=GetSortKey(result.sort,result["股票代码"])
|
result.key=result.sort
|
||||||
|
//result.key=GetSortKey(result.sort,result["股票代码"])
|
||||||
results.value[GetSortKey(result.sort,result["股票代码"])]=result
|
results.value[GetSortKey(result.sort,result["股票代码"])]=result
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -505,13 +509,11 @@ async function monitor() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//数字长度不够前面补0
|
|
||||||
function padZero(num, length) {
|
|
||||||
return (Array(length).join('0') + num).slice(-length);
|
|
||||||
}
|
|
||||||
|
|
||||||
function GetSortKey(sort,code){
|
function GetSortKey(sort,code){
|
||||||
return padZero(sort,6)+"_"+code
|
//let sortKey= pad(sort,6,'0')+"_"+code
|
||||||
|
//console.log("GetSortKey:",sortKey)
|
||||||
|
return sort
|
||||||
}
|
}
|
||||||
|
|
||||||
function onSelect(item) {
|
function onSelect(item) {
|
||||||
|
@ -3,9 +3,7 @@ import naive from 'naive-ui'
|
|||||||
import App from './App.vue'
|
import App from './App.vue'
|
||||||
import router from './router/router'
|
import router from './router/router'
|
||||||
|
|
||||||
|
|
||||||
const app = createApp(App)
|
const app = createApp(App)
|
||||||
|
|
||||||
app.use(router)
|
app.use(router)
|
||||||
app.use(naive)
|
app.use(naive)
|
||||||
app.mount('#app')
|
app.mount('#app')
|
Loading…
x
Reference in New Issue
Block a user