Browse Source

搭建目录

306132416@qq.com 5 years ago
commit
9fd9df8d24

+ 23 - 0
code/.gitignore

@@ -0,0 +1,23 @@
+.DS_Store
+node_modules
+/dist
+
+
+# local env files
+.env.local
+.env.*.local
+
+# Log files
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*
+pnpm-debug.log*
+
+# Editor directories and files
+.idea
+.vscode
+*.suo
+*.ntvs*
+*.njsproj
+*.sln
+*.sw?

+ 5 - 0
code/babel.config.js

@@ -0,0 +1,5 @@
+module.exports = {
+  presets: [
+    '@vue/cli-plugin-babel/preset'
+  ]
+}

File diff suppressed because it is too large
+ 25245 - 0
code/package-lock.json


+ 53 - 0
code/package.json

@@ -0,0 +1,53 @@
+{
+  "name": "vuefirst",
+  "version": "0.1.0",
+  "private": true,
+  "scripts": {
+    "serve": "vue-cli-service serve --port 9000",
+    "build": "vue-cli-service build",
+    "lint": "vue-cli-service lint"
+  },
+  "dependencies": {
+    "axios": "^0.19.0",
+    "core-js": "^3.3.2",
+    "dingtalk-jsapi": "^2.8.11",
+    "element-ui": "^2.12.0",
+    "vue": "^2.6.10",
+    "vue-router": "^3.1.3",
+    "vuex": "^3.0.1"
+  },
+  "devDependencies": {
+    "@vue/cli-plugin-babel": "^4.0.0",
+    "@vue/cli-plugin-eslint": "^4.0.0",
+    "@vue/cli-plugin-router": "^4.0.5",
+    "@vue/cli-plugin-vuex": "^4.0.5",
+    "@vue/cli-service": "^4.0.0",
+    "babel-eslint": "^10.0.3",
+    "eslint": "^5.16.0",
+    "eslint-plugin-vue": "^5.0.0",
+    "vue-template-compiler": "^2.6.10"
+  },
+  "eslintConfig": {
+    "root": true,
+    "env": {
+      "node": true
+    },
+    "extends": [
+      "plugin:vue/essential",
+      "eslint:recommended"
+    ],
+    "rules": {},
+    "parserOptions": {
+      "parser": "babel-eslint"
+    }
+  },
+  "postcss": {
+    "plugins": {
+      "autoprefixer": {}
+    }
+  },
+  "browserslist": [
+    "> 1%",
+    "last 2 versions"
+  ]
+}

BIN
code/public/favicon.ico


+ 17 - 0
code/public/index.html

@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html lang="en">
+  <head>
+    <meta charset="utf-8">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge">
+    <meta name="viewport" content="width=device-width,initial-scale=1.0">
+    <link rel="icon" href="<%= BASE_URL %>favicon.ico">
+    <title>vuefirst</title>
+  </head>
+  <body>
+    <noscript>
+      <strong>We're sorry but vuefirst doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
+    </noscript>
+    <div id="app"></div>
+    <!-- built files will be auto injected -->
+  </body>
+</html>

+ 34 - 0
code/src/App.vue

@@ -0,0 +1,34 @@
+<template>
+  <div id="app">
+    <div id="nav">
+      <router-link to="/">Home</router-link> |
+      <!-- <router-link to="/about">About</router-link> -->
+      
+      <router-link to="/ding">Ding</router-link>
+    </div>
+    <router-view/>
+  </div>
+</template>
+
+<style>
+#app {
+  font-family: 'Avenir', Helvetica, Arial, sans-serif;
+  -webkit-font-smoothing: antialiased;
+  -moz-osx-font-smoothing: grayscale;
+  text-align: center;
+  color: #2c3e50;
+}
+
+#nav {
+  padding: 30px;
+}
+
+#nav a {
+  font-weight: bold;
+  color: #2c3e50;
+}
+
+#nav a.router-link-exact-active {
+  color: #42b983;
+}
+</style>

BIN
code/src/assets/logo.png


+ 58 - 0
code/src/components/HelloWorld.vue

