diff --git a/miniprogram/app.js b/miniprogram/app.js index 026c88f6e8744c25478a3af74cae8ff382ff488c..71cba3f86a77171d161c6b3143387c8d0bf7be1b 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -12,7 +12,7 @@ App({ userPrefix: '昵称:', userName: '月牙天冲', designPlaceholder: '自定义名称', - joinTitle: '进入', + joinTitle: '微信登录', isOldVersion: false }, homePageConfig: { @@ -35,7 +35,7 @@ App({ avatarUrl: 'https://yongma16.xyz/staticFile/common/img/aiTop.jpg', bgUrl: 'https://yongma16.xyz/staticFile/common/img/aiBg.jpg' }, - mode: 'openAiUse', + mode: 'introduce', option: 'introduce,openAiUse', layoutConfig: { introduceText: 'api介绍', @@ -46,14 +46,15 @@ App({ reportText: '复制数据', copyText: '复制', pasteText: '粘贴', - upText: "↑", - downText: "↓", + upText: "", + downText: "", errorMsg: 'openai的服务器异常!', emptyText: '欢迎', storageKey: 'openAiOptionsConfig', permissionTitle: '很抱歉您没有权限!', permissionContent: '请联系微信号:cse-yma16\r\n 需要1元开通权限\r\n1元可支持100条消息!', wxInfoImg: 'https://yongma16.xyz/staticFile/common/img/userInfo.png', + isShowOpenAi:true, limitMsgCount: 10, confirmText: '添加微信', cancelText: '返回' @@ -104,6 +105,31 @@ App({ } }); return markdownText + }, + /** + * 转换html + * @param {string} text + */ + changeHtmlText(text) { + const markdownText = this.towxml(text, 'html', { + theme: 'light', //主题 dark 黑色,light白色,不填默认light + events:{ + tap:(e)=>{ + console.log('e',e) + if(e&&e.target&&e.target.dataset.data){ + const {attrs,tag}=e.target.dataset.data + if(tag==='img'){ + const {src}=attrs + wx.previewImage({ + current: src, // 当前显示图片的http链接 + urls: [src] // 需要预览的图片http链接列表 + }) + } + } + } + } + }); + return markdownText }, getUserProfile: function (e) { // 推荐使用 wx.getUserProfile 获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认 diff --git a/miniprogram/app.wxss b/miniprogram/app.wxss index 91f0cd088cb0be8aeca6384fc043b9b10f3dabf5..ac24012ad17bb2218e70043010fc99292d71301b 100644 --- a/miniprogram/app.wxss +++ b/miniprogram/app.wxss @@ -1,4 +1,7 @@ /**app.wxss**/ + + + .container { display: flex; flex-direction: column; diff --git a/miniprogram/pages/blog/blog.wxss b/miniprogram/pages/blog/blog.wxss index 5932516c703ea1e2bae54ef9b5485bb588c469a4..cb17a20b31b520c7c0998fa8b8085127a935cc6a 100644 --- a/miniprogram/pages/blog/blog.wxss +++ b/miniprogram/pages/blog/blog.wxss @@ -33,7 +33,7 @@ .blog-title{ text-align: center; font-weight: bold; - background: rgba(114, 158, 240); + background: rgba(16, 116, 187); color: #ffffff; position: relative; margin:0; diff --git a/miniprogram/pages/codeOnline/codeOnline.js b/miniprogram/pages/codeOnline/codeOnline.js new file mode 100644 index 0000000000000000000000000000000000000000..d9cf8e07b86f73f02bd959feaddb2d4f64b57373 --- /dev/null +++ b/miniprogram/pages/codeOnline/codeOnline.js @@ -0,0 +1,89 @@ +// pages/codeOnline/codeOnline.js +const app = getApp() +Component({ + /** + * 继承父级样式 + */ + options: { + addGlobalClass: true, + }, + + + + /** + * 组件的属性列表 + */ + properties: { + + }, + + /** + * 组件的初始数据 + */ + data: { + baseUrl: 'https://yongma16.xyz', + runJsPath: '/common-api/searchOpenAiText/', + config: { + title: '运行js', + runCodePlaceholderText: '请输入js', + loading: true, + runBtnText: '运行', + formatBtnText: '格式化', + htmlNode: '' + }, + codeVal: '', + loading: false, + runCodeRes: '结果集', + htmlNode: '结果集' + }, + + + lifetimes: { + // 生命周期函数,可以为函数,或一个在 methods 段中定义的方法名 + attached: function () { + this.initData('请输入') + } + }, + methods: { + initData(val) { + this.setData({ + htmlNode: app.changeHtmlText(val) + }) + }, + runCode() { + const codeVal = this.data.codeVal + console.log('运行代码', codeVal) + const thisBack = this + if (codeVal) { + // let obj =(new Function("return "+""+codeVal+""))(); + const data = { + coontent: codeVal + } + wx.request({ + url: this.data.baseUrl + this.data.runJsPath, + method: 'POST', + data: data, + success: res => { + console.log(res, 'res') + const resText=res.data + thisBack.setData({ + runCodeRes:resText , + htmlNode: app.changeHtmlText(resText) + }) + }, + fail: r => { + console.log(r, r) + } + }) + + } + // // eval(this.data.codeVal) + + }, + bindKeyInput(e) { + this.setData({ + codeVal: e.detail.value + }) + }, + } +}) \ No newline at end of file diff --git a/miniprogram/pages/codeOnline/codeOnline.json b/miniprogram/pages/codeOnline/codeOnline.json new file mode 100644 index 0000000000000000000000000000000000000000..9dc3362d3c459dc908f0a50f315aa8ee84bd2058 --- /dev/null +++ b/miniprogram/pages/codeOnline/codeOnline.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "towxml":"/towxml/towxml" + } +} \ No newline at end of file diff --git a/miniprogram/pages/codeOnline/codeOnline.wxml b/miniprogram/pages/codeOnline/codeOnline.wxml new file mode 100644 index 0000000000000000000000000000000000000000..241bbe21685c2ff443b2d157fe1f04fd44c1be9c --- /dev/null +++ b/miniprogram/pages/codeOnline/codeOnline.wxml @@ -0,0 +1,25 @@ + + + + {{config.title}} + + + + + + + + + + + + + + + + +