| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- "use strict";
- const common_vendor = require("../../common/vendor.js");
- const utils_userCache = require("../../utils/userCache.js");
- const _sfc_main = {
- __name: "debug",
- setup(__props) {
- const logs = common_vendor.ref([]);
- const isLogined = common_vendor.ref(false);
- const tokenDisplay = common_vendor.ref("无");
- const userInfoDisplay = common_vendor.ref("无");
- const refreshStatus = () => {
- isLogined.value = utils_userCache.isLogin();
- const token = utils_userCache.getToken();
- tokenDisplay.value = token ? token.substring(0, 20) + "..." : "无";
- const userInfo = utils_userCache.getUserInfo();
- if (userInfo) {
- userInfoDisplay.value = JSON.stringify(userInfo);
- } else {
- userInfoDisplay.value = "无";
- }
- addLog("状态已刷新");
- };
- const addLog = (text) => {
- const now = /* @__PURE__ */ new Date();
- const time = `${now.getHours().toString().padStart(2, "0")}:${now.getMinutes().toString().padStart(2, "0")}:${now.getSeconds().toString().padStart(2, "0")}`;
- logs.value.unshift({ time, text });
- if (logs.value.length > 20) {
- logs.value.pop();
- }
- };
- const simulateLogin = () => {
- const mockUserInfo = {
- id: "test_user_001",
- nickname: "测试用户",
- phone: "13800138000",
- avatar: ""
- };
- const mockToken = "mock_token_" + Date.now();
- const success = utils_userCache.saveUserInfo(mockUserInfo, mockToken);
- if (success) {
- addLog("模拟登录成功");
- refreshStatus();
- common_vendor.index.showToast({
- title: "模拟登录成功",
- icon: "success"
- });
- } else {
- addLog("模拟登录失败");
- }
- };
- const clearCache = () => {
- common_vendor.index.showModal({
- title: "提示",
- content: "确定要清除缓存吗?",
- success: (res) => {
- if (res.confirm) {
- utils_userCache.clearUserInfo();
- addLog("缓存已清除");
- refreshStatus();
- common_vendor.index.showToast({
- title: "已清除",
- icon: "success"
- });
- }
- }
- });
- };
- const gotoSplash = () => {
- addLog("跳转到启动页");
- common_vendor.index.reLaunch({
- url: "/pages/splash/splash"
- });
- };
- const gotoLogin = () => {
- addLog("跳转到登录页");
- common_vendor.index.navigateTo({
- url: "/pages/login/login"
- });
- };
- const gotoHome = () => {
- addLog("跳转到首页");
- common_vendor.index.navigateTo({
- url: "/pages/index/index"
- });
- };
- common_vendor.onMounted(() => {
- addLog("调试工具已加载");
- refreshStatus();
- });
- return (_ctx, _cache) => {
- return {
- a: common_vendor.t(isLogined.value ? "已登录" : "未登录"),
- b: isLogined.value ? 1 : "",
- c: !isLogined.value ? 1 : "",
- d: common_vendor.t(tokenDisplay.value),
- e: common_vendor.t(userInfoDisplay.value),
- f: common_vendor.o(simulateLogin, "bc"),
- g: common_vendor.o(clearCache, "bd"),
- h: common_vendor.o(refreshStatus, "f0"),
- i: common_vendor.o(gotoSplash, "41"),
- j: common_vendor.o(gotoLogin, "92"),
- k: common_vendor.o(gotoHome, "48"),
- l: common_vendor.f(logs.value, (log, index, i0) => {
- return {
- a: common_vendor.t(log.time),
- b: common_vendor.t(log.text),
- c: index
- };
- })
- };
- };
- }
- };
- const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-42851fab"]]);
- wx.createPage(MiniProgramPage);
- //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/test/debug.js.map
|