debug.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <template>
  2. <ie-page bg-color="#F6F8FA">
  3. <ie-navbar title="调试" />
  4. <view class="p-20">
  5. <view class="h-20 my-20">用户数据:</view>
  6. <view class="bg-white">
  7. <textarea class="p-20 h-400 break-all" v-model="userJson" maxlength="-1"></textarea>
  8. </view>
  9. </view>
  10. <view class="m-20">
  11. <uv-button type="primary" @click="handleLoad">加载</uv-button>
  12. </view>
  13. <view class="p-20">
  14. <view class="h-20 my-20">app数据:</view>
  15. <view class="bg-white">
  16. <textarea class="p-20 h-400 break-all" v-model="appJson" maxlength="-1"></textarea>
  17. </view>
  18. </view>
  19. <view class="m-20">
  20. <uv-button type="primary" @click="handleLoad">加载</uv-button>
  21. </view>
  22. <view class="m-20">
  23. <uv-button type="success" @click="handleToHome">进入首页</uv-button>
  24. </view>
  25. </ie-page>
  26. </template>
  27. <script lang="ts" setup>
  28. import { useUserStore } from '@/store/userStore';
  29. import { useAppStore } from '@/store/appStore';
  30. const userStore = useUserStore();
  31. const appStore = useAppStore();
  32. const userJson = ref('');
  33. const appJson = ref('');
  34. const handleLoad = () => {
  35. if (userJson.value) {
  36. try {
  37. userStore.loadFromLocal(userJson.value);
  38. uni.$ie.showToast('加载成功');
  39. } catch (error) {
  40. uni.$ie.showToast('加载失败');
  41. }
  42. }
  43. }
  44. const handleLoadApp = () => {
  45. if (appJson.value) {
  46. try {
  47. appStore.loadFromLocal(appJson.value);
  48. uni.$ie.showToast('加载成功');
  49. } catch (error) {
  50. uni.$ie.showToast('加载失败');
  51. }
  52. }
  53. }
  54. const handleToHome = () => {
  55. uni.reLaunch({
  56. url: '/pagesMain/pages/index/index',
  57. type: 'reLaunch'
  58. });
  59. }
  60. </script>
  61. <style lang="scss"></style>