@@ -0,0 +1,58 @@
+<template>
+  <div class="hello">
+    <h1>{{ msg }}</h1>
+    <p>
+      For a guide and recipes on how to configure / customize this project,<br>
+      check out the
+      <a href="https://cli.vuejs.org" target="_blank" rel="noopener">vue-cli documentation</a>.
+    </p>
+    <h3>Installed CLI Plugins</h3>
+    <ul>
+      <li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel" target="_blank" rel="noopener">babel</a></li>
+      <li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-eslint" target="_blank" rel="noopener">eslint</a></li>
+    </ul>
+    <h3>Essential Links</h3>
+    <ul>
+      <li><a href="https://vuejs.org" target="_blank" rel="noopener">Core Docs</a></li>
+      <li><a href="https://forum.vuejs.org" target="_blank" rel="noopener">Forum</a></li>
+      <li><a href="https://chat.vuejs.org" target="_blank" rel="noopener">Community Chat</a></li>
+      <li><a href="https://twitter.com/vuejs" target="_blank" rel="noopener">Twitter</a></li>
+      <li><a href="https://news.vuejs.org" target="_blank" rel="noopener">News</a></li>
+    </ul>
+    <h3>Ecosystem</h3>
+    <ul>
+      <li><a href="https://router.vuejs.org" target="_blank" rel="noopener">vue-router</a></li>
+      <li><a href="https://vuex.vuejs.org" target="_blank" rel="noopener">vuex</a></li>
+      <li><a href="https://github.com/vuejs/vue-devtools#vue-devtools" target="_blank" rel="noopener">vue-devtools</a></li>
+      <li><a href="https://vue-loader.vuejs.org" target="_blank" rel="noopener">vue-loader</a></li>
+      <li><a href="https://github.com/vuejs/awesome-vue" target="_blank" rel="noopener">awesome-vue</a></li>
+    </ul>
+  </div>
+</template>
+
+<script>
+export default {
+  name: 'HelloWorld',
+  props: {
+    msg: String
+  }
+}
+</script>
+
+<!-- Add "scoped" attribute to limit CSS to this component only -->
+<style scoped>
+h3 {
+  margin: 40px 0 0;
+}
+ul {
+  list-style-type: none;
+  padding: 0;
+}
+li {
+  display: inline-block;
+  margin: 0 10px;
+}
+a {
+  color: #42b983;
+}
+</style>

+ 18 - 0
code/src/components/util/dingding.js

@@ -0,0 +1,18 @@
+import * as dd from 'dingtalk-jsapi';
+dd.ready(function () {
+    
+    var corpId = '??';
+    //使用SDK 获取免登授权码
+    dd.runtime.permission.requestAuthCode({
+        corpId: corpId,
+        onSuccess: function (result) {
+            var code = result.code;
+            sessionStorage.setItem('code',code)
+            alert(code);
+        }
+    });
+});
+
+export default {
+    dd
+}

+ 16 - 0
code/src/main.js

@@ -0,0 +1,16 @@
+import Vue from 'vue'
+import App from './App.vue'
+import router from './router'
+import store from './store'
+import ElementUI from 'element-ui';
+import 'element-ui/lib/theme-chalk/index.css';
+import dd from '@/components/util/dingding.js'
+Vue.use(ElementUI);
+Vue.config.productionTip = false
+Vue.prototype.dd = dd
+
+new Vue({
+  router,
+  store,
+  render: h => h(App)
+}).$mount('#app')

+ 35 - 0
code/src/router/index.js

@@ -0,0 +1,35 @@
+import Vue from 'vue'
+import VueRouter from 'vue-router'
+import Home from '../views/Home.vue'
+
+Vue.use(VueRouter)
+
+const routes = [
+  {
+    path: '/',
+    name: 'home',
+    component: Home
+  },
+  {
+    path: '/about',
+    name: 'about',
+    // route level code-splitting
+    // this generates a separate chunk (about.[hash].js) for this route
+    // which is lazy-loaded when the route is visited.
+    component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
+  },
+  {
+    path: '/ding',
+    name: 'ding',
+    // route level code-splitting
+    // this generates a separate chunk (about.[hash].js) for this route
+    // which is lazy-loaded when the route is visited.
+    component: () => import(/* webpackChunkName: "ding" */ '../views/dingding/Access.vue')
+  }
+]
+
+const router = new VueRouter({
+  routes
+})
+
+export default router

+ 15 - 0
code/src/store/index.js

@@ -0,0 +1,15 @@
+import Vue from 'vue'
+import Vuex from 'vuex'
+
+Vue.use(Vuex)
+
+export default new Vuex.Store({
+  state: {
+  },
+  mutations: {
+  },
+  actions: {
+  },
+  modules: {
+  }
+})

+ 5 - 0
code/src/views/About.vue

@@ -0,0 +1,5 @@
+<template>
+  <div class="about">
+    <h1>This is an about page</h1>
+  </div>
+</template>

+ 18 - 0
code/src/views/Home.vue

