| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- import common from '../../utils/util';
- import main from '../../utils/main';
- const COUNT_MAX=10;
- const app = getApp();
- Page({
- data: {
- Words:"",
- },
- onLoad: function (options) {
- let that = this;
- let words=app.globalData.SelectedWords.join("\n");
- that.setData({
- Containnerheight: main.getWindowHeight(),
- Words:words,
- });
- that.handlePaste();
- },
- handlePaste: function(e) {
- let that = this;
- // 获取剪贴板内容
- wx.getClipboardData({
- success: function(res) {
- // res.data 包含剪贴板的内容
- let pasteData = res.data;
-
- // 这里可以处理粘贴的数据,比如按空格分割成单词
- let words = pasteData.split(/[\r\n]+/); // 按空格分割
-
- // 过滤掉空字符串和非单词内容
- words = common.filterWordsWithSpecialChars(words);
- //debugger;
- let str="";
- if (that.data.Words)
- str+=that.data.Words+"\n";
- str+=words.join("\n");
- that.setData({
- Words: str,
- });
- },
- fail: function(err) {
- console.error('获取剪贴板失败', err);
- }
- });
- },
- bindKeyInput:function(e){
- let words=e.detail.value;
- this.setData({
- Words:words,
- });
- },
- submit:function(){
- app.globalData.SelectedWords=this.data.Words.split("\n");
- app.globalData.SelectedWords=common.removeDuplicateAndTrimStrings(app.globalData.SelectedWords);
- wx.navigateBack({
- delta: 1
- });
- },
- showExample:function(){
- this.setData({
- IsShowExample:!this.data.IsShowExample,
- });
- },
- onShareAppMessage: function () {
- return {
- title: app.globalData.ShareTitle,
- path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
- imageUrl: app.globalData.ShareImage,
- }
- },
- })
|