bl双性强迫侵犯h_国产在线观看人成激情视频_蜜芽188_被诱拐的少孩全彩啪啪漫画

使用Electron-Vue開發的桌面應用

這是由 Electron & Vue.js 編寫的,為程序員服務的編程工具

白云ssl適用于網站、小程序/APP、API接口等需要進行數據傳輸應用場景,ssl證書未來市場廣闊!成為創新互聯的ssl證書銷售渠道,可以享受市場價格4-6折優惠!如果有意向歡迎電話聯系或者加微信:18982081108(備注:SSL證書合作)期待與您的合作!

目前提供了四個版塊:

  • 正則表達式
  • 時間戳轉化
  • 顏色盒子
  • Json 轉化
    在這幾個模塊中,可以發現使用組件化的好處,處理多個組件之間各種數據變化非常方便!

使用 Electron-Vue 開發的桌面應用

項目地址:

Github 地址:https://github.com/TsaiKoga/it-tools

感興趣的朋友可以關注一下,或者貢獻代碼;

下面介紹一下我寫 正則表達式內容,寫的不好,望見諒...

electron-vue

克隆項目,從 electron-vue 克隆項目,然后開始編寫代碼;

https://github.com/SimulatedGREG/electron-vue.git
通過"正則表達式"這個模塊,來了解 Vue 組件通信;

electron-vue 一開始已經為你生成一些文件頁面,我們可以按照他的方法創建我們自己的頁面;

創建路由:
src/renderer/router/index.js 文件中添加路由:

export default new Router({
  routes: [
    {
      path: '/',
      name: 'landing-page',
      component: require('@/components/LandingPage').default
    },
    {
      path: '/regex-page',
      name: 'regex-page',
      component: require('@/components/RegexPage').default
    }
]
});

這里我們的 url 為 /regex-page,并且 require 了 RegexPage 組件,這個組件要放置在 components 目錄下,所以我創建了文件:src/renderer/components/RegexPage.vue

編寫組件:
可以通過復制 LandingPage.vue 組件,將它改成新組件即可:

要實現這個頁面,頭部兩個輸入框,輸入后都能與下面的 textarea 內容進行比較處理,得出結論;

這個用 組件化 vue 比純粹用 js jquery 的 dom 操作要方便太多了;

通過 template 包裹寫成 vue 組件:

<template>
  <div id="regex-page">
    <div class="regex-inner" v-show="currentTab === 'Home'">
            <div class="regex-top">
                <div class="regex-top-label">
                    <label>Your regular expression:</label>
                </div>
                <div class="regex-top-fields">
                    <div class="regex-diagonal">/</div>
                    <div class="regex-diagnoal-input">
                        <input type="text" name="regex-exp" @input='execRegex' :value='regexExp' />
                    </div>

         <div class="regex-diagonal">/</div>
                    <div>
                        <input type="text" name="regex-opt" @input="execRegex" :value="regexOpt" />
                    </div>
                </div>
             </div>

      <div class="regex-bottom">
                <div class="regex-content">
                    <label>Your test string: </label>
                    <textarea class="regex-textarea" name="regex-content" @input="execRegex" :value='regexCont'></textarea>
                </div>

       <div class="result-content result-init" v-if="regexResult['status'] == 0">
                    {{ regexResult['content'] }}
                </div>

                <div class="result-content result-match" v-if="regexResult['status'] == 1">
                    <div>
                        <div class="regex-match-btn">
                            <label>Match Result:</label>
                            <a href="javascript:void(0)" class="clean-fields" @click="cleanAllFields">Clean Fields</a>
                        </div>
                        <div class="result-item">
            <span v-for="(cont, indx) in regexResult['matchedContext']" :class="indx%2 !== 0 ? 'match' : null">{{ cont }}</span>
                        </div>
                    </div>
                    <ul v-if="regexResult['content'].length > 0">
                        <label>Match Groups:</label>
                        <div class="match-groups">
                            <li v-for="(itemGroup, index) in regexResult['content']">
                                <div class="group-item">
                                  <label>Match Group {{ index + 1 }}:</label>
                                  <ul>
                                      <li v-if="i !== 0" v-for="(item, i) in itemGroup">{{ i }}: {{ item }}</li>
                                  </ul>
                                </div>
                            </li>
                        </div>
                    </ul>
                  </div>

         <div class="result-content result-not-match" v-if="regexResult['status'] == -1">
                      {{ regexResult['content'] }}
                  </div>
              </div>
          </div>
</div>
</template>

<script>
import { mapState, mapActions } from 'vuex'

