From 34257f504330191b1a698eb48b52217095db47fe Mon Sep 17 00:00:00 2001 From: zmc <zmc_li@foxmail.com> Date: 星期一, 04 九月 2023 18:10:46 +0800 Subject: [PATCH] 扬尘vue --- src/views/setting/SetConfiguration.vue | 76 +++++++++++++++++++++++++++++-------- 1 files changed, 59 insertions(+), 17 deletions(-) diff --git a/src/views/setting/SetConfiguration.vue b/src/views/setting/SetConfiguration.vue index 7f7df82..d8d07c5 100644 --- a/src/views/setting/SetConfiguration.vue +++ b/src/views/setting/SetConfiguration.vue @@ -1,34 +1,76 @@ <script> -// import DustRadarChart from '../../sfc/DustRadarChart.vue'; -// import TimeSelectWithShortCuts from '../../sfc/TimeSelectWithShortCuts.vue' -import dayjs from 'dayjs'; - export default { - components :{ - // DustRadarChart, - // TimeSelectWithShortCuts - }, - data() { +import {useCounterStore} from '@/stores/counter'; +export default { + data(){ return{ } - }, - mounted() { + }, + setup(){ + const store = useCounterStore() + const unsubscribe = store.$onAction( + ({ + name, // action 鐨勫悕瀛� + store, // store 瀹炰緥 + args, // 璋冪敤杩欎釜 action 鐨勫弬鏁� + after, // 鍦ㄨ繖涓� action 鎵ц瀹屾瘯涔嬪悗锛屾墽琛岃繖涓嚱鏁� + onError, // 鍦ㄨ繖涓� action 鎶涘嚭寮傚父鐨勬椂鍊欙紝鎵ц杩欎釜鍑芥暟 + }) => { + // 璁板綍寮�濮嬬殑鏃堕棿鍙橀噺 + const startTime = Date.now() + // 杩欏皢鍦� `store` 涓婄殑鎿嶄綔鎵ц涔嬪墠瑙﹀彂 + console.log(`Start "${name}" with params [${args.join(', ')}].`) + // 濡傛灉 action 鎴愬姛骞朵笖瀹屽叏杩愯鍚庯紝after 灏嗚Е鍙戙�� + // 瀹冨皢绛夊緟浠讳綍杩斿洖鐨� promise + after((result) => { + console.log( + `Finished "${name}" after ${ + Date.now() - startTime + }ms.\nResult: ${result}.` + ) + }) + + // 濡傛灉 action 鎶涘嚭鎴栬繑鍥� Promise.reject 锛宱nError 灏嗚Е鍙� + onError((error) => { + console.warn( + `Failed "${name}" after ${Date.now() - startTime}ms.\nError: ${error}.` + ) + }) + } +) + return{ + store,unsubscribe + } + }, + computed:{ + a(){ + return this.store.doubleCount*2 }, - methods: { - } + }, + mounted(){ + + }, + methods:{ + doThing(){ + this.store.increment(5) + this.store.doubleCount + } + } } </script> <template> <div> - 鏁版嵁鎺ュ叆閰嶇疆 + <el-button type="primary" @click="doThing">鐐瑰嚮{{ store.doubleCount }}</el-button> </div> - + <div>{{ a }}</div> + <div>{{ store.secret }}</div> + <div>{{ store.vue }}</div> + <div>{{ store.澶� }}</div> </template> - -<style scoped> +<style scoped> </style> \ No newline at end of file -- Gitblit v1.9.3