@@ -0,0 +1,18 @@
+<template>
+  <div class="home">
+    <img alt="Vue logo" src="../assets/logo.png">
+    <HelloWorld msg="Welcome to Your Vue.js App"/>
+  </div>
+</template>
+
+<script>
+// @ is an alias to /src
+import HelloWorld from '@/components/HelloWorld.vue'
+
+export default {
+  name: 'home',
+  components: {
+    HelloWorld
+  }
+}
+</script>

+ 39 - 0
code/src/views/dingding/Access.vue

@@ -0,0 +1,39 @@
+<template>
+  <div class="about">
+    <h1>This is a ding page: {{ code }}</h1>
+  </div>
+</template>
+<script>
+
+  export default {
+        name: 'ding',
+        data() {
+            return {
+                code: "0",
+                
+                
+            
+            }
+        },
+        mounted() {
+          this.code=this.dd;
+        
+
+            
+        },
+        created() {
+            // this.getStatisticsDurable();
+            // this.getDing();
+		},
+        methods: {
+           
+        },
+        filters: {
+         percentageConversion: function (value) {
+           if (!value) return '0'
+           return (value*100).toFixed(2).toString()+'%'
+  }
+}
+
+    }
+</script>

+ 125 - 0
code/src/views/dingding/demo.js

@@ -0,0 +1,125 @@
+/**
+ * Created by liqiao on 8/10/15.
+ */
+
+/**
+ * _config comes from server-side template. see views/index.jade
+ */
+import * as dd from 'dingtalk-jsapi';
+dd.config({
+    agentId : _config.agentId,
+    corpId : _config.corpId,
+    timeStamp : _config.timeStamp,
+    nonceStr : _config.nonceStr,
+    signature : _config.signature,
+    jsApiList : [ 'runtime.info', 'biz.contact.choose',
+            'device.notification.confirm', 'device.notification.alert',
+            'device.notification.prompt', 'biz.ding.post',
+            'biz.util.openLink' ]
+});
+
+
+dd.ready(function() {
+dd.biz.navigation.setTitle({
+title: '钉钉demo',
+onSuccess: function(data) {
+},
+onFail: function(err) {
+    log.e(JSON.stringify(err));
+}
+});
+//	 alert('dd.ready rocks!');
+
+dd.runtime.info({
+onSuccess : function(info) {
+    logger.e('runtime info: ' + JSON.stringify(info));
+},
+onFail : function(err) {
+    logger.e('fail: ' + JSON.stringify(err));
+}
+});
+dd.ui.pullToRefresh.enable({
+onSuccess: function() {
+},
+onFail: function() {
+}
+})
+
+dd.biz.navigation.setMenu({
+backgroundColor : "#ADD8E6",
+items : [
+    {
+        id:"此处可以设置帮助",//字符串
+    // "iconId":"file",//字符串,图标命名
+      text:"帮助"
+    }
+    ,
+    {
+        "id":"2",
+    "iconId":"photo",
+      "text":"我们"
+    }
+    ,
+    {
+        "id":"3",
+    "iconId":"file",
+      "text":"你们"
+    }
+    ,
+    {
+        "id":"4",
+    "iconId":"time",
+      "text":"他们"
+    }
+],
+onSuccess: function(data) {
+    alert(JSON.stringify(data));
+
+},
+onFail: function(err) {
+    alert(JSON.stringify(err));
+}
+});
+
+
+dd.runtime.permission.requestAuthCode({
+corpId : _config.corpId,
+onSuccess : function(info) {
+//			alert('authcode: ' + info.code);
+    $.ajax({
+        url : 'userinfo?code=' + info.code + '&corpid='
+                + _config.corpId,
+        type : 'GET',
+        success : function(data, status, xhr) {
+            alert(data);
+            var info = JSON.parse(data);
+
+            document.getElementById("userName").innerHTML = info.name;
+            document.getElementById("userId").innerHTML = info.userid;
+            
+            // 图片
+            if(info.avatar.length != 0){
+                var img = document.getElementById("userImg");
+                img.src = info.avatar;
+                          img.height = '100';
+                          img.width = '100';
+              }
+
+        },
+        error : function(xhr, errorType, error) {
+            logger.e("yinyien:" + _config.corpId);
+            alert(errorType + ', ' + error);
+        }
+    });
+
+},
+onFail : function(err) {
+    alert('fail: ' + JSON.stringify(err));
+}
+});
+});
+
+dd.error(function(err) {
+alert('dd error: ' + JSON.stringify(err));
+});
+export default dd