export default {
  name: 'regex-page',
  computed: {
    ...mapState('Regex', {
      regexExp: state => state.regexExp,
      regexOpt: state => state.regexOpt,
      regexCont: state => state.regexCont,
      regexResult: state => state.regexResult})
  },

    methods: {
    ...mapActions('Regex', [
      'setNav',
      'cleanFields',
      'regexMatch'
    ]),
    cleanAllFields () {
      this.cleanFields()
    },
    execRegex (event) {
      this.regexMatch(event)
    },
    updateNav (title, index) {
      this.setNav({ title: title, index: index })
    }

  }

}
</script>
<style lang="scss" scoped>
 * {

  }
</style>

至于,輸入框之間的交互,我使用 vuex 來實現他們之間數據的傳遞;

使用 Vuex 管理狀態: 一、創建 store 目錄,并創建 modules 目錄用來管理不同的命名空間的 State, Actions, Mutations 創建 src/renderer/store/modules/Regex.js 文件:

const state = {
  regexExp: '',
  regexOpt: '',
  regexCont: '',
  regexResult: { status: 0, content: "Here's result." }
}

const mutations = {
  REGEX_MATCH (state, target) {
    if (target.name === 'regex-exp') {
      state.regexExp = target.value
    }
    if (target.name === 'regex-opt') {
      state.regexOpt = target.value
    }
    if (target.name === 'regex-content') {
      state.regexCont = target.value
    }
    ...
}

const actions = {
  cleanFields ({ commit }) {
    commit('CLEAN_FIELDS')
  },
  regexMatch ({ commit }, payload) {
    commit('REGEX_MATCH', payload.target)
  }
}

export default {
  state,
  mutations,
  actions
}
  • state 給默認狀態;

  • mutations 更改對應 state ;

  • actions 用于寫異步來改變狀態或提交 mutations 的更改;

  • state 的方法被我寫在 computed,這樣組件中可以使用;

在 methods 方法中使用 mapActions,并定義其他方法來調用這些 action ;

二、main.js 加入 store 容器

import App from './App'
import router from './router'
import store from './store'

if (!process.env.IS_WEB) Vue.use(require('vue-electron'))
Vue.http = Vue.prototype.$http = axios
Vue.config.productionTip = false

new Vue({
  components: { App },
  router,
  store,
  template: '<App/>'
}).$mount('#app')

三、組件中通過 computed 或 data 使用 State,通過 methods 觸發 Actions 方法

import { mapState, mapActions } from 'vuex'

export default {
  name: 'regex-page',
  computed: {
    ...mapState('Regex', {
      regexExp: state => state.regexExp,
      regexOpt: state => state.regexOpt,
      regexCont: state => state.regexCont,
      regexResult: state => state.regexResult})
    },

    methods: {
    ...mapActions('Regex', [
      'setNav',
      'cleanFields',
      'regexMatch'
    ]),
    cleanAllFields () {
      this.cleanFields()
    },
    execRegex (event) {
      this.regexMatch(event)
    },
    updateNav (title, index) {
      this.setNav({ title: title, index: index })
    }

  }
}

在組件文件中引用了

mapState, mapActions 方法,他可以獲取這個 store 里的 state 和 action 方法,

不過要注意命名空間的使用,此處使用了 Regex 作為命名空間,所以要在 mapState 和 mapActions 中加 命名空間;

命名空間定義文件在:src/renderer/store/modules/index.js 文件;

const files = require.context('.', false, /\.js$/)
const modules = {}

files.keys().forEach(key => {
  if (key === './index.js') return
  modules[key.replace(/(\.\/|\.js)/g, '')] = files(key).default
  modules[key.replace(/(\.\/|\.js)/g, '')]['namespaced'] = true
})

export default modules

但是直接 (‘ Regex ’, [regexExp: state => state.regexExp]) 是無法使用的,必須在 module 中聲明 namespaced: true 才可以;

… mapActions() 是將里面的對象 扁平化 到 外面的對象中;

直接 mapActions 只是打開了方法,還未執行:

刪除 createSharedMutations() 的方法后,action 生效;

綁定到組件上

<input type="text" name="regex-exp" @input='execRegex' value='regexExp' />

生成桌面應用

運行命令:

npm run build:mas # 生成 mac 應用
npm run build:linux # 生成 linux 應用
npm run build:win32 # 生成 windows 應用

可以在 /build 目錄中看到生成的應用目錄

文章題目:使用Electron-Vue開發的桌面應用
本文URL:http://vcdvsql.cn/article32/gjoisc.html

成都網站建設公司_創新互聯,為您提供網站建設微信公眾號營銷型網站建設響應式網站網站策劃面包屑導航

廣告

聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯

綿陽服務器托管