"use strict"; const common_vendor = require("../../common/vendor.js"); const _sfc_main = { data() { return { toggleSettings: [ { label: "阅读时不自动锁屏", value: false, key: "noAutoLock" }, { label: "阅读时隐藏别人的笔记", value: false, key: "hideOthersNotes" }, { label: "阅读时显示时间和电量", value: true, key: "showTimeBattery" }, { label: "阅读时允许横屏", value: false, key: "allowLandscape" }, { label: "点赞提醒", value: true, key: "likeReminder" } ], cacheSize: "20M" }; }, onLoad() { this.loadSettings(); this.loadCacheSize(); }, methods: { goBack() { common_vendor.index.navigateBack(); }, handleToggleChange(index, event) { this.toggleSettings[index].value = event.detail.value; this.saveSettings(); }, handleInfoClick(type) { switch (type) { case "clearCache": this.clearCache(); break; case "about": this.showAbout(); break; case "contact": this.showContact(); break; } }, clearCache() { common_vendor.index.showModal({ title: "提示", content: `确定要清理 ${this.cacheSize} 缓存吗?`, success: (res) => { if (res.confirm) { common_vendor.index.clearStorageSync(); this.cacheSize = "0M"; common_vendor.index.showToast({ title: "缓存已清理", icon: "success" }); } } }); }, showAbout() { common_vendor.index.navigateTo({ url: "/pages/about/about" }); }, showContact() { common_vendor.index.showModal({ title: "联系我们", content: "邮箱: support@yunread.com\n电话: 400-123-4567", showCancel: false }); }, handleLogout() { common_vendor.index.showModal({ title: "提示", content: "确定要退出登录吗?", success: (res) => { if (res.confirm) { common_vendor.index.removeStorageSync("token"); common_vendor.index.removeStorageSync("userInfo"); common_vendor.index.showToast({ title: "已退出登录", icon: "success" }); setTimeout(() => { common_vendor.index.reLaunch({ url: "/pages/login/login" }); }, 1500); } } }); }, loadSettings() { const savedSettings = common_vendor.index.getStorageSync("appSettings"); if (savedSettings) { this.toggleSettings.forEach((setting, index) => { if (savedSettings[setting.key] !== void 0) { this.toggleSettings[index].value = savedSettings[setting.key]; } }); } }, saveSettings() { const settings = {}; this.toggleSettings.forEach((setting) => { settings[setting.key] = setting.value; }); common_vendor.index.setStorageSync("appSettings", settings); }, loadCacheSize() { try { const info = common_vendor.index.getStorageInfoSync(); const size = (info.keys.length * 2).toFixed(0); this.cacheSize = size + "M"; } catch (e) { this.cacheSize = "20M"; } } } }; function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { return { a: common_vendor.o((...args) => $options.goBack && $options.goBack(...args)), b: common_vendor.f($data.toggleSettings, (setting, index, i0) => { return { a: common_vendor.t(setting.label), b: setting.value, c: common_vendor.o(($event) => $options.handleToggleChange(index, $event), index), d: index }; }), c: common_vendor.t($data.cacheSize), d: common_vendor.o(($event) => $options.handleInfoClick("clearCache")), e: common_vendor.o(($event) => $options.handleInfoClick("about")), f: common_vendor.o(($event) => $options.handleInfoClick("contact")), g: common_vendor.o((...args) => $options.handleLogout && $options.handleLogout(...args)) }; } const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-7fad0a1c"]]); wx.createPage(MiniProgramPage); //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/settings/settings.js.map