diff --git a/.gitignore b/.gitignore index 66240cd69c7055bdeaebf559817543d0a06c9e8e..27d4fccb5ffa8ec77bd9d2f8fed466d54bff332c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,117 @@ +class TodoApp: + def __init__(self): + self.todos = [] + + def display_todos(self): + if not self.todos: + print("No todos to display.") + else: + for index, todo in enumerate(self.todos, start=1): + print(f"{index}. {todo}") + + def add_todo(self, todo): + self.todos.append(todo) + print(f"Added: '{todo}'") + + def remove_todo(self, index): + try: + todo = self.todos.pop(index - 1) + print(f"Removed: '{todo}'") + except IndexError: + print("Invalid todo number.") + + def main(self): + while True: + print("\nOptions: 'add', 'display', 'remove', 'quit'") + choice = input("> ") + + if choice == "add": + todo = input("Enter todo: ") + self.add_todo(todo) + elif choice == "display": + self.display_todos() + elif choice == "remove": + index = int(input("Enter todo number to remove: ")) + self.remove_todo(index) + elif choice == "quit": + break + else: + print("Unknown command. Please try again.") + +if __name__ == "__main__": + app = TodoApp() + app.main() +vue create admin-system +cd admin-system +vue add router +npm install vuex axios +cd admin-system +vue add router +npm install vuex axios +cd admin-system +vue add router +npm install vuex axios +cd admin-system +vue add router +npm install vuex axios +import Vue from 'vue' +import Router from 'vue-router' +import Dashboard from '../views/Dashboard.vue' + +Vue.use(Router) + +export default new Router({ + routes: [ + { + path: '/', + name: 'dashboard', + component: Dashboard + }, + // 添加更多路由... + ] +}) +import Vue from 'vue' +import Vuex from 'vuex' + +Vue.use(Vuex) + +export default new Vuex.Store({ + state: { + user: null + }, + mutations: { + setUser(state, payload) { + state.user = payload; + } + }, + actions: {}, + getters: { + getUser: state => state.user + } +}) +// src/utils/http.js +import axios from 'axios'; +const service = axios.create({ + baseURL: process.env.BASE_API, // api的base_url + timeout: 5000 // 请求超时时间 +}) + +export default service; +import Vue from 'vue' +import App from './App.vue' +import router from './router' +import store from './store' +// 引入axios +import http from './utils/http' +Vue.prototype.$http = http + +Vue.config.productionTip = false + +new Vue({ + router, + store, + render: h => h(App), +}).$mount('#app') # Logs logs *.log